[PATCH] D95217: [LoopVectorize] Fix VPRecipeBuilder::createEdgeMask to correctly generate the mask
Juneyoung Lee via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 22 02:03:27 PST 2021
aqjune created this revision.
aqjune added reviewers: fhahn, dmgreen, skatkov.
Herald added a subscriber: hiraditya.
aqjune requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
This patch fixes pr48832 by correctly generating the mask when a poison value is involved.
Consider this CFG (which is a part of the input):
for.body: ; preds = %for.cond
br i1 true, label %cond.false, label %land.rhs
land.rhs: ; preds = %for.body
br i1 poison, label %cond.end, label %cond.false
cond.false: ; preds = %for.body, %land.rhs
br label %cond.end
cond.end: ; preds = %land.rhs, %cond.false
%cond = phi i32 [ 0, %cond.false ], [ 1, %land.rhs ]
The path for.body -> cond.false -> cond.end should be taken when 'select i1 true, i1 poison, i1 false' holds; but VPRecipeBuilder::createEdgeMask was emitting 'and i1 true, poison' instead.
The former one successfully blocks poison propagation whereas the latter one doesn't, causing the miscompilation.
SimplifyCFG has a similar bug (which didn't expose a real-world bug yet), and a patch for this is also ongoing (see https://reviews.llvm.org/D95026).
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D95217
Files:
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/test/Transforms/LoopVectorize/X86/masked_load_store.ll
llvm/test/Transforms/LoopVectorize/X86/x86-interleaved-accesses-masked-group.ll
llvm/test/Transforms/LoopVectorize/if-conversion-nest.ll
llvm/test/Transforms/LoopVectorize/if-pred-non-void.ll
llvm/test/Transforms/LoopVectorize/if-reduction.ll
llvm/test/Transforms/LoopVectorize/pr48832.ll
llvm/test/Transforms/LoopVectorize/reduction-inloop-pred.ll
llvm/test/Transforms/LoopVectorize/reduction-inloop.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D95217.318467.patch
Type: text/x-patch
Size: 23457 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210122/1cf24707/attachment.bin>
More information about the llvm-commits
mailing list