re PR rtl-optimization/9888 (-mcpu=k6 -Os produces out of range loop instructions)
authorEric Botcazou <ebotcazou@libertysurf.fr>
Wed, 12 Mar 2003 09:21:47 +0000 (10:21 +0100)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Wed, 12 Mar 2003 09:21:47 +0000 (09:21 +0000)
PR optimization/9888
* config/i386/i386.md (jcc_1): Fix range.
(jcc_2): Likewise.
(jump): LIkewise.
(doloop_end_internal): Likewise.

From-SVN: r64230

gcc/ChangeLog
gcc/config/i386/i386.md
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/i386-loop-2.c [new file with mode: 0644]

index 5d8f291dc9d9f0f4e2b64454cab00477a0d32fc8..f0f4738ad339efedcdb6101206cc9cf0f61a103f 100644 (file)
@@ -1,3 +1,11 @@
+2003-03-12  Eric Botcazou  <ebotcazou@libertysurf.fr>
+
+       PR optimization/9888
+       * config/i386/i386.md (jcc_1): Fix range.
+       (jcc_2): Likewise.
+       (jump): LIkewise.
+       (doloop_end_internal): Likewise.
+
 2003-03-12  Danny Smith  <dannysmith@users.sourceforge.net>
  
        * config/i386/winnt.c (DLL_IMPORT_PREFIX): New define.
index 3ac6af1233e2a1a3913e5d381801315c29271198..01fb3db2d811771f5983fe9f3f29dda2fa0289f2 100644 (file)
    (set_attr "modrm" "0")
    (set (attr "length")
           (if_then_else (and (ge (minus (match_dup 0) (pc))
-                                 (const_int -128))
+                                 (const_int -126))
                              (lt (minus (match_dup 0) (pc))
-                                 (const_int 124)))
+                                 (const_int 128)))
             (const_int 2)
             (const_int 6)))])
 
    (set_attr "modrm" "0")
    (set (attr "length")
           (if_then_else (and (ge (minus (match_dup 0) (pc))
-                                 (const_int -128))
+                                 (const_int -126))
                              (lt (minus (match_dup 0) (pc))
-                                 (const_int 124)))
+                                 (const_int 128)))
             (const_int 2)
             (const_int 6)))])
 
   [(set_attr "type" "ibr")
    (set (attr "length")
           (if_then_else (and (ge (minus (match_dup 0) (pc))
-                                 (const_int -128))
+                                 (const_int -126))
                              (lt (minus (match_dup 0) (pc))
-                                 (const_int 124)))
+                                 (const_int 128)))
             (const_int 2)
             (const_int 5)))
    (set_attr "modrm" "0")])
    (set (attr "length")
        (if_then_else (and (eq_attr "alternative" "0")
                           (and (ge (minus (match_dup 0) (pc))
-                                   (const_int -128))
+                                   (const_int -126))
                                (lt (minus (match_dup 0) (pc))
-                                   (const_int 124))))
+                                   (const_int 128))))
                      (const_int 2)
                      (const_int 16)))
    ;; We don't know the type before shorten branches.  Optimistically expect
index 76de10e7e5f8410effbad117d758bd3a60d64822..3e0633c3ef19c771003f60fae0b61aa9c8523404 100644 (file)
@@ -1,3 +1,7 @@
+2003-03-12  Eric Botcazou  <ebotcazou@libertysurf.fr>
+
+       * gcc.dg/i386-loop-2.c: New test.
+
 2003-03-11  Mark Mitchell  <mark@codesourcery.com>
 
        PR c++/9474
diff --git a/gcc/testsuite/gcc.dg/i386-loop-2.c b/gcc/testsuite/gcc.dg/i386-loop-2.c
new file mode 100644 (file)
index 0000000..3a3e69e
--- /dev/null
@@ -0,0 +1,80 @@
+/* PR optimization/9888 */
+/* Originator: Jim Bray <jb@as220.org> */
+/* { dg-do run { target i?86-*-* } } */
+/* { dg-options "-mtune=k6 -Os" } */
+
+enum reload_type
+{
+  RELOAD_FOR_INPUT, RELOAD_FOR_OUTPUT, RELOAD_FOR_INSN,
+  RELOAD_FOR_INPUT_ADDRESS, RELOAD_FOR_INPADDR_ADDRESS,
+  RELOAD_FOR_OUTPUT_ADDRESS, RELOAD_FOR_OUTADDR_ADDRESS,
+  RELOAD_FOR_OPERAND_ADDRESS, RELOAD_FOR_OPADDR_ADDR,
+  RELOAD_OTHER, RELOAD_FOR_OTHER_ADDRESS
+};
+
+#define FOO_SIZE 3
+
+/* My results, varying with FOO_SIZE:
+   30: asm error "value of ..fff77 too large:
+   3 to 29: ....ff7d...
+   1 to 2: no error.  */
+
+struct reload
+{
+   int foo[FOO_SIZE];
+   int opnum; 
+   enum reload_type when_needed;
+   unsigned int optional:1; 
+   unsigned int secondary_p:1;
+};
+
+#define N_RELOADS  2
+
+struct reload rld[N_RELOADS];
+int n_reloads = N_RELOADS;
+
+int main(void)
+{
+  int i;
+
+  enum reload_type operand_type[1];
+
+  enum reload_type address_type[1];
+
+  int operand_reloadnum[1];
+  int goal_alternative_matches[1];
+
+  for (i = 0; i < n_reloads; i++)
+    {
+      if (rld[i].secondary_p
+          && rld[i].when_needed == operand_type[rld[i].opnum])
+        rld[i].when_needed = address_type[rld[i].opnum];
+
+      if ((rld[i].when_needed == RELOAD_FOR_INPUT_ADDRESS
+           || rld[i].when_needed == RELOAD_FOR_OUTPUT_ADDRESS
+           || rld[i].when_needed == RELOAD_FOR_INPADDR_ADDRESS
+           || rld[i].when_needed == RELOAD_FOR_OUTADDR_ADDRESS)
+          && (operand_reloadnum[rld[i].opnum] < 0
+              || rld[operand_reloadnum[rld[i].opnum]].optional))
+        {
+
+          if (rld[i].when_needed == RELOAD_FOR_INPADDR_ADDRESS
+              || rld[i].when_needed == RELOAD_FOR_OUTADDR_ADDRESS)
+            rld[i].when_needed = RELOAD_FOR_OPADDR_ADDR;
+          else
+            rld[i].when_needed = RELOAD_FOR_OPERAND_ADDRESS;
+        }
+
+      if ((rld[i].when_needed == RELOAD_FOR_INPUT_ADDRESS
+           || rld[i].when_needed == RELOAD_FOR_INPADDR_ADDRESS)
+          && operand_reloadnum[rld[i].opnum] >= 0
+          && (rld[operand_reloadnum[rld[i].opnum]].when_needed
+              == RELOAD_OTHER))
+        rld[i].when_needed = RELOAD_FOR_OTHER_ADDRESS;
+
+      if (goal_alternative_matches[rld[i].opnum] >= 0)
+        rld[i].opnum = goal_alternative_matches[rld[i].opnum];
+    }
+
+  return 0;
+}