While writing tests for AltiVec i found out that the sum of two signed integers is translated to IR as 'add nsw' while the difference of signed integers is translated to 'sub' without "No Signed Wrap" keyword. It seems that corresponding code for producing 'sub nsw' is missing in \clang\lib\CodeGen\CGExprScalar.cpp, ScalarExprEmitter::EmitSub(.) method. Attached is the patch that adds code for generating 'sub nsw' similar to the ScalarExprEmitter::EmitAdd(.) method. Please review.
CGExprScalar.diff (563 Bytes)