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
+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.
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.
--- /dev/null
+/* { 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;
+}