Skip to content

Commit 30080b0

Browse files
committed
[DAGCombiner] Minor compile time improvement to (sext_in_reg (sign_extend_vector_inreg x)) optimization.
Don't bother calling ComputeNumSignBits if N00Bits < ExtVTBits. No matter what answer we get back this will be true: (N00Bits - DAG.ComputeNumSignBits(N00, DemandedSrcElts)) < ExtVTBits) So we might as well save the computation. This makes the code more consistent with the similar (sext_in_reg (sext x)) handling above.
1 parent d11d5d1 commit 30080b0

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11799,8 +11799,9 @@ SDValue DAGCombiner::visitSIGN_EXTEND_INREG(SDNode *N) {
1179911799
bool IsZext = N0.getOpcode() == ISD::ZERO_EXTEND_VECTOR_INREG;
1180011800
APInt DemandedSrcElts = APInt::getLowBitsSet(SrcElts, DstElts);
1180111801
if ((N00Bits == ExtVTBits ||
11802-
(!IsZext && (N00Bits - DAG.ComputeNumSignBits(N00, DemandedSrcElts)) <
11803-
ExtVTBits)) &&
11802+
(!IsZext && (N00Bits < ExtVTBits ||
11803+
(N00Bits - DAG.ComputeNumSignBits(N00, DemandedSrcElts)) <
11804+
ExtVTBits))) &&
1180411805
(!LegalOperations ||
1180511806
TLI.isOperationLegal(ISD::SIGN_EXTEND_VECTOR_INREG, VT)))
1180611807
return DAG.getNode(ISD::SIGN_EXTEND_VECTOR_INREG, SDLoc(N), VT, N00);

0 commit comments

Comments
 (0)