[PATCH] D22238: Reapply "InstCombine: Reduce trunc (shl x, K) width."

David Majnemer via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 13 12:27:42 PDT 2016


majnemer added inline comments.

================
Comment at: lib/Transforms/InstCombine/InstCombineCasts.cpp:540
@@ +539,3 @@
+    // dest type is native.
+    if (match(Src, m_And(m_Value(A), m_ConstantInt(Cst)))) {
+      Value *NewTrunc = Builder->CreateTrunc(A, DestTy, A->getName() + ".tr");
----------------
arsenm wrote:
> majnemer wrote:
> > Can `m_ConstantInt` be `m_Constant` here?
> This would also require an additional variable since Cst is ConstantInt
I think we can afford an extra variable.

================
Comment at: lib/Transforms/InstCombine/InstCombineCasts.cpp:548
@@ +547,3 @@
+    // dest type is native and cst < dest size.
+    if (match(Src, m_Shl(m_Value(A), m_ConstantInt(Cst))) &&
+        !match(A, m_Shr(m_Value(), m_Constant()))) {
----------------
majnemer wrote:
> Could you use m_APInt instead of m_ConstantInt?
OK.


https://reviews.llvm.org/D22238





More information about the llvm-commits mailing list