Commit bbc210ab by Richard Guenther Committed by Richard Biener

fold-const.c (fold_unary_loc): Do not strip sign-changes for NEGATE_EXPR.

2011-07-07  Richard Guenther  <rguenther@suse.de>

	* fold-const.c (fold_unary_loc): Do not strip sign-changes
	for NEGATE_EXPR.

	* gcc.dg/ftrapv-3.c: New testcase.

From-SVN: r175976
parent 29c5134a
2011-07-07 Richard Guenther <rguenther@suse.de>
* fold-const.c (fold_unary_loc): Do not strip sign-changes
for NEGATE_EXPR.
2011-07-07 Richard Guenther <rguenther@suse.de>
* tree-vrp.c (simplify_conversion_using_ranges): New function.
(simplify_stmt_using_ranges): Call it.
......
......@@ -7561,7 +7561,7 @@ fold_unary_loc (location_t loc, enum tree_code code, tree type, tree op0)
if (arg0)
{
if (CONVERT_EXPR_CODE_P (code)
|| code == FLOAT_EXPR || code == ABS_EXPR)
|| code == FLOAT_EXPR || code == ABS_EXPR || code == NEGATE_EXPR)
{
/* Don't use STRIP_NOPS, because signedness of argument type
matters. */
......
2011-07-07 Richard Guenther <rguenther@suse.de>
* gcc.dg/ftrapv-3.c: New testcase.
2011-07-07 Richard Guenther <rguenther@suse.de>
* gcc.dg/tree-ssa/vrp58.c: New testcase.
* gcc.dg/tree-ssa/scev-cast.c: Adjust.
......
/* { dg-do run } */
/* { dg-options "-ftrapv" } */
extern void abort (void);
unsigned long
foo (long i, long j)
{
/* We may not fold this to (unsigned long)(i * j). */
return -(unsigned long)(i * -j);
}
int main()
{
if (foo (-__LONG_MAX__ - 1, -1) != -(unsigned long)(-__LONG_MAX__ - 1))
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