[PATCH] D145811: [SystemZ] Don't reuse a sub that can overflow during isel.

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Mar 11 02:22:32 PST 2023


nikic added inline comments.


================
Comment at: llvm/lib/Target/SystemZ/SystemZISelLowering.cpp:2426
       if (N->getOpcode() == ISD::SUB &&
+          (!N->getFlags().hasNoSignedWrap() && !N->getFlags().hasNoUnsignedWrap()) &&
           ((N->getOperand(0) == C.Op0 && N->getOperand(1) == C.Op1) ||
----------------
jonpa wrote:
> nikic wrote:
> > It would be better to drop the flags instead -- the general preference is to drop nowrap flags rather than block optimizations due to their presence.
> Hmm - I wish I had a better grasp of this.. How is it that we can just drop the nowrap flag and let the program behavior change and print the wrong result?
> 
Dropping nowrap flag just means that instead of returning `poison`, the instruction will now return a well-defined value instead. This is always safe to do and will not change program behavior in the usual sense (this is called "refinement").


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

https://reviews.llvm.org/D145811



More information about the llvm-commits mailing list