Commit a0857153 by Richard Guenther Committed by Richard Biener

re PR middle-end/34130 (the builtin abs() gives wrong result when used in some expression)

2007-11-17  Richard Guenther  <rguenther@suse.de>

	PR middle-end/34130
	* fold-const.c (extract_muldiv_1): Do not move negative
	constants inside ABS_EXPR.

	* gcc.c-torture/execute/pr34130.c: New testcase.

From-SVN: r130258
parent d61ae8dd
2007-11-17 Richard Guenther <rguenther@suse.de>
PR middle-end/34130
* fold-const.c (extract_muldiv_1): Do not move negative
constants inside ABS_EXPR.
2007-11-16 Ian Lance Taylor <iant@google.com>
* collect2.c (dump_file): If a demangled symbol is followed by a
......@@ -6095,6 +6095,9 @@ extract_muldiv_1 (tree t, tree c, enum tree_code code, tree wide_type,
}
break;
}
/* If the constant is negative, we cannot simplify this. */
if (tree_int_cst_sgn (c) == -1)
break;
/* FALLTHROUGH */
case NEGATE_EXPR:
if ((t1 = extract_muldiv (op0, c, code, wide_type, strict_overflow_p))
......
2007-11-17 Richard Guenther <rguenther@suse.de>
PR middle-end/34130
* gcc.c-torture/execute/pr34130.c: New testcase.
2007-11-17 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
PR fortran/34108
extern void abort (void);
int foo (int i)
{
return -2 * __builtin_abs(i - 2);
}
int main()
{
if (foo(1) != -2
|| foo(3) != -2)
abort ();
return 0;
}
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