diff options
Diffstat (limited to 'gcc/tree-ssa-phiopt.c')
-rw-r--r-- | gcc/tree-ssa-phiopt.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c index 3f3b88cfc61..63738d07e2e 100644 --- a/gcc/tree-ssa-phiopt.c +++ b/gcc/tree-ssa-phiopt.c @@ -1474,6 +1474,14 @@ abs_replacement (basic_block cond_bb, basic_block middle_bb, else negate = false; + /* If the code negates only iff positive then make sure to not + introduce undefined behavior when negating or computing the absolute. + ??? We could use range info if present to check for arg1 == INT_MIN. */ + if (negate + && (ANY_INTEGRAL_TYPE_P (TREE_TYPE (arg1)) + && ! TYPE_OVERFLOW_WRAPS (TREE_TYPE (arg1)))) + return false; + result = duplicate_ssa_name (result, NULL); if (negate) |