Skip to content

Commit 72f30ac

Browse files
committed
[RISCV] Disable Zbs special case in performTRUNCATECombine with -riscv-experimental-rv64-legal-i32.
1 parent bc09ec6 commit 72f30ac

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12242,7 +12242,7 @@ static SDValue performTRUNCATECombine(SDNode *N, SelectionDAG &DAG,
1224212242
// shift amounts larger than 31 would produce poison. If we wait until
1224312243
// type legalization, we'll create RISCVISD::SRLW and we can't recover it
1224412244
// to use a BEXT instruction.
12245-
if (Subtarget.is64Bit() && Subtarget.hasStdExtZbs() && VT == MVT::i1 &&
12245+
if (!RV64LegalI32 && Subtarget.is64Bit() && Subtarget.hasStdExtZbs() && VT == MVT::i1 &&
1224612246
N0.getValueType() == MVT::i32 && N0.getOpcode() == ISD::SRL &&
1224712247
!isa<ConstantSDNode>(N0.getOperand(1)) && N0.hasOneUse()) {
1224812248
SDLoc DL(N0);

llvm/lib/Target/RISCV/RISCVInstrInfoZb.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,8 @@ def : Pat<(i32 (xor (shiftop<shl> 1, (XLenVT GPR:$rs2)), GPR:$rs1)),
861861
(BINV GPR:$rs1, GPR:$rs2)>;
862862
def : Pat<(i32 (and (shiftop<srl> GPR:$rs1, (XLenVT GPR:$rs2)), 1)),
863863
(BEXT GPR:$rs1, GPR:$rs2)>;
864+
def : Pat<(i64 (and (anyext (i32 (shiftop<srl> GPR:$rs1, (XLenVT GPR:$rs2)))), 1)),
865+
(BEXT GPR:$rs1, GPR:$rs2)>;
864866

865867
def : Pat<(i32 (and (srl GPR:$rs1, uimm5:$shamt), (i32 1))),
866868
(BEXTI GPR:$rs1, uimm5:$shamt)>;

0 commit comments

Comments
 (0)