[PATCH] D27461: [DAGCombine] Add (sext_in_reg (zext x)) -> (sext x) combine

Andrea Di Biagio via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 6 09:02:33 PST 2016


andreadb accepted this revision.
andreadb added a comment.
This revision is now accepted and ready to land.

Hi Simon,
I only have one question. Otherwise the patch LGMT.

Thanks



================
Comment at: lib/CodeGen/SelectionDAG/DAGCombiner.cpp:7130-7148
   // fold (sext_in_reg (sext x)) -> (sext x)
   // fold (sext_in_reg (aext x)) -> (sext x)
   // if x is small enough.
   if (N0.getOpcode() == ISD::SIGN_EXTEND || N0.getOpcode() == ISD::ANY_EXTEND) {
     SDValue N00 = N0.getOperand(0);
     if (N00.getScalarValueSizeInBits() <= EVTBits &&
         (!LegalOperations || TLI.isOperationLegal(ISD::SIGN_EXTEND, VT)))
----------------
Your new rule has a lot in common with the folding rules between lines [7130:7138]. You could potentially extend those folding rules to accomodate your extra case (ISD::ZERO_EXTEND). The only difference seems to be the check for EVTBits. All other checks (for legal operations) are identical.



Repository:
  rL LLVM

https://reviews.llvm.org/D27461





More information about the llvm-commits mailing list