OSDN Git Service

* expr.c (expand_expr) [INTEGER_CST]: Force overflows into registers.
authorrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 10 Apr 2002 02:22:20 +0000 (02:22 +0000)
committerrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 10 Apr 2002 02:22:20 +0000 (02:22 +0000)
* gcc.c-torture/compile/20020409-1.c: New.

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

gcc/ChangeLog
gcc/expr.c
gcc/testsuite/gcc.c-torture/compile/20020409-1.c [new file with mode: 0644]

index 8aa8936..e1b2ac9 100644 (file)
@@ -1,5 +1,10 @@
 2002-04-09  Richard Henderson  <rth@redhat.com>
 
+       PR c/5078
+       * expr.c (expand_expr) [INTEGER_CST]: Force overflows into registers.
+
+2002-04-09  Richard Henderson  <rth@redhat.com>
+
        * basic-block.h (flow_delete_block_noexpunge): Declare.
        (expunge_block_nocompact): Declare.
        * cfg.c (expunge_block_nocompact): Split out from ...
index 11f1a53..4871c4b 100644 (file)
@@ -6318,9 +6318,19 @@ expand_expr (exp, target, tmode, modifier)
       return DECL_RTL (exp);
 
     case INTEGER_CST:
-      return immed_double_const (TREE_INT_CST_LOW (exp),
+      temp = immed_double_const (TREE_INT_CST_LOW (exp),
                                 TREE_INT_CST_HIGH (exp), mode);
 
+      /* ??? If overflow is set, fold will have done an incomplete job,
+        which can result in (plus xx (const_int 0)), which can get
+        simplified by validate_replace_rtx during virtual register
+        instantiation, which can result in unrecognizable insns.
+        Avoid this by forcing all overflows into registers.  */
+      if (TREE_CONSTANT_OVERFLOW (exp))
+       temp = force_reg (mode, temp);
+
+      return temp;
+
     case CONST_DECL:
       return expand_expr (DECL_INITIAL (exp), target, VOIDmode, 0);
 
diff --git a/gcc/testsuite/gcc.c-torture/compile/20020409-1.c b/gcc/testsuite/gcc.c-torture/compile/20020409-1.c
new file mode 100644 (file)
index 0000000..1bdc08f
--- /dev/null
@@ -0,0 +1,9 @@
+/* PR c/5078 */
+
+#include <limits.h>
+
+int f(int i)
+{
+  i -= 2 * (INT_MAX + 1);
+  return i;
+}