]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
rs6000: Fix condition of define_expand vec_shr_<mode> [PR100645]
authorKewen Lin <linkw@linux.ibm.com>
Mon, 26 Sep 2022 03:01:50 +0000 (22:01 -0500)
committerKewen Lin <linkw@linux.ibm.com>
Mon, 26 Sep 2022 03:23:44 +0000 (22:23 -0500)
PR100645 exposes one latent bug in define_expand vec_shr_<mode>
that the current condition TARGET_ALTIVEC is too loose.  The
mode iterator VEC_L contains a few modes, they are not always
supported as vector mode, VECTOR_UNIT_ALTIVEC_OR_VSX_P should
be used like some other VEC_L usages.

PR target/100645

gcc/ChangeLog:

* config/rs6000/vector.md (vec_shr_<mode>): Replace condition
TARGET_ALTIVEC with VECTOR_UNIT_ALTIVEC_OR_VSX_P.

gcc/testsuite/ChangeLog:

* gcc.target/powerpc/pr100645.c: New test.

gcc/config/rs6000/vector.md
gcc/testsuite/gcc.target/powerpc/pr100645.c [new file with mode: 0644]

index a0d33d2f604432632cf029b286aea0235c9f4a25..0171705803c2b79bc7a1f449117ccbb48a7a9558 100644 (file)
   [(match_operand:VEC_L 0 "vlogical_operand")
    (match_operand:VEC_L 1 "vlogical_operand")
    (match_operand:QI 2 "reg_or_short_operand")]
-  "TARGET_ALTIVEC"
+  "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
 {
   rtx bitshift = operands[2];
   rtx shift;
diff --git a/gcc/testsuite/gcc.target/powerpc/pr100645.c b/gcc/testsuite/gcc.target/powerpc/pr100645.c
new file mode 100644 (file)
index 0000000..c4e92cc
--- /dev/null
@@ -0,0 +1,13 @@
+/* { dg-require-effective-target powerpc_altivec_ok } */
+/* { dg-options "-mdejagnu-cpu=power6 -maltivec" } */
+
+/* This used to ICE.  */
+
+typedef long long v2di __attribute__ ((vector_size (16)));
+
+v2di
+foo_v2di_l (v2di x)
+{
+  return __builtin_shuffle ((v2di){0, 0}, x, (v2di){3, 0});
+}
+