This is an archive of the discontinued LLVM Phabricator instance.

[CorrelatedValuePropagation] Remove redundant if statement in processSelect()
ClosedPublic

Authored by Enna1 on Mar 24 2020, 8:48 PM.

Details

Summary

[CorrelatedValuePropagation] Remove redundant if statement in processSelect()

This statement if (ReplaceWith == S) ReplaceWith = UndefValue::get(S->getType()); is introduced in "https://reviews.llvm.org/rG35609d97ae89b8e13f40f4e6b9b056954f8baa83" to fix a case where unreachable code can cause select instruction simplification to fail.
In "https://reviews.llvm.org/rGd10480657527ffb44ea213460fb3676a6b1300aa", we begin to perform a depth-first walk of basic blocks. This means we will not visit unreachable blocks.
So we do not need this the special check any more.

Diff Detail

Event Timeline

Enna1 created this revision.Mar 24 2020, 8:48 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 24 2020, 8:48 PM
nikic accepted this revision.Mar 25 2020, 1:28 AM

LGTM

llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp
139

Not really related to your change, but the use of swap here is pretty awkward, I'd write this as Value *ReplaceWith = CI->isOne() ? S->getTrueValue() : S->getFalseValue().

This revision is now accepted and ready to land.Mar 25 2020, 1:28 AM
Enna1 updated this revision to Diff 252520.Mar 25 2020, 2:30 AM

update code as suggestion

Enna1 marked an inline comment as done.Mar 28 2020, 3:12 AM

Cause I don't have commit access, can you help me to commit this patch ?
Thanks!

This revision was automatically updated to reflect the committed changes.