This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Optimize (select (x in [0,1] != 0), y, (z ^ y) ) -> ((x-1) & z ) ^ y
AbandonedPublic

Authored by craig.topper on Dec 20 2022, 10:07 PM.

Details

Summary

This is the inverted case of
(select (x in [0,1] == 0), y, (z ^ y) ) -> (-x & z ) ^ y

Instead of -x we need -(x ^ 1) which simplifies to -(1-x) or (x-1).

Diff Detail

Event Timeline

craig.topper created this revision.Dec 20 2022, 10:07 PM
craig.topper requested review of this revision.Dec 20 2022, 10:07 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 20 2022, 10:07 PM
asb accepted this revision.Dec 21 2022, 1:36 AM

Reviewing this in isolation, LGTM. It's going to conflict with D140465 though so I'm not sure what your plan is there?

This revision is now accepted and ready to land.Dec 21 2022, 1:36 AM

Reviewing this in isolation, LGTM. It's going to conflict with D140465 though so I'm not sure what your plan is there?

I will abandon this patch. The select rabbit hole kept getting deeper after I wrote this patch. I'll extract the new tests from it though.

craig.topper abandoned this revision.Dec 21 2022, 10:39 AM