diff options
author | Richard Biener <rguenther@suse.de> | 2016-11-07 12:25:09 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2016-11-07 12:25:09 +0000 |
commit | 32894793ff96f4c56b90e0f0e1d961e526a6edc7 (patch) | |
tree | c262e115f9ce800d3846ad1e27f9cf648149d1b1 /gcc/tree-ssa-phiopt.c | |
parent | e27bfda2fc621864fd0ffd2ba3a2cee38b3c7965 (diff) | |
download | gcc-32894793ff96f4c56b90e0f0e1d961e526a6edc7.zip gcc-32894793ff96f4c56b90e0f0e1d961e526a6edc7.tar.gz gcc-32894793ff96f4c56b90e0f0e1d961e526a6edc7.tar.bz2 |
re PR middle-end/78228 (fstrict-overflow breaks code without overflow?)
2016-11-07 Richard Biener <rguenther@suse.de>
PR tree-optimization/78228
* tree-ssa-phiopt.c (abs_replacement): Avoid introducing
undefined behavior.
* gcc.dg/tree-ssa/phi-opt-15.c: New testcase.
From-SVN: r241899
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 3f3b88c..63738d0 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) |