Skip to content

Commit 2bffdb8

Browse files
committed
[ARM][TargetLowering] Combine Level should not be a factor in shouldFoldConstantShiftPairToMask
This should be based on the type and instructions, and only thumb uses combine level anyway.
1 parent a49030e commit 2bffdb8

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
@@ -854,8 +854,7 @@ class LLVM_ABI TargetLoweringBase {
854854
/// This is usually true on most targets. But some targets, like Thumb1,
855855
/// have immediate shift instructions, but no immediate "and" instruction;
856856
/// this makes the fold unprofitable.
857-
virtual bool shouldFoldConstantShiftPairToMask(const SDNode *N,
858-
CombineLevel Level) const {
857+
virtual bool shouldFoldConstantShiftPairToMask(const SDNode *N) const {
859858
return true;
860859
}
861860

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10521,7 +10521,7 @@ SDValue DAGCombiner::visitSHL(SDNode *N) {
1052110521
// folding this will increase the total number of instructions.
1052210522
if (N0.getOpcode() == ISD::SRL &&
1052310523
(N0.getOperand(1) == N1 || N0.hasOneUse()) &&
10524-
TLI.shouldFoldConstantShiftPairToMask(N, Level)) {
10524+
TLI.shouldFoldConstantShiftPairToMask(N)) {
1052510525
if (ISD::matchBinaryPredicate(N1, N0.getOperand(1), MatchShiftAmount,
1052610526
/*AllowUndefs*/ false,
1052710527
/*AllowTypeMismatch*/ true)) {
@@ -11100,7 +11100,7 @@ SDValue DAGCombiner::visitSRL(SDNode *N) {
1110011100
// fold (srl (shl x, c1), c2) -> (and (shl x, (sub c1, c2), MASK) or
1110111101
// (and (srl x, (sub c2, c1), MASK)
1110211102
if ((N0.getOperand(1) == N1 || N0->hasOneUse()) &&
11103-
TLI.shouldFoldConstantShiftPairToMask(N, Level)) {
11103+
TLI.shouldFoldConstantShiftPairToMask(N)) {
1110411104
auto MatchShiftAmount = [OpSizeInBits](ConstantSDNode *LHS,
1110511105
ConstantSDNode *RHS) {
1110611106
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
@@ -18280,7 +18280,7 @@ bool AArch64TargetLowering::isDesirableToCommuteXorWithShift(
1828018280
}
1828118281

1828218282
bool AArch64TargetLowering::shouldFoldConstantShiftPairToMask(
18283-
const SDNode *N, CombineLevel Level) const {
18283+
const SDNode *N) const {
1828418284
assert(((N->getOpcode() == ISD::SHL &&
1828518285
N->getOperand(0).getOpcode() == ISD::SRL) ||
1828618286
(N->getOpcode() == ISD::SRL &&

llvm/lib/Target/AArch64/AArch64ISelLowering.h

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

299299
/// Return true if it is profitable to fold a pair of shifts into a mask.
300-
bool shouldFoldConstantShiftPairToMask(const SDNode *N,
301-
CombineLevel Level) const override;
300+
bool shouldFoldConstantShiftPairToMask(const SDNode *N) const override;
302301

303302
bool shouldFoldSelectWithIdentityConstant(unsigned BinOpcode, EVT VT,
304303
unsigned SelectOpcode, SDValue X,

llvm/lib/Target/ARM/ARMISelLowering.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13878,7 +13878,7 @@ bool ARMTargetLowering::isDesirableToCommuteXorWithShift(
1387813878
}
1387913879

1388013880
bool ARMTargetLowering::shouldFoldConstantShiftPairToMask(
13881-
const SDNode *N, CombineLevel Level) const {
13881+
const SDNode *N) const {
1388213882
assert(((N->getOpcode() == ISD::SHL &&
1388313883
N->getOperand(0).getOpcode() == ISD::SRL) ||
1388413884
(N->getOpcode() == ISD::SRL &&
@@ -13888,7 +13888,8 @@ bool ARMTargetLowering::shouldFoldConstantShiftPairToMask(
1388813888
if (!Subtarget->isThumb1Only())
1388913889
return true;
1389013890

13891-
if (Level == BeforeLegalizeTypes)
13891+
EVT VT = N->getValueType(0);
13892+
if (VT.getScalarSizeInBits() > 32)
1389213893
return true;
1389313894

1389413895
return false;

llvm/lib/Target/ARM/ARMISelLowering.h

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

771771
bool isDesirableToCommuteXorWithShift(const SDNode *N) const override;
772772

773-
bool shouldFoldConstantShiftPairToMask(const SDNode *N,
774-
CombineLevel Level) const override;
773+
bool shouldFoldConstantShiftPairToMask(const SDNode *N) const override;
775774

776775
bool shouldFoldSelectWithIdentityConstant(unsigned BinOpcode, EVT VT,
777776
unsigned SelectOpcode, SDValue X,

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
@@ -3638,7 +3638,7 @@ bool X86TargetLowering::preferScalarizeSplat(SDNode *N) const {
36383638
}
36393639

36403640
bool X86TargetLowering::shouldFoldConstantShiftPairToMask(
3641-
const SDNode *N, CombineLevel Level) const {
3641+
const SDNode *N) const {
36423642
assert(((N->getOpcode() == ISD::SHL &&
36433643
N->getOperand(0).getOpcode() == ISD::SRL) ||
36443644
(N->getOpcode() == ISD::SRL &&
@@ -3653,7 +3653,7 @@ bool X86TargetLowering::shouldFoldConstantShiftPairToMask(
36533653
// the fold for non-splats yet.
36543654
return N->getOperand(1) == N->getOperand(0).getOperand(1);
36553655
}
3656-
return TargetLoweringBase::shouldFoldConstantShiftPairToMask(N, Level);
3656+
return TargetLoweringBase::shouldFoldConstantShiftPairToMask(N);
36573657
}
36583658

36593659
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
@@ -1240,8 +1240,7 @@ namespace llvm {
12401240
getJumpConditionMergingParams(Instruction::BinaryOps Opc, const Value *Lhs,
12411241
const Value *Rhs) const override;
12421242

1243-
bool shouldFoldConstantShiftPairToMask(const SDNode *N,
1244-
CombineLevel Level) const override;
1243+
bool shouldFoldConstantShiftPairToMask(const SDNode *N) const override;
12451244

12461245
bool shouldFoldMaskToVariableShiftPair(SDValue Y) const override;
12471246

0 commit comments

Comments
 (0)