[PATCH] D88429: [InstCombine] visitTrunc - trunc (*shr (trunc A), C) --> trunc(*shr A, C)

Simon Pilgrim via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 28 10:53:18 PDT 2020


RKSimon added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp:862
+    // removed by the trunc.
+    if (C->ule(MaxShiftAmt)) {
+      auto *ShAmt = ConstantInt::get(AType, C->getZExtValue());
----------------
lebedev.ri wrote:
> Do you want to deal with non-splats from the getgo?
> See `m_SpecificInt_ICMP()`
OMG - I never knew that existed - beautiful!!!!


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp:867
+                         : Builder.CreateLShr(A, ShAmt);
+      return CastInst::CreateTruncOrBitCast(Shift, DestTy);
+    }
----------------
lebedev.ri wrote:
> I think you can preserve `exact`ness of the shift.
Yes - alive2 says so https://alive2.llvm.org/ce/z/FLH5SX


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88429/new/

https://reviews.llvm.org/D88429



More information about the llvm-commits mailing list