[PATCH] [Instcombine] Recognize test for overflow in integer multiplication.
Benjamin Kramer
benny.kra at gmail.com
Sat Apr 12 06:29:05 PDT 2014
Some more review comments. I think you're good to commit when those are fixed.
================
Comment at: lib/Transforms/InstCombine/InstCombineCompares.cpp:2129
@@ +2128,3 @@
+ if (ConstantInt *CI = dyn_cast<ConstantInt>(OtherVal)) {
+ APInt MaxVal(CI->getBitWidth(), 1ULL << MulWidth);
+ if (MaxVal.eq(CI->getValue()))
----------------
MulWidth can be >= 64. would be better to use APInt arithmetic.
================
Comment at: lib/Transforms/InstCombine/InstCombineCompares.cpp:2070
@@ +2069,3 @@
+ if (ConstantInt *CI = dyn_cast<ConstantInt>(BO->getOperand(1))) {
+ APInt CVal = CI->getValue();
+ if (CVal.getBitWidth() - CVal.countLeadingZeros() > MulWidth)
----------------
"const APInt &" would save a copy.
http://reviews.llvm.org/D2814
More information about the llvm-commits
mailing list