[SystemZ] Clear NW flags on an ISD::SUB when reused as comparison.
The SystemZ backend will try to reuse an existing subtraction of two values whenever they are to be compared for equality. This depends on the SystemZ subtraction instruction setting the condition code, which can also signal overflow. A later pass will remove the compare and reuse the CC from the subtraction directly. However, if that subtraction has the NSW flag set it will not include the overflow bit in the updated CC user. That was a bug which can lead to wrong results, as shown by a csmith program. Fixes: https://github.com/llvm/llvm-project/issues/61268 Reviewed By: nikic, uweigand Differential Revision: https://reviews.llvm.org/D145811
Loading
Please sign in to comment