[PATCH] D35114: Fix invalid cast in instcombine UMul/ZExt idiom

Serge Pavlov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 10 03:47:40 PDT 2017


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

LGTM with small remark.



================
Comment at: lib/Transforms/InstCombine/InstCombineCompares.cpp:3849
         // Replace (mul & mask) --> zext (mul.with.overflow & short_mask)
-        ConstantInt *CI = cast<ConstantInt>(BO->getOperand(1));
-        APInt ShortMask = CI->getValue().trunc(MulWidth);
+        auto ShortMask = Builder->CreateTrunc(BO->getOperand(1),
+                                              Builder->getIntNTy(MulWidth));
----------------
Explicit type instead of auto would improve readability.


Repository:
  rL LLVM

https://reviews.llvm.org/D35114





More information about the llvm-commits mailing list