[llvm] [DAG] Add legalization handling for AVGCEIL/AVGFLOOR nodes (PR #92096)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 12 07:26:08 PDT 2024


dtcxzyw wrote:

Hi @RKSimon, I think this patch causes some regressions on riscv: https://github.com/dtcxzyw/llvm-codegen-benchmark/commit/97ad8e7b80da7aba30042b112095724802189681

Reproducer:
```
; llc -mtriple=riscv64 test.ll -o -
define signext i64 @func000000000000002b(i32 signext %0) #0 {
entry:
  %1 = zext nneg i32 %0 to i64
  %2 = add nsw i64 %1, -1
  %3 = lshr i64 %2, 1
  %4 = add nuw nsw i64 %3, 1
  %5 = and i64 %4, 9223372036854775806
  ret i64 %5
}
```
Before (74f200baedfed496880ca86ce9409788b0d0eaca):
```
func000000000000002b:
        addi    a0, a0, -1
        srli    a0, a0, 1
        addi    a0, a0, 1
        andi    a0, a0, -2
        ret
```
After (47afa10bbaa89351afa9bcc53dd959e6181ebf3d):
```
func000000000000002b:
        addi    a0, a0, -1
        srli    a0, a0, 1
        addi    a0, a0, 1
        li      a1, -3
        srli    a1, a1, 1
        and     a0, a0, a1
        ret
```

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


More information about the llvm-commits mailing list