[VPlan] Fix iterator invalidation in adjustFixedOrderRecurrences.
authorFlorian Hahn <flo@fhahn.com>
Mon, 13 Feb 2023 13:51:14 +0000 (13:51 +0000)
committerFlorian Hahn <flo@fhahn.com>
Mon, 13 Feb 2023 13:51:14 +0000 (13:51 +0000)
commitaf3c25dc3d871a7665610a819426c31d5eb17a03
tree639c871f717bbeb7f45d04c42d1e9576e0e4c0d0
parent5801090258011cfe636cda1493ac9bc07fb2a889
[VPlan] Fix iterator invalidation in adjustFixedOrderRecurrences.

adjustFixedOrderRecurrences may insert instructions after immediately
after the PHI nodes in the block. This invalidates the phis() iterator.
To avoid crashing/accessing invalid recipes, first collect all
first-order recurrence phi recipes.

This should fix a crash reported by @dmgreen after D142589 landed.
llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
llvm/test/Transforms/LoopVectorize/AArch64/first-order-recurrence-fold-tail.ll [new file with mode: 0644]