[PATCH] D39417: InstCombine: Preserve nuw when reassociating nuw ops

Matt Arsenault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 18 12:06:02 PDT 2019


arsenm marked an inline comment as done.
arsenm added inline comments.


================
Comment at: lib/Transforms/InstCombine/InstructionCombining.cpp:198-229
 // Return true, if No Signed Wrap should be maintained for I.
 // The No Signed Wrap flag can be kept if the operation "B (I.getOpcode) C",
 // where both B and C should be ConstantInts, results in a constant that does
 // not overflow. This function only handles the Add and Sub opcodes. For
 // all other opcodes, the function conservatively returns false.
 static bool MaintainNoSignedWrap(BinaryOperator &I, Value *B, Value *C) {
   OverflowingBinaryOperator *OBO = dyn_cast<OverflowingBinaryOperator>(&I);
----------------
lebedev.ri wrote:
> Why does `MaintainNoSignedWrap()` need all that logic to prove that no overflow happens,
> but `MaintainNoUnsignedWrap()` does nothing of sorts?
I'm not really sure why MaintainNoSignedWrap has all of those checks. It seems to me like it's looking an overflow that was already illegal?


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

https://reviews.llvm.org/D39417





More information about the llvm-commits mailing list