[llvm-branch-commits] [llvm] [RISCV] Add initial support of memcmp expansion (PR #107548)

Craig Topper via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Oct 10 10:32:47 PDT 2024


================
@@ -112,42 +104,46 @@ entry:
 define i32 @bcmp_size_2(ptr %s1, ptr %s2) nounwind optsize {
 ; CHECK-ALIGNED-RV32-LABEL: bcmp_size_2:
 ; CHECK-ALIGNED-RV32:       # %bb.0: # %entry
-; CHECK-ALIGNED-RV32-NEXT:    addi sp, sp, -16
-; CHECK-ALIGNED-RV32-NEXT:    sw ra, 12(sp) # 4-byte Folded Spill
-; CHECK-ALIGNED-RV32-NEXT:    li a2, 2
-; CHECK-ALIGNED-RV32-NEXT:    call bcmp
-; CHECK-ALIGNED-RV32-NEXT:    lw ra, 12(sp) # 4-byte Folded Reload
-; CHECK-ALIGNED-RV32-NEXT:    addi sp, sp, 16
+; CHECK-ALIGNED-RV32-NEXT:    lbu a2, 1(a0)
----------------
topperc wrote:

I was proposing

```
lbu a2, 1(a0)
lbu a0, 0(a0)
lbu a3, 1(a1)
lbu a1, 0(a1)
xor a2, a2, a3
xor a0, a0, a1
or  a2, a2, a0
snez a2, a2
```

that looks like fewer instructions.

https://github.com/llvm/llvm-project/pull/107548


More information about the llvm-branch-commits mailing list