[all-commits] [llvm/llvm-project] e6549b: [RISCV][ISel] Allow emitting `addiw` with u32simm1...
Yingwei Zheng via All-commits
all-commits at lists.llvm.org
Fri Oct 4 18:23:50 PDT 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: e6549b8036089f20c6ac01e644a544aa2b231ca8
https://github.com/llvm/llvm-project/commit/e6549b8036089f20c6ac01e644a544aa2b231ca8
Author: Yingwei Zheng <dtcxzyw2333 at gmail.com>
Date: 2024-10-05 (Sat, 05 Oct 2024)
Changed paths:
M llvm/lib/Target/RISCV/RISCVInstrInfo.td
M llvm/test/CodeGen/RISCV/rv64zba.ll
Log Message:
-----------
[RISCV][ISel] Allow emitting `addiw` with u32simm12 rhs (#111116)
In InstCombine, we shrink the constant by setting unused bits to zero
(e.g. `((X + -2) & 4294967295) -> ((X + 4294967294) & 4294967295)`).
However, this canonicalization blocks emitting `addiw` and creates
redundant li for simm32 rhs:
```
; bin/llc -mtriple=riscv64 -mattr=+zba test.ll -o -
define i64 @add_u32simm32_zextw(i64 %x) nounwind {
entry:
%add = add i64 %x, 4294967294
%and = and i64 %add, 4294967295
ret i64 %and
}
```
```
add_u32simm32_zextw: # @add_u32simm32_zextw
# %bb.0: # %entry
li a1, -2
add a0, a0, a1
zext.w a0, a0
ret
```
This patch addresses the issue by matching u32simm12 rhs.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list