Skip to content

Commit 6adf6d3

Browse files
committed
[RISCV] Add helper method for detecting BEXTI or TH_TST is supported. NFC
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 ebf86b1 commit 6adf6d3

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-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: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,10 @@ class RISCVSubtarget : public RISCVGenSubtargetInfo {
186186
return HasStdExtZfhmin || HasStdExtZfbfmin;
187187
}
188188

189+
bool hasBEXTILike() const {
190+
return HasStdExtZbs || HasVendorXTHeadBs;
191+
}
192+
189193
bool hasCZEROLike() const {
190194
return HasStdExtZicond || HasVendorXVentanaCondOps;
191195
}

0 commit comments

Comments
 (0)