This patch is to fix one wrong assertion which is too aggressive.
Vectorizer can do vec_construct costing for the vector type which
only has one unit. For the failed case, the passed in vector type
is "vector(1) int", though it doesn't end up with any construction
eventually, we have to handle this kind of possibility.
gcc/ChangeLog:
PR target/103702
* config/rs6000/rs6000.cc
(rs6000_cost_data::update_target_cost_per_stmt): Fix one wrong
assertion with early return.
gcc/testsuite/ChangeLog:
PR target/103702
* gcc.target/powerpc/pr103702.c: New test.
{
tree vectype = STMT_VINFO_VECTYPE (stmt_info);
unsigned int nunits = vect_nunits_for_cost (vectype);
- /* We don't expect strided/elementwise loads for just 1 nunit. */
- gcc_assert (nunits > 1);
+ /* As PR103702 shows, it's possible that vectorizer wants to do
+ costings for only one unit here, it's no need to do any
+ penalization for it, so simply early return here. */
+ if (nunits == 1)
+ return;
/* i386 port adopts nunits * stmt_cost as the penalized cost
for this kind of penalization, we used to follow it but
found it could result in an unreliable body cost especially
--- /dev/null
+/* We don't have one powerpc.*_ok for Power6, use altivec_ok conservatively. */
+/* { dg-require-effective-target powerpc_altivec_ok } */
+/* { dg-options "-mdejagnu-cpu=power6 -O2 -ftree-loop-vectorize -fno-tree-scev-cprop" } */
+
+/* Verify there is no ICE. */
+
+unsigned short a, e;
+int *b, *d;
+int c;
+extern int fn2 ();
+void
+fn1 ()
+{
+ void *f;
+ for (;;)
+ {
+ fn2 ();
+ b = f;
+ e = 0;
+ for (; e < a; ++e)
+ b[e] = d[e * c];
+ }
+}
+