Page MenuHomePhabricator

[InstCombine] Optimize select (X == C), (icmp X Y), false
AbandonedPublic

Authored by aqjune on Jan 16 2021, 2:56 AM.

Details

Summary

This patch adds transformation select (X == C), (icmp X Y), false ->
select (X == C), (icmp C Y), false.

After the select i1 -> and/or transformation is removed, this optimization
should be explicitly added as a select transformation.
This pattern seems quite common in Transforms/InstCombine.

Alive2 proof:
And: https://alive2.llvm.org/ce/z/dVoKnd
Or: https://alive2.llvm.org/ce/z/3hb9qS

Diff Detail

Event Timeline

aqjune created this revision.Jan 16 2021, 2:56 AM
aqjune requested review of this revision.Jan 16 2021, 2:56 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 16 2021, 2:56 AM
nikic added a comment.Jan 16 2021, 3:42 AM

I think this is a case where being in select form favors us, and we can handle this through a more general transform, rather than the special case that is needed for and/or. The general transform is something along these lines: https://gist.github.com/nikic/4bad7e7e7ecda8d9c9e9633d86836b4d I've wanted to do this for a while, and this looks like a good excuse to make it happen :)

The change makes sense..!
Since the patch is more succinct, I'm in favor of applying the patch than this one.

aqjune abandoned this revision.Jan 17 2021, 4:58 PM