This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix movstr expansion (PR target/43636)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Andreas Krebbel <krebbel at linux dot vnet dot ibm dot com>
- Date: Fri, 28 May 2010 15:27:21 +0200
- Subject: [PATCH] Fix movstr expansion (PR target/43636)
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
Since SSA expand has been added, expand_movstr is sometimes called with
target that is neither NULL, nor const0_rtx, nor a Pmode REG.
The expander doesn't check the predicate and blindly uses that target,
which leads to non-recognized insn.
Fixed thusly. There are just 4 targets that have movstr expanders,
apparently m32c forgot to supply a predicate, other targets do (for m32c
I chose the one that is actually required for the insn that uses that
argument).
Ok for trunk/4.5?
2010-05-28 Jakub Jelinek <jakub@redhat.com>
PR target/43636
* builtins.c (expand_movstr): Use a temporary pseudo instead
of target even when target is not NULL and not const0_rtx, but
fails movstr predicate.
* config/m32c/blkmov.md (movstr): Add predicate to first operand.
* gcc.c-torture/compile/pr43636.c: New test.
--- gcc/builtins.c.jj 2010-05-25 11:27:45.000000000 +0200
+++ gcc/builtins.c 2010-05-26 13:58:36.000000000 +0200
@@ -3560,6 +3560,7 @@ expand_movstr (tree dest, tree src, rtx
dest_mem = get_memory_rtx (dest, NULL);
src_mem = get_memory_rtx (src, NULL);
+ data = insn_data + CODE_FOR_movstr;
if (!endp)
{
target = force_reg (Pmode, XEXP (dest_mem, 0));
@@ -3568,18 +3569,18 @@ expand_movstr (tree dest, tree src, rtx
}
else
{
- if (target == 0 || target == const0_rtx)
+ if (target == 0
+ || target == const0_rtx
+ || ! (*data->operand[0].predicate) (target, Pmode))
{
end = gen_reg_rtx (Pmode);
- if (target == 0)
+ if (target != const0_rtx)
target = end;
}
else
end = target;
}
- data = insn_data + CODE_FOR_movstr;
-
if (data->operand[0].mode != VOIDmode)
end = gen_lowpart (data->operand[0].mode, end);
--- gcc/config/m32c/blkmov.md.jj 2008-09-05 12:56:18.000000000 +0200
+++ gcc/config/m32c/blkmov.md 2010-05-26 14:43:58.000000000 +0200
@@ -1,5 +1,5 @@
;; Machine Descriptions for R8C/M16C/M32C
-;; Copyright (C) 2006, 2007
+;; Copyright (C) 2006, 2007, 2010
;; Free Software Foundation, Inc.
;; Contributed by Red Hat.
;;
@@ -214,7 +214,7 @@ (define_insn "cmpstrhi_op"
;; 2 = source (mem:BLK ...)
(define_expand "movstr"
- [(match_operand 0 "" "")
+ [(match_operand 0 "m32c_nonimmediate_operand" "")
(match_operand 1 "ap_operand" "")
(match_operand 2 "ap_operand" "")
]
--- gcc/testsuite/gcc.c-torture/compile/pr43636.c.jj 2010-05-26 14:14:55.000000000 +0200
+++ gcc/testsuite/gcc.c-torture/compile/pr43636.c 2010-05-26 14:14:51.000000000 +0200
@@ -0,0 +1,10 @@
+/* PR target/43636 */
+
+extern char a[], *b[];
+
+char *
+foo (char *x, int y)
+{
+ x = __builtin_stpcpy (x, b[a[y]]);
+ return x;
+}
Jakub