This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] Fold more select of selects using isImpliedCondition
ClosedPublic

Authored by aqjune on May 3 2021, 6:17 PM.

Details

Summary

This is a simple folding that does these:

select x_inv, true, (select y, x, false)
=>
select x_inv, true, y

https://alive2.llvm.org/ce/z/-STJ2d

select (select y, x, false), true, x_inv
=>
select y, true, x_inv

https://alive2.llvm.org/ce/z/6ruYt6

Diff Detail

Event Timeline

aqjune created this revision.May 3 2021, 6:17 PM
aqjune requested review of this revision.May 3 2021, 6:17 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 3 2021, 6:17 PM
spatel accepted this revision.May 4 2021, 5:17 AM

LGTM - seems like there must be more combinations of these implied condition patterns, so we may want to split it into another function and try to make the matching more systematic/complete.

This revision is now accepted and ready to land.May 4 2021, 5:17 AM
nikic added inline comments.May 4 2021, 9:47 AM
llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
2776

Shouldn't we also handle select (select a, b, false), true, c -> select a, true, c here? It seems odd to handle 3 out of 4 patterns.

aqjune added inline comments.May 4 2021, 9:42 PM
llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
2776

Fine, since this is just a repetition of the current change I included it in this patch.

aqjune retitled this revision from [InstCombine] Fold select x_inv, true, (select y, x, false) to [InstCombine] Fold more select of selects using isImpliedCondition.May 4 2021, 9:44 PM
aqjune edited the summary of this revision. (Show Details)
This revision was landed with ongoing or failed builds.May 4 2021, 9:45 PM
This revision was automatically updated to reflect the committed changes.