[PATCH] Add NSW/NUW flags in InstCombine

David Tweed david.tweed at gmail.com
Tue Apr 1 08:41:38 PDT 2014


  My understanding was that the meaning of nsw/nuw flags was "there's no need to care about the semantics of the code that would execute in the event that there's a wraparound of that type" (so that in particular there's no need to add extra code to deal with those cases, or forbid optimizing away code that will only execute in the overflowing case). In the case of where an overflow is undefined behaviour according to the higher level languages semantics, the compiler needn't care because it's entitled to do whatever it wants if that occurs. In the case where it's known that overflow can't happen (due to the way the operands on the instruction have been produced) the compiler needn't care because that code can't ever be executed. Or is this understanding not quite right?

  (Obviously I do work at ARM, but I've had no involvement in this patch.)

http://llvm-reviews.chandlerc.com/D2426



More information about the llvm-commits mailing list