[llvm] 3e6b80b - [CSKY] Optimize conditional select with CLRT/CLRF
Ben Shi via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 4 00:22:45 PDT 2023
Author: Ben Shi
Date: 2023-07-04T15:22:18+08:00
New Revision: 3e6b80b1bdf42d7f3c73541250b2eb2480e7df32
URL: https://github.com/llvm/llvm-project/commit/3e6b80b1bdf42d7f3c73541250b2eb2480e7df32
DIFF: https://github.com/llvm/llvm-project/commit/3e6b80b1bdf42d7f3c73541250b2eb2480e7df32.diff
LOG: [CSKY] Optimize conditional select with CLRT/CLRF
Reviewed By: zixuan-wu
Differential Revision: https://reviews.llvm.org/D154409
Added:
Modified:
llvm/lib/Target/CSKY/CSKYInstrInfo.td
llvm/test/CodeGen/CSKY/select.ll
Removed:
################################################################################
diff --git a/llvm/lib/Target/CSKY/CSKYInstrInfo.td b/llvm/lib/Target/CSKY/CSKYInstrInfo.td
index 078b4c8cb6084b..549c883c34a729 100644
--- a/llvm/lib/Target/CSKY/CSKYInstrInfo.td
+++ b/llvm/lib/Target/CSKY/CSKYInstrInfo.td
@@ -1410,6 +1410,11 @@ defm : MOVTF32Pat1<setuge, setule, CMPHS32, MOVT32>;
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.
diff --git a/llvm/test/CodeGen/CSKY/select.ll b/llvm/test/CodeGen/CSKY/select.ll
index eb0bb94e70ec07..a26b1ff113c68b 100644
--- a/llvm/test/CodeGen/CSKY/select.ll
+++ b/llvm/test/CodeGen/CSKY/select.ll
@@ -135,9 +135,8 @@ entry:
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_true(i1 %c, i32 %q) {
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:
More information about the llvm-commits
mailing list