[PATCH] D33338: [InstCombineCasts] Take in account final size when transforming sext->lshr->trunc patterns

Jacob Young via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 18 19:01:25 PDT 2017


jacobly added inline comments.


================
Comment at: lib/Transforms/InstCombine/InstCombineCasts.cpp:608
+    if (CISize == ASize)
+      if (ShiftAmt <= MaxAmt)
+        return BinaryOperator::CreateAShr(A, ConstantInt::get(CI.getType(),
----------------
This needs to be checked in every case, so maybe it should be factored out.


================
Comment at: lib/Transforms/InstCombine/InstCombineCasts.cpp:611
+                                                     std::min(ShiftAmt, ASize - 1)));
+    if (CISize > ASize)
+      if (SExt->hasOneUse() && ShiftAmt <= MaxAmt) {
----------------
This code also handles `CISize < ASize` correctly: http://rise4fun.com/Alive/eSU. There was no need to check `ShiftAmt <= SExtSize - ASize` in the first place since we only care about zero bits being shifted into the final type.


https://reviews.llvm.org/D33338





More information about the llvm-commits mailing list