https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124142
Bug ID: 124142
Summary: Bad early-break vectorization of loop with integer
modulo
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: jchrist at gcc dot gnu.org
Target Milestone: ---
Created attachment 63703
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=63703&action=edit
Reproducer
Early break vectorization of attached loop (extracted from SpecCPU 2017
cactuBSSN) leads to a vectorization of the loop even though the modulus of the
next iteration of the scalar loop is produced in the current iteration. With
unrolling, this leads to a computation "modulo 0", which traps on certain
architectures.
This crashes early break vectorization on s390 (not upstream due to this bug)
since s390 has vectorized modulo that traps if one lane is 0.
I also tried this on aarch64 (see https://godbolt.org/z/eaqoE9s4x) where it
looks like a division by 0 is possible, but SVE does not trap in that case.