[VP] Update uses of select instructions used as masks. #68
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If we run
llvm-lit
onif-elif-else_not-uniform.ll
repeatedly, we'll find that this test case has ~50% probability of failing.The vector-predication pass will mark out the ready-to-be-removed instructions, and then replace all of its uses.
However, some of these instructions, that is, some
select
instructions, are marked asmask
at the beginning of the pass, and thesemask
will be used as parameters of newly-generated vp-instrinsic.In the original version these copies are not updated as well when the instruction is marked as ready-to-be-removed, therefore there still exist uses of ready-to-be-removed instructions. All the instructions are indexed by their addresses. If the replace happens after vp-instrinsic generation, because old uses have appear in LLVM IR, they can be easily handled by
replaceAllUsesWith
method. But if the replace comes first, the vp-instrinsic generation process has to use yet-stored-in-list oldmask
s, resulting in undesired uses and cause should-be-removed instructions remain in blocks.By adding a for loop to iterate through
VecOpsToTransform
, we can update themask
s along withreplaceAllUsesWith
method.The tests is updated as well. The updated version has same semantic with the former version, but obviously the author hopes the
%9 = select ...
line to be removed.