[PATCH] D65150: [InstSimplify] Drop leftover "division-by-zero guard" around `@llvm.umul.with.overflow` overflow bit

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 23 07:32:52 PDT 2019


lebedev.ri created this revision.
lebedev.ri added reviewers: nikic, spatel, xbolva00.
lebedev.ri added a project: LLVM.
Herald added a subscriber: hiraditya.

Now that with D65143 <https://reviews.llvm.org/D65143>/D65144 <https://reviews.llvm.org/D65144> we've produce `@llvm.umul.with.overflow`,
and with D65147 <https://reviews.llvm.org/D65147>+D65148 <https://reviews.llvm.org/D65148> we've flattened the CFG, we now can see that
the guard may have been there to prevent division by zero is redundant.
We can simply drop it:

  ----------------------------------------
  Name: no overflow and not zero
    %iszero = icmp ne i4 %y, 0
    %umul = umul_overflow i4 %x, %y
    %umul.ov = extractvalue {i4, i1} %umul, 1
    %retval.0 = and i1 %iszero, %umul.ov
    ret i1 %retval.0
  =>
    %iszero = icmp ne i4 %y, 0
    %umul = umul_overflow i4 %x, %y
    %umul.ov = extractvalue {i4, i1} %umul, 1
    %retval.0 = and i1 %iszero, %umul.ov
    ret %umul.ov
  
  Done: 1
  Optimization is correct!


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D65150

Files:
  llvm/lib/Analysis/InstructionSimplify.cpp
  llvm/test/Transforms/InstSimplify/div-by-0-guard-before-smul_ov.ll
  llvm/test/Transforms/InstSimplify/div-by-0-guard-before-umul_ov.ll
  llvm/test/Transforms/PhaseOrdering/unsigned-multiply-overflow-check.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65150.211298.patch
Type: text/x-patch
Size: 7947 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190723/638710bd/attachment.bin>


More information about the llvm-commits mailing list