Skip to content

Commit d95f8ff

Browse files
authored
[ARM][TargetLowering] Combine Level should not be a factor in shouldFoldConstantShiftPairToMask (NFC) (llvm#156949)
This should be based on the type and instructions, and only thumb uses combine level anyway.
1 parent 26eca24 commit d95f8ff

File tree

10 files changed

+14
-18
lines changed

10 files changed

+14
-18
lines changed

llvm/include/llvm/CodeGen/TargetLowering.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -847,8 +847,7 @@ class LLVM_ABI TargetLoweringBase {
847847
/// This is usually true on most targets. But some targets, like Thumb1,
848848
/// have immediate shift instructions, but no immediate "and" instruction;
849849
/// this makes the fold unprofitable.
850-
virtual bool shouldFoldConstantShiftPairToMask(const SDNode *N,
851-
CombineLevel Level) const {
850+
virtual bool shouldFoldConstantShiftPairToMask(const SDNode *N) const {
852851
return true;
853852
}
854853

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10628,7 +10628,7 @@ SDValue DAGCombiner::visitSHL(SDNode *N) {
1062810628
// folding this will increase the total number of instructions.
1062910629
if (N0.getOpcode() == ISD::SRL &&
1063010630
(N0.getOperand(1) == N1 || N0.hasOneUse()) &&
10631-
TLI.shouldFoldConstantShiftPairToMask(N, Level)) {
10631+
TLI.shouldFoldConstantShiftPairToMask(N)) {
1063210632
if (ISD::matchBinaryPredicate(N1, N0.getOperand(1), MatchShiftAmount,
1063310633
/*AllowUndefs*/ false,
1063410634
/*AllowTypeMismatch*/ true)) {
@@ -11207,7 +11207,7 @@ SDValue DAGCombiner::visitSRL(SDNode *N) {
1120711207
// fold (srl (shl x, c1), c2) -> (and (shl x, (sub c1, c2), MASK) or
1120811208
// (and (srl x, (sub c2, c1), MASK)
1120911209
if ((N0.getOperand(1) == N1 || N0->hasOneUse()) &&
11210-
TLI.shouldFoldConstantShiftPairToMask(N, Level)) {
11210+
TLI.shouldFoldConstantShiftPairToMask(N)) {
1121111211
auto MatchShiftAmount = [OpSizeInBits](ConstantSDNode *LHS,
1121211212
ConstantSDNode *RHS) {
1121311213
const APInt &LHSC = LHS->getAPIntValue();

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18640,7 +18640,7 @@ bool AArch64TargetLowering::isDesirableToCommuteXorWithShift(
1864018640
}
1864118641

1864218642
bool AArch64TargetLowering::shouldFoldConstantShiftPairToMask(
18643-
const SDNode *N, CombineLevel Level) const {
18643+
const SDNode *N) const {
1864418644
assert(((N->getOpcode() == ISD::SHL &&
1864518645
N->getOperand(0).getOpcode() == ISD::SRL) ||
1864618646
(N->getOpcode() == ISD::SRL &&

llvm/lib/Target/AArch64/AArch64ISelLowering.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,7 @@ class AArch64TargetLowering : public TargetLowering {
300300
bool isDesirableToCommuteXorWithShift(const SDNode *N) const override;
301301

302302
/// Return true if it is profitable to fold a pair of shifts into a mask.
303-
bool shouldFoldConstantShiftPairToMask(const SDNode *N,
304-
CombineLevel Level) const override;
303+
bool shouldFoldConstantShiftPairToMask(const SDNode *N) const override;
305304

306305
/// Return true if it is profitable to fold a pair of shifts into a mask.
307306
bool shouldFoldMaskToVariableShiftPair(SDValue Y) const override {

llvm/lib/Target/ARM/ARMISelLowering.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13816,7 +13816,7 @@ bool ARMTargetLowering::isDesirableToCommuteXorWithShift(
1381613816
}
1381713817

1381813818
bool ARMTargetLowering::shouldFoldConstantShiftPairToMask(
13819-
const SDNode *N, CombineLevel Level) const {
13819+
const SDNode *N) const {
1382013820
assert(((N->getOpcode() == ISD::SHL &&
1382113821
N->getOperand(0).getOpcode() == ISD::SRL) ||
1382213822
(N->getOpcode() == ISD::SRL &&
@@ -13826,7 +13826,8 @@ bool ARMTargetLowering::shouldFoldConstantShiftPairToMask(
1382613826
if (!Subtarget->isThumb1Only())
1382713827
return true;
1382813828

13829-
if (Level == BeforeLegalizeTypes)
13829+
EVT VT = N->getValueType(0);
13830+
if (VT.getScalarSizeInBits() > 32)
1383013831
return true;
1383113832

1383213833
return false;

llvm/lib/Target/ARM/ARMISelLowering.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -772,8 +772,7 @@ class VectorType;
772772

773773
bool isDesirableToCommuteXorWithShift(const SDNode *N) const override;
774774

775-
bool shouldFoldConstantShiftPairToMask(const SDNode *N,
776-
CombineLevel Level) const override;
775+
bool shouldFoldConstantShiftPairToMask(const SDNode *N) const override;
777776

778777
/// Return true if it is profitable to fold a pair of shifts into a mask.
779778
bool shouldFoldMaskToVariableShiftPair(SDValue Y) const override {

llvm/lib/Target/Mips/MipsISelLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1306,7 +1306,7 @@ bool MipsTargetLowering::hasBitTest(SDValue X, SDValue Y) const {
13061306
}
13071307

13081308
bool MipsTargetLowering::shouldFoldConstantShiftPairToMask(
1309-
const SDNode *N, CombineLevel Level) const {
1309+
const SDNode *N) const {
13101310
assert(((N->getOpcode() == ISD::SHL &&
13111311
N->getOperand(0).getOpcode() == ISD::SRL) ||
13121312
(N->getOpcode() == ISD::SRL &&

llvm/lib/Target/Mips/MipsISelLowering.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,8 +290,7 @@ class TargetRegisterClass;
290290
bool isCheapToSpeculateCttz(Type *Ty) const override;
291291
bool isCheapToSpeculateCtlz(Type *Ty) const override;
292292
bool hasBitTest(SDValue X, SDValue Y) const override;
293-
bool shouldFoldConstantShiftPairToMask(const SDNode *N,
294-
CombineLevel Level) const override;
293+
bool shouldFoldConstantShiftPairToMask(const SDNode *N) const override;
295294

296295
/// Return the register type for a given MVT, ensuring vectors are treated
297296
/// as a series of gpr sized integers.

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3633,7 +3633,7 @@ bool X86TargetLowering::preferScalarizeSplat(SDNode *N) const {
36333633
}
36343634

36353635
bool X86TargetLowering::shouldFoldConstantShiftPairToMask(
3636-
const SDNode *N, CombineLevel Level) const {
3636+
const SDNode *N) const {
36373637
assert(((N->getOpcode() == ISD::SHL &&
36383638
N->getOperand(0).getOpcode() == ISD::SRL) ||
36393639
(N->getOpcode() == ISD::SRL &&
@@ -3648,7 +3648,7 @@ bool X86TargetLowering::shouldFoldConstantShiftPairToMask(
36483648
// the fold for non-splats yet.
36493649
return N->getOperand(1) == N->getOperand(0).getOperand(1);
36503650
}
3651-
return TargetLoweringBase::shouldFoldConstantShiftPairToMask(N, Level);
3651+
return TargetLoweringBase::shouldFoldConstantShiftPairToMask(N);
36523652
}
36533653

36543654
bool X86TargetLowering::shouldFoldMaskToVariableShiftPair(SDValue Y) const {

llvm/lib/Target/X86/X86ISelLowering.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,8 +1244,7 @@ namespace llvm {
12441244
getJumpConditionMergingParams(Instruction::BinaryOps Opc, const Value *Lhs,
12451245
const Value *Rhs) const override;
12461246

1247-
bool shouldFoldConstantShiftPairToMask(const SDNode *N,
1248-
CombineLevel Level) const override;
1247+
bool shouldFoldConstantShiftPairToMask(const SDNode *N) const override;
12491248

12501249
bool shouldFoldMaskToVariableShiftPair(SDValue Y) const override;
12511250

0 commit comments

Comments
 (0)