Commit 32894793 by Richard Biener Committed by Richard Biener

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
parent e27bfda2
2016-11-07 Richard Biener <rguenther@suse.de>
PR tree-optimization/78228
* tree-ssa-phiopt.c (abs_replacement): Avoid introducing
undefined behavior.
2016-11-07 Kyrylo Tkachov <kyrylo.tkachov@arm.com>
PR target/77822
2016-11-07 Richard Biener <rguenther@suse.de>
PR tree-optimization/78228
* gcc.dg/tree-ssa/phi-opt-15.c: New testcase.
2016-11-07 Kyrylo Tkachov <kyrylo.tkachov@arm.com>
PR target/77822
......
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-optimized" } */
int
foo (int i)
{
if (i > 0)
i = -i;
return i;
}
/* { dg-final { scan-tree-dump-not "ABS" "optimized" } } */
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment