* fold-const.c (fold_unary_loc): Do not strip sign-changes
for NEGATE_EXPR.
* gcc.dg/ftrapv-3.c: New testcase.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@175976
138bc75d-0d04-0410-961f-
82ee72b054a4
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.
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.
--- /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;
+}