HomePhabricator

[CodeGen] use nsw negation for builtin abs

Description

[CodeGen] use nsw negation for builtin abs

The clang builtins have the same semantics as the stdlib functions.
The stdlib functions are defined in section 7.20.6.1 of the C standard with:
"If the result cannot be represented, the behavior is undefined."

That lets us mark the negation with 'nsw' because "sub i32 0, INT_MIN" would
be UB/poison.

Differential Revision: https://reviews.llvm.org/D47202

Details

Committed
spatelMay 22 2018, 4:02 PM
Differential Revision
D47202: [CodeGen] use nsw negation for abs
Parents
rL333037: [CMake] Support builtins as Clang default rtlib in compiler-rt
Branches
Unknown
Tags
Unknown