OSDN Git Service

2008-09-02 Richard Guenther <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 2 Sep 2008 13:48:11 +0000 (13:48 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 2 Sep 2008 13:48:11 +0000 (13:48 +0000)
PR tree-optimization/37327
* tree-vrp.c (register_new_assert_for): Make sure to not have
TREE_OVERFLOW set on the bound.

* gcc.c-torture/compile/pr37327.c: New testcase.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@139890 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr37327.c [new file with mode: 0644]
gcc/tree-vrp.c

index 37a3959..0766ec3 100644 (file)
@@ -1,3 +1,9 @@
+2008-09-02  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/37327
+       * tree-vrp.c (register_new_assert_for): Make sure to not have
+       TREE_OVERFLOW set on the bound.
+
 2008-09-02  Alexander Monakov  <amonakov@ispras.ru>
 
        Fixed typo in date of the 2008-09-01 MOVE_RATIO commit.
index 304e76c..fa07075 100644 (file)
@@ -1,3 +1,8 @@
+2008-09-02  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/37327
+       * gcc.c-torture/compile/pr37327.c: New testcase.
+
 2008-09-02  Victor Kaplansky  <victork@il.ibm.com>
 
        * gcc.dg/fastmath-2.c: New.
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr37327.c b/gcc/testsuite/gcc.c-torture/compile/pr37327.c
new file mode 100644 (file)
index 0000000..7041d83
--- /dev/null
@@ -0,0 +1,48 @@
+typedef signed char int8_t;
+typedef short int int16_t;
+typedef int int32_t;
+typedef unsigned short int uint16_t;
+typedef unsigned int uint32_t;
+static inline uint32_t
+safe_add_int8_t_s_s (int8_t si1, int16_t si2)
+{
+  if ((si1) && (si2) && (si1 > (1 - si2)) || (si1) && (si2 < 0)
+      && (si1 < (-128 - si2)))
+    return si1;
+  return si1 + si2;
+}
+
+uint32_t g_2;
+uint32_t g_113;
+uint32_t g_145;
+int32_t
+func_17 (int32_t p_18, uint32_t p_19, uint32_t p_21)
+{
+  uint32_t l_23 = -1L;
+  return l_23;
+}
+
+uint32_t
+func_26 (uint16_t p_27)
+{
+  uint32_t l_424;
+  if (func_93 (func_59 (safe_add_int8_t_s_s (p_27, 1))),
+      func_124 (l_424, -7L, 1, g_145, 1, (safe_add_int8_t_s_s (1, 1)), 1), 1,
+      1, 1)
+    func_117 (1, 1,
+              (safe_add_uint64_t_u_u
+               (1, (safe_add_int8_t_s_s (1, 0xCDF4BE7A1B7E4629LL)))), 1);
+  uint32_t l_210;
+  if (func_17
+      ((safe_add_int8_t_s_s (g_2, (0x6C79A83AL | func_17 (1, 1, 1)))),
+       0x4C9FL, 1))
+    {
+      uint32_t l_212;
+      if (safe_mul_int32_t_s_s
+          ((1, 1, l_212, (1, (safe_add_int8_t_s_s (l_210, 1)), 1, 1)), 1))
+        if (func_59 (1, (safe_add_int8_t_s_s (g_113, 1))))
+          {
+          }
+    }
+}
+
index 348382e..8db35ca 100644 (file)
@@ -3785,6 +3785,14 @@ register_new_assert_for (tree name, tree expr,
                && gimple_code (gsi_stmt (si)) != GIMPLE_SWITCH);
 #endif
 
+  /* Never build an assert comparing against an integer constant with
+     TREE_OVERFLOW set.  This confuses our undefined overflow warning
+     machinery.  */
+  if (TREE_CODE (val) == INTEGER_CST
+      && TREE_OVERFLOW (val))
+    val = build_int_cst_wide (TREE_TYPE (val),
+                             TREE_INT_CST_LOW (val), TREE_INT_CST_HIGH (val));
+
   /* The new assertion A will be inserted at BB or E.  We need to
      determine if the new location is dominated by a previously
      registered location for A.  If we are doing an edge insertion,