[llvm] [RISCV] Move strength reduction of mul X, 3/5/9*2^N to combine (PR #89966)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 24 12:32:35 PDT 2024


dtcxzyw wrote:

This patch breaks bext pattern:
```
; bin/llc -O3 -mtriple=riscv64 -mattr=+m,+zbs,+zba test.ll -o -
define ptr @test(ptr %0, i32 %1, i32 %2) {
entry:
  %3 = lshr i32 %1, %2
  %4 = and i32 %3, 1
  %5 = zext nneg i32 %4 to i64
  %6 = getelementptr inbounds [3 x float], ptr %0, i64 %5
  ret ptr %6
}
```
Before:
```
test:
        bext    a1, a1, a2
        sh1add  a1, a1, a1
        sh2add  a0, a1, a0
        ret
```

After:
```
test:
        srl     a1, a1, a2
        andi    a1, a1, 1
        sh1add  a1, a1, a1
        sh2add  a0, a1, a0
        ret
```
See https://github.com/dtcxzyw/llvm-codegen-benchmark/pull/25#discussion_r1578372935.




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


More information about the llvm-commits mailing list