[PATCH] D98932: [RISCV] Don't call setHasMultipleConditionRegisters(), so icmp is sunk
Craig Topper via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 18 22:18:11 PST 2021
craig.topper updated this revision to Diff 388390.
craig.topper added a comment.
Rebase to just show test change. I haven't pre-committed the test to the repo yet.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D98932/new/
https://reviews.llvm.org/D98932
Files:
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
llvm/lib/Target/RISCV/RISCVISelLowering.h
llvm/test/CodeGen/RISCV/sink-icmp.ll
Index: llvm/test/CodeGen/RISCV/sink-icmp.ll
===================================================================
--- llvm/test/CodeGen/RISCV/sink-icmp.ll
+++ llvm/test/CodeGen/RISCV/sink-icmp.ll
@@ -10,8 +10,7 @@
; RV32-NEXT: lh a0, 0(a0)
; RV32-NEXT: bltz a0, .LBB0_3
; RV32-NEXT: # %bb.1: # %.LBB0_1
-; RV32-NEXT: seqz a1, a1
-; RV32-NEXT: bnez a1, .LBB0_3
+; RV32-NEXT: beqz a1, .LBB0_3
; RV32-NEXT: # %bb.2: # %.LBB0_2
; RV32-NEXT: ret
; RV32-NEXT: .LBB0_3: # %return
@@ -23,8 +22,7 @@
; RV64-NEXT: lh a0, 0(a0)
; RV64-NEXT: bltz a0, .LBB0_3
; RV64-NEXT: # %bb.1: # %.LBB0_1
-; RV64-NEXT: seqz a1, a1
-; RV64-NEXT: bnez a1, .LBB0_3
+; RV64-NEXT: beqz a1, .LBB0_3
; RV64-NEXT: # %bb.2: # %.LBB0_2
; RV64-NEXT: ret
; RV64-NEXT: .LBB0_3: # %return
Index: llvm/lib/Target/RISCV/RISCVISelLowering.h
===================================================================
--- llvm/lib/Target/RISCV/RISCVISelLowering.h
+++ llvm/lib/Target/RISCV/RISCVISelLowering.h
@@ -620,6 +620,14 @@
/// NOTE: Once BUILD_VECTOR can be custom lowered for all legal vector types,
/// this override can be removed.
bool mergeStoresAfterLegalization(EVT VT) const override;
+
+ /// Disable normalizing
+ /// select(N0&N1, X, Y) => select(N0, select(N1, X, Y), Y) and
+ /// select(N0|N1, X, Y) => select(N0, select(N1, X, Y, Y))
+ /// RISCV doesn't have flags so it's better to perform the and/or in a GPR.
+ bool shouldNormalizeToSelectSequence(LLVMContext &, EVT) const override {
+ return false;
+ };
};
namespace RISCV {
Index: llvm/lib/Target/RISCV/RISCVISelLowering.cpp
===================================================================
--- llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -963,9 +963,6 @@
// Jumps are expensive, compared to logic
setJumpIsExpensive();
- // We can use any register for comparisons
- setHasMultipleConditionRegisters();
-
setTargetDAGCombine(ISD::ADD);
setTargetDAGCombine(ISD::SUB);
setTargetDAGCombine(ISD::AND);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98932.388390.patch
Type: text/x-patch
Size: 2070 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211119/10e7cac7/attachment.bin>
More information about the llvm-commits
mailing list