This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] Add checking of i1 types when converting select instructions into zext/sext instructions
ClosedPublic

Authored by congzhe on Dec 14 2020, 9:17 PM.

Details

Summary

When doing select-to-zext/sext transformations, we should not handle
TrueVal and FalseVal of i1 type otherwise it would result in zext/sext i1 to i1.

Note that the current trunk code does not break since the checking currently does exist
but is implicit. When we have TrueVal and FalseVal of i1 type, this case will be captured
in the previous code block:
https://github.com/llvm/llvm-project/blob/master/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp#L2629

Therefore no unit test is provided in this patch. For maintenance purposes however,
this patch makes the checking explicit instead of implicit.

Diff Detail

Event Timeline

congzhe created this revision.Dec 14 2020, 9:17 PM
congzhe requested review of this revision.Dec 14 2020, 9:17 PM
spatel added inline comments.Dec 15 2020, 5:09 AM
llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
2612

Extra && ?

congzhe updated this revision to Diff 312046.Dec 15 2020, 2:59 PM
spatel accepted this revision.Dec 21 2020, 8:56 AM

LGTM

llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
5

Nit: put a period at the end of sentence.

This revision is now accepted and ready to land.Dec 21 2020, 8:56 AM
congzhe updated this revision to Diff 313146.Dec 21 2020, 10:28 AM
congzhe updated this revision to Diff 313147.

LGTM

Thanks for the review! Committed the patch.