https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119351

--- Comment #16 from Tamar Christina <tnfchris at gcc dot gnu.org> ---
Ok, found the bug and c-vise is running for a testcase.

The issue is as follows:

For early break we need to know which value to start the scalar loop with if we
take an early exit.

Historically this means that we take the first element of every induction.
this is because there's an assumption in place, that even with masked loops the
masks come from a whilel* instruction.

As such we reduce using a BIT_FIELD_REF <, 0>.

When PFA was added this assumption was correct for non-masked loop, however we
assumed that PFA for VLA wouldn't work for now, and disabled it using the
alignment requirement checks.  We also expected VLS to PFA using scalar loops.

However as this PR shows, for VLS the vectorizer can, and does in some
circumstances choose to peel using masks by masking the first iteration of the
loop.

When this is done, the first elements of the predicate can be inactive. In this
example element 1 is inactive based on the dynamically calculated misalignment.
 hence the -1 value in the first vector element.

When we reduce using BIT_FIELD_REF we get the wrong value.

vectorizable_live_operation_1 needs to in the case of
LOOP_VINFO_MASK_SKIP_NITERS reduce using the mask, rather than a BIT_FIELD_REF
otherwise PFA for VLS is broken.

Working on patch.

Reply via email to