[llvm] [DAG] Introduce generic shl_add node [NFC] (PR #88791)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 18 10:33:06 PDT 2024


dtcxzyw wrote:

This patch is not a NFC.

Example: https://godbolt.org/z/PMTqjf45M
```
; llc -mtriple=riscv64 -mattr=+zba test.ll
define i64 @func(i64 signext %0, i32 signext %1) {
entry:
  %2 = zext i32 %1 to i64
  %3 = shl nuw nsw i64 %2, 5
  %4 = shl nsw i64 %0, 3
  %5 = add nsw i64 %3, %4
  ret i64 %5
}
```

Before:
```
func:                                   # @func
        sh2add.uw       a0, a1, a0
        slli    a0, a0, 3
        ret
```

After:
```
func:                                   # @func
        zext.w  a1, a1
        sh2add  a0, a1, a0
        slli    a0, a0, 3
        ret
```

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


More information about the llvm-commits mailing list