Kaynağa Gözat

src/jit.rs: Use short path for multiplication with imm == 0

We already have a case where we set the destination register to 0
immediately in multdivmod(), for the divisions by zero (with an
immediate). The result of a multiplication by zero is also zero, reuse
the same path.

Signed-off-by: Quentin Monnet <quentin@isovalent.com>
Quentin Monnet 2 yıl önce
ebeveyn
işleme
4cd20cd8c3
1 değiştirilmiş dosya ile 1 ekleme ve 1 silme
  1. 1 1
      src/jit.rs

+ 1 - 1
src/jit.rs

@@ -368,7 +368,7 @@ fn muldivmod(jit: &mut JitMemory, pc: u16, opc: u8, src: u8, dst: u8, imm: i32)
     let is64 = (opc & ebpf::BPF_CLS_MASK) == ebpf::BPF_ALU64;
     let is_reg = (opc & ebpf::BPF_X) == ebpf::BPF_X;
 
-    if div && !is_reg && imm == 0 {
+    if (div || mul) && !is_reg && imm == 0 {
         // Division by zero returns 0
         // Set register to 0: xor with itself
         emit_alu32(jit, 0x31, dst, dst);