Avoid two_valued_val_range_p for pointers.
authorMarc Glisse <marc.glisse@inria.fr>
Wed, 22 Nov 2017 16:44:46 +0000 (17:44 +0100)
committerMarc Glisse <glisse@gcc.gnu.org>
Wed, 22 Nov 2017 16:44:46 +0000 (16:44 +0000)
2017-11-22  Marc Glisse  <marc.glisse@inria.fr>

PR tree-optimization/83104
gcc/
* vr-values.c (simplify_stmt_using_ranges): Check integral argument,
not result.

gcc/testsuite/
* gcc.c-torture/compile/pr83104.c: New file.

From-SVN: r255068

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr83104.c [new file with mode: 0644]
gcc/vr-values.c

index 4b248cd81b7b3bd9b7d3bd5e3ad5bc4d81fa67b9..f80012097ca888e08d500e5946904aa2f75ba4dc 100644 (file)
@@ -1,3 +1,9 @@
+2017-11-22  Marc Glisse  <marc.glisse@inria.fr>
+
+       PR tree-optimization/83104
+       * vr-values.c (simplify_stmt_using_ranges): Check integral argument,
+       not result.
+
 2017-11-22  Marek Polacek  <polacek@redhat.com>
            H.J. Lu  <hongjiu.lu@intel.com>
            Jason Merrill  <jason@redhat.com>
index 7dbdc24292c8cb7915e893b1cfc213098efb013e..737424b1fd9ab33dba821f53a068ef38f033c333 100644 (file)
@@ -1,3 +1,8 @@
+2017-11-22  Marc Glisse  <marc.glisse@inria.fr>
+
+       PR tree-optimization/83104
+       * gcc.c-torture/compile/pr83104.c: New file.
+
 2017-11-22  Christophe Lyon  <christophe.lyon@linaro.org>
 
        * gcc.target/arm/pr56184.C: Add -Wno-return-type to dg-options.
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr83104.c b/gcc/testsuite/gcc.c-torture/compile/pr83104.c
new file mode 100644 (file)
index 0000000..40dc3d4
--- /dev/null
@@ -0,0 +1,5 @@
+int *a;
+int foo() {
+  if (a && a - (int *)0 > 0)
+    return 0;
+}
index 7b9c5ad6c4b24858bf7f161a4ba5018c4a3520f6..0150f59d53dc9f685bb4dba71f3ac4751e06bf02 100644 (file)
@@ -4091,7 +4091,7 @@ vr_values::simplify_stmt_using_ranges (gimple_stmt_iterator *gsi)
         LHS = VAR == VAL1 ? (VAL1 BINOP CST) : (VAL2 BINOP CST) */
 
       if (TREE_CODE_CLASS (rhs_code) == tcc_binary
-         && INTEGRAL_TYPE_P (TREE_TYPE (lhs))
+         && INTEGRAL_TYPE_P (TREE_TYPE (rhs1))
          && ((TREE_CODE (rhs1) == INTEGER_CST
               && TREE_CODE (rhs2) == SSA_NAME)
              || (TREE_CODE (rhs2) == INTEGER_CST