OSDN Git Service

PR debug/41679
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 17 Dec 2009 19:30:58 +0000 (19:30 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 17 Dec 2009 19:30:58 +0000 (19:30 +0000)
* var-tracking.c (add_stores): Avoid value mode mismatch for
promoted declarations.

* gcc.target/arm/pr41679.c: New.

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

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/arm/pr41679.c [new file with mode: 0644]
gcc/var-tracking.c

index 90dc2c8..45a9715 100644 (file)
@@ -1,3 +1,9 @@
+2009-12-17  Alexandre Oliva  <aoliva@redhat.com>
+
+       PR debug/41679
+       * var-tracking.c (add_stores): Avoid value mode mismatch for
+       promoted declarations.
+
 2009-12-17  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/42386
index a8ee952..345d664 100644 (file)
@@ -1,3 +1,8 @@
+2009-12-17  Alexandre Oliva  <aoliva@redhat.com>
+
+       PR debug/41679
+       * gcc.target/arm/pr41679.c: New.
+
 2009-12-17  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/42386
diff --git a/gcc/testsuite/gcc.target/arm/pr41679.c b/gcc/testsuite/gcc.target/arm/pr41679.c
new file mode 100644 (file)
index 0000000..8b24898
--- /dev/null
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-options "-march=armv5te -g -O2" } */
+
+extern int a;
+extern char b;
+extern int foo (void);
+
+void
+test (void)
+{
+  int c;
+  b = foo () ? '~' : '\0';
+  while ((c = foo ()))
+    if (c == '7')
+      a = 0;
+}
index 8267df8..11e3aa2 100644 (file)
@@ -4815,13 +4815,15 @@ add_stores (rtx loc, const_rtx expr, void *cuip)
            }
          else
            {
+             rtx xexpr = CONST_CAST_RTX (expr);
+
              if (SET_SRC (expr) != src)
-               expr = gen_rtx_SET (VOIDmode, loc, src);
+               xexpr = gen_rtx_SET (VOIDmode, loc, src);
              if (same_variable_part_p (src, REG_EXPR (loc), REG_OFFSET (loc)))
                mo->type = MO_COPY;
              else
                mo->type = MO_SET;
-             mo->u.loc = CONST_CAST_RTX (expr);
+             mo->u.loc = xexpr;
            }
        }
       mo->insn = cui->insn;
@@ -4872,15 +4874,17 @@ add_stores (rtx loc, const_rtx expr, void *cuip)
            }
          else
            {
+             rtx xexpr = CONST_CAST_RTX (expr);
+
              if (SET_SRC (expr) != src)
-               expr = gen_rtx_SET (VOIDmode, loc, src);
-             if (same_variable_part_p (SET_SRC (expr),
+               xexpr = gen_rtx_SET (VOIDmode, loc, src);
+             if (same_variable_part_p (SET_SRC (xexpr),
                                        MEM_EXPR (loc),
                                        INT_MEM_OFFSET (loc)))
                mo->type = MO_COPY;
              else
                mo->type = MO_SET;
-             mo->u.loc = CONST_CAST_RTX (expr);
+             mo->u.loc = xexpr;
            }
        }
       mo->insn = cui->insn;
@@ -4901,7 +4905,14 @@ add_stores (rtx loc, const_rtx expr, void *cuip)
 
   if (resolve && GET_CODE (mo->u.loc) == SET)
     {
-      nloc = replace_expr_with_values (SET_SRC (mo->u.loc));
+      nloc = replace_expr_with_values (SET_SRC (expr));
+
+      /* Avoid the mode mismatch between oexpr and expr.  */
+      if (!nloc && mode != mode2)
+       {
+         nloc = SET_SRC (expr);
+         gcc_assert (oloc == SET_DEST (expr));
+       }
 
       if (nloc)
        oloc = gen_rtx_SET (GET_MODE (mo->u.loc), oloc, nloc);
@@ -4940,7 +4951,8 @@ add_stores (rtx loc, const_rtx expr, void *cuip)
 
      (concat (concat val dstv) (set dst src)): dst now holds val,
      copied from src.  dstv is a value-based representation of dst, if
-     it differs from dst.  If resolution is needed, src is a REG.
+     it differs from dst.  If resolution is needed, src is a REG, and
+     its mode is the same as that of val.
 
      (concat (concat val (set dstv srcv)) (set dst src)): src
      copied to dst, holding val.  dstv and srcv are value-based