re PR middle-end/7153 (bad operands for 'movsbl' error)
authorEric Botcazou <ebotcazou@multimania.com>
Mon, 15 Jul 2002 23:59:02 +0000 (23:59 +0000)
committerRichard Henderson <rth@gcc.gnu.org>
Mon, 15 Jul 2002 23:59:02 +0000 (16:59 -0700)
        PR optimization/7153
        * regmove.c (optimize_reg_copy_3): Don't optimize if the register
        dies in more than one insn.

From-SVN: r55468

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

index f1e8b3ac929c862d8f7252f499f129b34089a347..5c659805be5fc367edba1c74057af8f476148938 100644 (file)
@@ -1,3 +1,9 @@
+2002-07-15  Eric Botcazou  <ebotcazou@multimania.com>
+
+       PR optimization/7153
+       * regmove.c (optimize_reg_copy_3): Don't optimize if the register
+       dies in more than one insn.
+
 2002-07-15  Jason Thorpe  <thorpej@wasabisystems.com>
 
        * config/sparc/netbsd-elf.h (TRANSFER_FROM_TRAMPOLINE): Remove.
index 55a31dc612eafaff62f7a01b8262511f8980e6c3..1a1fffe097525299d16d5bd69706f35fd6219c00 100644 (file)
@@ -664,6 +664,7 @@ optimize_reg_copy_3 (insn, dest, src)
   if (src_no < FIRST_PSEUDO_REGISTER
       || dst_no < FIRST_PSEUDO_REGISTER
       || ! find_reg_note (insn, REG_DEAD, src_reg)
+      || REG_N_DEATHS (src_no) != 1
       || REG_N_SETS (src_no) != 1)
     return;
   for (p = PREV_INSN (insn); p && ! reg_set_p (src_reg, p); p = PREV_INSN (p))
diff --git a/gcc/testsuite/gcc.c-torture/compile/20020715-1.c b/gcc/testsuite/gcc.c-torture/compile/20020715-1.c
new file mode 100644 (file)
index 0000000..5294133
--- /dev/null
@@ -0,0 +1,22 @@
+/* PR optimization/7153 */
+/* Verify that GCC doesn't promote a register when its
+   lifetime is not limited to one basic block. */
+
+void f(char);
+void g(void);
+
+void scale(void)
+{
+  int width;
+  char bytes;
+  char *src;
+
+  if (width)
+  {
+    bytes = *src;
+    g();
+    width *= bytes;
+  }
+
+  f(bytes);
+}