Page MenuHomePhabricator

[TargetLowering] Change SimplifyDemandedBits for XOR
AbandonedPublic

Authored by foad on Sep 10 2020, 9:21 AM.

Details

Summary

Don't simplify XOR to AND whenever we can, because it's not clear
(to me) that it's simpler.

Instead simplify:

(X | C) ^ C -> X & ~C
(X & ~C) ^ C -> X | C

These are clearly better because they remove one operation.

Diff Detail

Event Timeline

foad created this revision.Sep 10 2020, 9:21 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 10 2020, 9:21 AM
foad requested review of this revision.Sep 10 2020, 9:21 AM
RKSimon added inline comments.Jan 2 2021, 8:24 AM
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
1363

ISD::AND ?

yubing added a subscriber: yubing.Jan 3 2021, 3:03 AM
foad updated this revision to Diff 330599.Mar 15 2021, 3:47 AM

Rebase.

foad updated this revision to Diff 330608.Mar 15 2021, 4:34 AM

Fix ISD::OR -> ISD::AND.

foad added inline comments.Mar 15 2021, 4:36 AM
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
1363

Good spot. Fixed. This patch no longer seems to improve anything (and I only wrote it in the first place to address some regressions in D87145, which has since been landed) so I guess I'll abandon it unless you have some particular interest in it?

This seems to lack description/motivation/test cases.
Why do we not want to strength-reduce xor into an and?

foad abandoned this revision.Mar 15 2021, 4:52 AM

This seems to lack description/motivation/test cases.
Why do we not want to strength-reduce xor into an and?

The original motivation was here: https://reviews.llvm.org/D87145?id=289963#inline-807379

But that problem was fixed in other ways, so I'll give up on this now.