re PR rtl-optimization/23047 (Combine ignores flag_wrapv)
authorJames A. Morrison <phython@gcc.gnu.org>
Thu, 28 Jul 2005 04:40:05 +0000 (04:40 +0000)
committerJames A. Morrison <phython@gcc.gnu.org>
Thu, 28 Jul 2005 04:40:05 +0000 (04:40 +0000)
2005-07-27  James A. Morrison  <phython@gcc.gnu.org>

        PR rtl-optimization/23047
        * simplify-rtx.c (simplify_const_relational_operation): Respect
        flag_wrapv for comparisons with ABS.

From-SVN: r102459

gcc/ChangeLog
gcc/simplify-rtx.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/pr23047.c [new file with mode: 0644]
gcc/testsuite/gcc.c-torture/execute/pr23047.x [new file with mode: 0644]

index b0d7bff728851a521579a5f3b26734f6fc3f4a40..d888c82e23fc18344b013ede8a5434f11d9a7e3f 100644 (file)
@@ -1,3 +1,9 @@
+2005-07-25  James A. Morrison  <phython@gcc.gnu.org>
+
+       PR rtl-optimization/23047
+       * simplify-rtx.c (simplify_const_relational_operation): Respect
+       flag_wrapv for comparisons with ABS.
+
 2005-07-27  James A. Morrison  <phython@gcc.gnu.org>
 
        PR tree-optimization/22493
index ae1fea7e2e47246f652401dcd7ff04977e4ae0ab..e3e29991af8f9b11d396da6139a7593f1ce1b721 100644 (file)
@@ -3236,7 +3236,9 @@ simplify_const_relational_operation (enum rtx_code code,
 
        case LT:
          /* Optimize abs(x) < 0.0.  */
-         if (trueop1 == CONST0_RTX (mode) && !HONOR_SNANS (mode))
+         if (trueop1 == CONST0_RTX (mode)
+             && !HONOR_SNANS (mode)
+             && !(flag_wrapv && INTEGRAL_MODE_P (mode)))
            {
              tem = GET_CODE (trueop0) == FLOAT_EXTEND ? XEXP (trueop0, 0)
                                                       : trueop0;
@@ -3247,7 +3249,9 @@ simplify_const_relational_operation (enum rtx_code code,
 
        case GE:
          /* Optimize abs(x) >= 0.0.  */
-         if (trueop1 == CONST0_RTX (mode) && !HONOR_NANS (mode))
+         if (trueop1 == CONST0_RTX (mode)
+             && !HONOR_NANS (mode)
+             && !(flag_wrapv && INTEGRAL_MODE_P (mode)))
            {
              tem = GET_CODE (trueop0) == FLOAT_EXTEND ? XEXP (trueop0, 0)
                                                       : trueop0;
index d2861aade39c54149156bd16967b27c71370bb42..ddf272d6885817354a0a0a5ff60e4d23a5d8b3df 100644 (file)
@@ -1,6 +1,12 @@
 2005-07-27  James A. Morrison  <phython@gcc.gnu.org>
 
-       PR rtl-optimization/22493
+       PR rtl-optimization/23047
+       * gcc.c-torture/execute/pr23047.c: New test.
+       * gcc.c-torture/execute/pr23047.x: New.
+
+2005-07-27  James A. Morrison  <phython@gcc.gnu.org>
+
+       PR tree-optimization/22493
        * gcc.c-torture/execute/pr22493-1.c: New test.
        * gcc.c-torture/execute/pr22493-1.x: New.
        * gcc.c-torture/execute/vrp-1.c: New test.
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr23047.c b/gcc/testsuite/gcc.c-torture/execute/pr23047.c
new file mode 100644 (file)
index 0000000..7557fc2
--- /dev/null
@@ -0,0 +1,16 @@
+#include <limits.h>
+extern void abort ();
+extern void exit (int);
+void f(int i)
+{
+  i = i > 0 ? i : -i;
+  if (i<0)
+    return;
+  abort ();
+}
+
+int main(int argc, char *argv[])
+{
+  f(INT_MIN);
+  exit (0);
+}
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr23047.x b/gcc/testsuite/gcc.c-torture/execute/pr23047.x
new file mode 100644 (file)
index 0000000..36a5839
--- /dev/null
@@ -0,0 +1,2 @@
+set additional_flags "-fwrapv"
+return 0