[PATCH] D154409: [CSKY] Optimize conditional select with CLRT/CLRF
Ben Shi via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 4 00:22:56 PDT 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3e6b80b1bdf4: [CSKY] Optimize conditional select with CLRT/CLRF (authored by benshi001).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D154409/new/
https://reviews.llvm.org/D154409
Files:
llvm/lib/Target/CSKY/CSKYInstrInfo.td
llvm/test/CodeGen/CSKY/select.ll
Index: llvm/test/CodeGen/CSKY/select.ll
===================================================================
--- llvm/test/CodeGen/CSKY/select.ll
+++ llvm/test/CodeGen/CSKY/select.ll
@@ -135,9 +135,8 @@
define i32 @selectRI_0_if_true(i1 %c, i32 %q) {
; CHECK-LABEL: selectRI_0_if_true:
; CHECK: # %bb.0:
-; CHECK-NEXT: movi16 a2, 0
; CHECK-NEXT: btsti16 a0, 0
-; CHECK-NEXT: movt32 a1, a2
+; CHECK-NEXT: clrt32 a1
; CHECK-NEXT: mov16 a0, a1
; CHECK-NEXT: rts16
;
@@ -162,10 +161,9 @@
define i32 @selectRI_0_if_false(i1 %c, i32 %q) {
; CHECK-LABEL: selectRI_0_if_false:
; CHECK: # %bb.0:
-; CHECK-NEXT: movi16 a2, 0
; CHECK-NEXT: btsti16 a0, 0
-; CHECK-NEXT: movt32 a2, a1
-; CHECK-NEXT: mov16 a0, a2
+; CHECK-NEXT: clrf32 a1
+; CHECK-NEXT: mov16 a0, a1
; CHECK-NEXT: rts16
;
; GENERIC-LABEL: selectRI_0_if_false:
Index: llvm/lib/Target/CSKY/CSKYInstrInfo.td
===================================================================
--- llvm/lib/Target/CSKY/CSKYInstrInfo.td
+++ llvm/lib/Target/CSKY/CSKYInstrInfo.td
@@ -1410,6 +1410,11 @@
defm : MOVTF32Pat1<setult, setugt, CMPHS32, MOVF32>;
defm : MOVTF32Pat1<setlt, setgt, CMPLT32, MOVT32>;
defm : MOVTF32Pat1<setge, setle, CMPLT32, MOVF32>;
+
+def : Pat<(select CARRY:$ca, (i32 0), GPR:$other),
+ (CLRT32 CARRY:$ca, GPR:$other)>;
+def : Pat<(select CARRY:$ca, GPR:$other, (i32 0)),
+ (CLRF32 CARRY:$ca, GPR:$other)>;
}
// Constant materialize patterns.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D154409.536974.patch
Type: text/x-patch
Size: 1489 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230704/532859a3/attachment.bin>
More information about the llvm-commits
mailing list