[PATCH] D104665: [instcombine] Fold overflow check using umulo to comparison

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 22 15:57:34 PDT 2021


reames added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstructionCombining.cpp:3086
 
+      assert(*EV.idx_begin() == 1);
+
----------------
spatel wrote:
> Add assert msg - "Unexpected extract index for overflow inst"
Done, though I don't think this actually improves the code.


================
Comment at: llvm/lib/Transforms/InstCombine/InstructionCombining.cpp:3105
+        // (unless C == 0, in which case no overflow ever occurs)
+        if (ConstantInt *CI = dyn_cast<ConstantInt>(WO->getRHS())) {
+          assert(!CI->isZero() && "handled by instruction simplify");
----------------
spatel wrote:
> This matches the existing check for add, but we could use match(WO->getRHS(), m_APInt(C)) and handle vector splat constants for almost free. Add a TODO comment?
I hadn't know these had vector overloads.  Learn something new every day.


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

https://reviews.llvm.org/D104665



More information about the llvm-commits mailing list