[PATCH] D134155: [RISCV]Preserve (and X, 0xffff) in targetShrinkDemandedConstant
Liao Chunyu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 18 23:19:48 PDT 2022
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2e74157ad47b: [RISCV]Preserve (and X, 0xffff) in targetShrinkDemandedConstant (authored by liaolucy).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D134155/new/
https://reviews.llvm.org/D134155
Files:
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
llvm/test/CodeGen/RISCV/rv64i-demanded-bits.ll
Index: llvm/test/CodeGen/RISCV/rv64i-demanded-bits.ll
===================================================================
--- llvm/test/CodeGen/RISCV/rv64i-demanded-bits.ll
+++ llvm/test/CodeGen/RISCV/rv64i-demanded-bits.ll
@@ -140,3 +140,16 @@
%6 = add i32 %4, %2
ret i32 %6
}
+
+define i32 @and_or(i32 signext %x) {
+; CHECK-LABEL: and_or:
+; CHECK: # %bb.0: # %entry
+; CHECK-NEXT: ori a0, a0, 255
+; CHECK-NEXT: slli a0, a0, 48
+; CHECK-NEXT: srli a0, a0, 48
+; CHECK-NEXT: ret
+entry:
+ %and = and i32 %x, 65280
+ %or = or i32 %and, 255
+ ret i32 %or
+}
Index: llvm/lib/Target/RISCV/RISCVISelLowering.cpp
===================================================================
--- llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -10041,12 +10041,11 @@
// And has a few special cases for zext.
if (Opcode == ISD::AND) {
- // Preserve (and X, 0xffff) when zext.h is supported.
- if (Subtarget.hasStdExtZbb() || Subtarget.hasStdExtZbp()) {
- APInt NewMask = APInt(Mask.getBitWidth(), 0xffff);
- if (IsLegalMask(NewMask))
- return UseMask(NewMask);
- }
+ // Preserve (and X, 0xffff), if zext.h exists use zext.h,
+ // otherwise use SLLI + SRLI.
+ APInt NewMask = APInt(Mask.getBitWidth(), 0xffff);
+ if (IsLegalMask(NewMask))
+ return UseMask(NewMask);
// Try to preserve (and X, 0xffffffff), the (zext_inreg X, i32) pattern.
if (VT == MVT::i64) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134155.461141.patch
Type: text/x-patch
Size: 1483 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220919/45dc97c2/attachment.bin>
More information about the llvm-commits
mailing list