Skip to content

Commit c6947da

Browse files
authored
[RISCV] Add helper method for detecting BEXTI or TH_TST is supported. NFC (#157915)
These instructions both extract single bit to bit 0 and fill the upper bits with 0. There's at least one place where we check for BEXTI but not TH_TST. I wanted to keep this patch NFC so that will be a follow up fix.
1 parent 6a581f7 commit c6947da

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1052,7 +1052,7 @@ void RISCVDAGToDAGISel::Select(SDNode *Node) {
10521052
SDLoc DL(Node);
10531053
MVT VT = Node->getSimpleValueType(0);
10541054

1055-
bool HasBitTest = Subtarget->hasStdExtZbs() || Subtarget->hasVendorXTHeadBs();
1055+
bool HasBitTest = Subtarget->hasBEXTILike();
10561056

10571057
switch (Opcode) {
10581058
case ISD::Constant: {

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2173,7 +2173,7 @@ bool RISCVTargetLowering::isMaskAndCmp0FoldingBeneficial(
21732173
// on the basis that it's possible the sinking+duplication of the AND in
21742174
// CodeGenPrepare triggered by this hook wouldn't decrease the instruction
21752175
// count and would increase code size (e.g. ANDI+BNEZ => BEXTI+BNEZ).
2176-
if (!Subtarget.hasStdExtZbs() && !Subtarget.hasVendorXTHeadBs())
2176+
if (!Subtarget.hasBEXTILike())
21772177
return false;
21782178
ConstantInt *Mask = dyn_cast<ConstantInt>(AndI.getOperand(1));
21792179
if (!Mask)

llvm/lib/Target/RISCV/RISCVSubtarget.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,8 @@ class RISCVSubtarget : public RISCVGenSubtargetInfo {
186186
return HasStdExtZfhmin || HasStdExtZfbfmin;
187187
}
188188

189+
bool hasBEXTILike() const { return HasStdExtZbs || HasVendorXTHeadBs; }
190+
189191
bool hasCZEROLike() const {
190192
return HasStdExtZicond || HasVendorXVentanaCondOps;
191193
}

0 commit comments

Comments
 (0)