synth-mult introduces multiple uses of a reduction variable
in some cases which will ultimatively fail vectorization (or ICE
with a pending change). So avoid applying the pattern in such case.
* tree-vect-patterns.cc (vect_synth_mult_by_constant): Avoid
in cases that introduce multiple uses of reduction operands.
Co-authored-by: Jakub Jelinek <jakub@redhat.com>
if (!possible)
return NULL;
+ if (vect_is_reduction (stmt_vinfo))
+ {
+ int op_uses = alg.op[0] != alg_zero;
+ for (int i = 1; i < alg.ops; i++)
+ switch (alg.op[i])
+ {
+ case alg_add_t_m2:
+ case alg_sub_t_m2:
+ if (synth_shift_p && alg.log[i])
+ return NULL;
+ else
+ op_uses++;
+ break;
+ case alg_add_t2_m:
+ case alg_sub_t2_m:
+ op_uses++;
+ break;
+ default:
+ break;
+ }
+ if (variant == add_variant)
+ op_uses++;
+ /* When we'll synthesize more than a single use of the reduction
+ operand the reduction constraints are violated. Avoid this
+ situation. */
+ if (op_uses > 1)
+ return NULL;
+ }
+
if (!target_supports_mult_synth_alg (&alg, variant, vectype, synth_shift_p))
return NULL;