Skip to content

Commit 074a6f5

Browse files
committed
fix the comments
1 parent fd31fe5 commit 074a6f5

File tree

6 files changed

+31
-18
lines changed

6 files changed

+31
-18
lines changed

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17930,10 +17930,13 @@ AArch64TargetLowering::isDesirableToCommuteWithShift(const SDNode *N,
1793017930

1793117931
SDValue ShiftLHS = N->getOperand(0);
1793217932
EVT VT = N->getValueType(0);
17933+
SDValue Add;
17934+
17935+
if (!ShiftLHS->hasOneUse())
17936+
return false;
1793317937

1793417938
if ((ShiftLHS.getOpcode() == ISD::SIGN_EXTEND &&
17935-
!(ShiftLHS->hasOneUse() && ShiftLHS.getOperand(0)->hasOneUse())) ||
17936-
!ShiftLHS->hasOneUse())
17939+
!ShiftLHS.getOperand(0)->hasOneUse()))
1793717940
return false;
1793817941

1793917942
// If ShiftLHS is unsigned bit extraction: ((x >> C) & mask), then do not
@@ -17954,6 +17957,7 @@ AArch64TargetLowering::isDesirableToCommuteWithShift(const SDNode *N,
1795417957
}
1795517958
}
1795617959
}
17960+
1795717961
return true;
1795817962
}
1795917963

llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,9 +1074,11 @@ bool AMDGPUTargetLowering::isDesirableToCommuteWithShift(
10741074
"Expected shift op");
10751075

10761076
SDValue ShiftLHS = N->getOperand(0);
1077+
if (!ShiftLHS->hasOneUse())
1078+
return false;
1079+
10771080
if ((ShiftLHS.getOpcode() == ISD::SIGN_EXTEND &&
1078-
!(ShiftLHS->hasOneUse() && ShiftLHS.getOperand(0)->hasOneUse())) ||
1079-
!ShiftLHS->hasOneUse())
1081+
!ShiftLHS.getOperand(0)->hasOneUse()))
10801082
return false;
10811083

10821084
// Always commute pre-type legalization and right shifts.

llvm/lib/Target/ARM/ARMISelLowering.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13881,9 +13881,11 @@ ARMTargetLowering::isDesirableToCommuteWithShift(const SDNode *N,
1388113881
"Expected shift op");
1388213882

1388313883
SDValue ShiftLHS = N->getOperand(0);
13884+
if (!ShiftLHS->hasOneUse())
13885+
return false;
13886+
1388413887
if ((ShiftLHS.getOpcode() == ISD::SIGN_EXTEND &&
13885-
!(ShiftLHS->hasOneUse() && ShiftLHS.getOperand(0)->hasOneUse())) ||
13886-
!ShiftLHS->hasOneUse())
13888+
!ShiftLHS.getOperand(0)->hasOneUse()))
1388713889
return false;
1388813890

1388913891
if (Level == BeforeLegalizeTypes)

llvm/lib/Target/Hexagon/HexagonISelLowering.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2154,17 +2154,19 @@ bool HexagonTargetLowering::hasBitTest(SDValue X, SDValue Y) const {
21542154

21552155
bool HexagonTargetLowering::isDesirableToCommuteWithShift(
21562156
const SDNode *N, CombineLevel Level) const {
2157+
using namespace llvm::SDPatternMatch;
21572158
assert((N->getOpcode() == ISD::SHL || N->getOpcode() == ISD::SRA ||
21582159
N->getOpcode() == ISD::SRL) &&
21592160
"Expected shift op");
21602161

21612162
SDValue ShiftLHS = N->getOperand(0);
2162-
if ((ShiftLHS.getOpcode() == ISD::SIGN_EXTEND &&
2163-
!(ShiftLHS->hasOneUse() && ShiftLHS.getOperand(0)->hasOneUse())) ||
2164-
!ShiftLHS->hasOneUse())
2165-
return false;
2163+
SDValue Add;
21662164

2167-
return true;
2165+
if (ShiftLHS->hasOneUse() ||
2166+
sd_match(ShiftLHS, m_OneUse(m_SExt(m_OneUse(m_Value(Add))))))
2167+
return true;
2168+
2169+
return false;
21682170
}
21692171

21702172
bool HexagonTargetLowering::isTruncateFree(Type *Ty1, Type *Ty2) const {

llvm/lib/Target/PowerPC/PPCISelLowering.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19169,15 +19169,17 @@ Value *PPCTargetLowering::emitMaskedAtomicCmpXchgIntrinsic(
1916919169

1917019170
bool PPCTargetLowering::isDesirableToCommuteWithShift(
1917119171
const SDNode *N, CombineLevel Level) const {
19172+
using namespace llvm::SDPatternMatch;
1917219173
assert((N->getOpcode() == ISD::SHL || N->getOpcode() == ISD::SRA ||
1917319174
N->getOpcode() == ISD::SRL) &&
1917419175
"Expected shift op");
1917519176

1917619177
SDValue ShiftLHS = N->getOperand(0);
19177-
if ((ShiftLHS.getOpcode() == ISD::SIGN_EXTEND &&
19178-
!(ShiftLHS->hasOneUse() && ShiftLHS.getOperand(0)->hasOneUse())) ||
19179-
!ShiftLHS->hasOneUse())
19180-
return false;
19178+
SDValue Add;
1918119179

19182-
return true;
19180+
if (ShiftLHS->hasOneUse() ||
19181+
sd_match(ShiftLHS, m_OneUse(m_SExt(m_OneUse(m_Value(Add))))))
19182+
return true;
19183+
19184+
return false;
1918319185
}

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60683,8 +60683,9 @@ bool X86TargetLowering::isDesirableToCommuteWithShift(
6068360683

6068460684
SDValue ShiftLHS = N->getOperand(0);
6068560685
SDValue Add;
60686-
if (sd_match(ShiftLHS, m_OneUse(m_SExt(m_OneUse(m_Value(Add))))) ||
60687-
ShiftLHS->hasOneUse())
60686+
60687+
if (ShiftLHS->hasOneUse() ||
60688+
sd_match(ShiftLHS, m_OneUse(m_SExt(m_OneUse(m_Value(Add))))))
6068860689
return true;
6068960690

6069060691
return false;

0 commit comments

Comments
 (0)