[PATCH] [Instcombine] Recognize test for overflow in integer multiplication.

Serge Pavlov sepavloff at gmail.com
Sun Apr 13 10:02:53 PDT 2014


  Thank you for review!


  2014-04-12 20:29 GMT+07:00 Benjamin Kramer <benny.kra at gmail.com>:

  >
  >   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
  >
  >
  >

http://reviews.llvm.org/D2814






More information about the llvm-commits mailing list