This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[VTA, PR41679] mode mismatch in var-tracking
- From: Alexandre Oliva <aoliva at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: jakub at redhat dot com
- Date: Thu, 19 Nov 2009 05:22:40 -0200
- Subject: [VTA, PR41679] mode mismatch in var-tracking
This patch avoids a mode mismatch between the VALUE chosen to represent
a location and the unpromoted expression it's copied from, arranging for
the promoted assignment to be used for value resolution.
This patch does not address the issue of cond_exec stores, that has not
been taken into account in var-tracking, although support for it is
right there in cselib.
I've just started testing this patch on x86_64-linux-gnu and
ia64-linux-gnu.
for gcc/ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
PR debug/41679
* var-tracking.c (add_stores): Avoid value mode mismatch for
promoted declarations.
for gcc/testsuite/ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
PR debug/41679
* gcc.target/arm/pr41679.c: New.
Index: gcc/var-tracking.c
===================================================================
--- gcc/var-tracking.c.orig 2009-11-19 05:15:38.000000000 -0200
+++ gcc/var-tracking.c 2009-11-19 05:15:53.000000000 -0200
@@ -4815,13 +4815,15 @@ add_stores (rtx loc, const_rtx expr, voi
}
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, voi
}
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, voi
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, voi
(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
Index: gcc/testsuite/gcc.target/arm/pr41679.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ gcc/testsuite/gcc.target/arm/pr41679.c 2009-11-19 05:15:53.000000000 -0200
@@ -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;
+}
--
Alexandre Oliva, freedom fighter http://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/ FSF Latin America board member
Free Software Evangelist Red Hat Brazil Compiler Engineer