Skip to content

Commit 39c8df3

Browse files
authored
[RISCV] Add VendorXTHeadCondMov to useInversedSetcc. (#157758)
These instructions have a eqz/nez operand like Zicond and XVentanaCondOps so the goal of using bexti seems applicable to them as well.
1 parent f059d2b commit 39c8df3

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18945,7 +18945,8 @@ static SDValue useInversedSetcc(SDNode *N, SelectionDAG &DAG,
1894518945
// Replace (setcc eq (and x, C)) with (setcc ne (and x, C))) to generate
1894618946
// BEXTI, where C is power of 2.
1894718947
if (Subtarget.hasStdExtZbs() && VT.isScalarInteger() &&
18948-
(Subtarget.hasStdExtZicond() || Subtarget.hasVendorXVentanaCondOps())) {
18948+
(Subtarget.hasStdExtZicond() || Subtarget.hasVendorXVentanaCondOps() ||
18949+
Subtarget.hasVendorXTHeadCondMov())) {
1894918950
SDValue LHS = Cond.getOperand(0);
1895018951
SDValue RHS = Cond.getOperand(1);
1895118952
ISD::CondCode CC = cast<CondCodeSDNode>(Cond.getOperand(2))->get();

llvm/test/CodeGen/RISCV/condops.ll

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,7 @@ define i64 @zero_singlebit1(i64 %rs1, i64 %rs2) {
126126
;
127127
; RV64XTHEADCONDMOV-LABEL: zero_singlebit1:
128128
; RV64XTHEADCONDMOV: # %bb.0:
129-
; RV64XTHEADCONDMOV-NEXT: lui a2, 1
130-
; RV64XTHEADCONDMOV-NEXT: and a1, a1, a2
129+
; RV64XTHEADCONDMOV-NEXT: bexti a1, a1, 12
131130
; RV64XTHEADCONDMOV-NEXT: th.mvnez a0, zero, a1
132131
; RV64XTHEADCONDMOV-NEXT: ret
133132
;
@@ -4412,9 +4411,9 @@ define i64 @single_bit3(i80 %x, i64 %y) {
44124411
;
44134412
; RV64XTHEADCONDMOV-LABEL: single_bit3:
44144413
; RV64XTHEADCONDMOV: # %bb.0: # %entry
4415-
; RV64XTHEADCONDMOV-NEXT: slli a1, a1, 63
4416-
; RV64XTHEADCONDMOV-NEXT: srai a0, a1, 63
4417-
; RV64XTHEADCONDMOV-NEXT: and a0, a0, a2
4414+
; RV64XTHEADCONDMOV-NEXT: mv a0, a2
4415+
; RV64XTHEADCONDMOV-NEXT: andi a1, a1, 1
4416+
; RV64XTHEADCONDMOV-NEXT: th.mveqz a0, zero, a1
44184417
; RV64XTHEADCONDMOV-NEXT: ret
44194418
;
44204419
; RV32ZICOND-LABEL: single_bit3:

0 commit comments

Comments
 (0)