Hi all,
When investigating this PR, I was initially confused as to why we were
matching a vec_duplicate on the RHS of *mve_mov<mode> (since
general_operand does not match vec_duplicates). It turns out that there
are two patterns in mve.md named *mve_mov<mode> and the second one
matches vec_duplicates. I've renamed this pattern to *mve_vdup<mode> to
avoid further confusion.
The issue in the PR is that the predicate for the operand of the
vec_duplicate in *mve_vdup<mode> is not strict enough: it allows (e.g.)
labels when we really only want to allow registers and const_ints.
Testing:
* Bootstrapped and regtested on arm-linux-gnueabihf, no regressions.
* Regtested an arm-eabi cross configured with --with-float=hard
--with-arch=armv8.1-m.main+mve: no regressions. Also fixes a couple of
existing torture test failures at -O3 for gcc.dg/torture/pr47958-1.c.
OK for trunk and eventual backport to the GCC 10 branch?
Thanks,
Alex
gcc/ChangeLog:
PR target/99647
* config/arm/mve.md (*mve_mov<mode>): Rename to...
(*mve_vdup<mode>): ... this. Also tighten up predicate for
vec_duplicate operand.
gcc/testsuite/ChangeLog:
PR target/99647
* gcc.c-torture/compile/pr99647.c: New test.
diff --git a/gcc/config/arm/mve.md b/gcc/config/arm/mve.md
index 135186371e7..d79b3156077 100644
--- a/gcc/config/arm/mve.md
+++ b/gcc/config/arm/mve.md
@@ -104,10 +104,10 @@ (define_insn "*mve_mov<mode>"
(set_attr "thumb2_pool_range" "*,*,*,*,1018,*,*,*,*")
(set_attr "neg_pool_range" "*,*,*,*,996,*,*,*,*")])
-(define_insn "*mve_mov<mode>"
+(define_insn "*mve_vdup<mode>"
[(set (match_operand:MVE_types 0 "s_register_operand" "=w,w")
(vec_duplicate:MVE_types
- (match_operand:SI 1 "nonmemory_operand" "r,i")))]
+ (match_operand:SI 1 "reg_or_int_operand" "r,i")))]
"TARGET_HAVE_MVE || TARGET_HAVE_MVE_FLOAT"
{
if (which_alternative == 0)
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr99647.c
b/gcc/testsuite/gcc.c-torture/compile/pr99647.c
new file mode 100644
index 00000000000..701155dd856
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/pr99647.c
@@ -0,0 +1,5 @@
+/* { dg-do assemble } */
+typedef int __attribute((vector_size(16))) V;
+V f(void) {
+ return (V){ (int)f, (int)f, (int)f, (int)f };
+}