Skip to content

Commit bd9bf9c

Browse files
committed
[X86] SimplifyDemandedBits - move MaskedValueIsZero as late as possible to avoid unnecessary (recursive) analysis costs. NFC.
Mentioned on D155472 for the SHL equivalent
1 parent a834b79 commit bd9bf9c

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1886,15 +1886,15 @@ bool TargetLowering::SimplifyDemandedBits(
18861886

18871887
// Narrow shift to lower half - similar to ShrinkDemandedOp.
18881888
// (srl i64:x, K) -> (i64 zero_extend (srl (i32 (trunc i64:x)), K))
1889-
if ((BitWidth % 2) == 0 && !VT.isVector() &&
1890-
((InDemandedMask.countLeadingZeros() >= (BitWidth / 2)) ||
1891-
TLO.DAG.MaskedValueIsZero(
1892-
Op0, APInt::getHighBitsSet(BitWidth, BitWidth / 2)))) {
1889+
if ((BitWidth % 2) == 0 && !VT.isVector()) {
1890+
APInt HiBits = APInt::getHighBitsSet(BitWidth, BitWidth / 2);
18931891
EVT HalfVT = EVT::getIntegerVT(*TLO.DAG.getContext(), BitWidth / 2);
18941892
if (isNarrowingProfitable(VT, HalfVT) &&
18951893
isTypeDesirableForOp(ISD::SRL, HalfVT) &&
18961894
isTruncateFree(VT, HalfVT) && isZExtFree(HalfVT, VT) &&
1897-
(!TLO.LegalOperations() || isOperationLegal(ISD::SRL, VT))) {
1895+
(!TLO.LegalOperations() || isOperationLegal(ISD::SRL, VT)) &&
1896+
((InDemandedMask.countLeadingZeros() >= (BitWidth / 2)) ||
1897+
TLO.DAG.MaskedValueIsZero(Op0, HiBits))) {
18981898
SDValue NewOp = TLO.DAG.getNode(ISD::TRUNCATE, dl, HalfVT, Op0);
18991899
SDValue NewShiftAmt = TLO.DAG.getShiftAmountConstant(
19001900
ShAmt, HalfVT, dl, TLO.LegalTypes());

0 commit comments

Comments
 (0)