[llvm] [VPlan] Dispatch to multiple exit blocks via middle blocks. (PR #112138)
David Sherwood via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 20 09:18:42 PST 2024
david-arm wrote:
Hi @fhahn, whilst doing some more testing of my patches based on this version I came across what looks like a serious issue in `collectUsersInExitBlocks`. One of the programs in the LLVM test suite (yacr2) miscompiles and I tracked the problem down to some invalid ordering assumptions in `VPIRInstruction::generate`. Essentially `collectUsersInExitBlocks` adds operands to the VPIRInstruction in the order of BasicBlock predecessors in the scalar loop, whereas `VPIRInstruction::generate` follows the order of VPBasicBlock predecessors. The assumption here, which is incorrect, is that the exiting VPBasicBlock in the predecessor list at index `I` corresponds like-for-like with the exiting BasicBlock predecessor index `I` in the original scalar loop. For yacr2 this isn't true and the incoming PHI values got swapped the wrong way around.
I've posted PR #117008, which shows how to fix this. That PR also does extra work required for enabling the tests, but you can look specifically at what I did for `VPIRInstruction::generate`. It's not particularly nice and you may have a better idea? Or is it worth scaling back this patch to only deal with the single early exit that's currently permitted by LoopVectorizationLegality? That might make life simpler and you can more easily enforce consistent ordering. What do you think?
https://github.com/llvm/llvm-project/pull/112138
More information about the llvm-commits
mailing list