diff options
| author | nora <48135649+Noratrieb@users.noreply.github.com> | 2026-02-05 08:50:57 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-02-05 15:50:57 +0800 |
| commit | 3bbf748a63a3cb38271a478b520789be57d5e2c8 (patch) | |
| tree | 840e9ba023906e3c99f835404b699a947850a676 /llvm/lib/Transforms/Vectorize | |
| parent | 584156d15d24c9b9f67aa7850e86ee2474a250c0 (diff) | |
| download | llvm-3bbf748a63a3cb38271a478b520789be57d5e2c8.tar.gz llvm-3bbf748a63a3cb38271a478b520789be57d5e2c8.tar.bz2 llvm-3bbf748a63a3cb38271a478b520789be57d5e2c8.zip | |
[VPlan] Create edge mask for single-destination switch (#179107)
When converting phis to blends, the `VPPredicator` expects to have edge
masks to the phi node if the phi node has different incoming blocks.
This was not the case if the predecessor of the phi was a switch where a
conditional destination was the same as the default destination.
This was because when creating edge masks in `createSwitchEdgeMasks`,
edge masks are set in a loop through the *non-default* destinations. But
when there are no non-default destinations (but at least one condition,
otherwise an earlier condition would trigger and just forward the source
mask), this loop is never executed, so the masks are never set.
To resolve this, we explicitly forward the source mask for these cases
as well, which is correct because it is an unconditional branch, just a
very convoluted one.
fixes #179074
Diffstat (limited to 'llvm/lib/Transforms/Vectorize')
| -rw-r--r-- | llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp b/llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp index f7e7fc29bc20..7f787dcbbf3c 100644 --- a/llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp +++ b/llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp @@ -225,6 +225,10 @@ void VPPredicator::createSwitchEdgeMasks(VPInstruction *SI) { DefaultMask = Builder.createNot(DefaultMask); if (SrcMask) DefaultMask = Builder.createLogicalAnd(SrcMask, DefaultMask); + } else { + // There are no destinations other than the default destination, so this is + // an unconditional branch. + DefaultMask = SrcMask; } setEdgeMask(Src, DefaultDst, DefaultMask); } |
