This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Apply DeMorgan's law to (and/or (xor X, 1), (xor Y, 1)) if X and Y are 0/1.
ClosedPublic

Authored by craig.topper on Aug 24 2022, 3:30 PM.

Details

Summary

This optimizes xors that appear due to legalizing setge/setle which
require an xor with 1. This reduces the number of xors and may
allow the xor to fold with a beqz or bnez.

Diff Detail

Event Timeline

craig.topper created this revision.Aug 24 2022, 3:30 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 24 2022, 3:30 PM
craig.topper requested review of this revision.Aug 24 2022, 3:30 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 24 2022, 3:30 PM
reames accepted this revision.Aug 24 2022, 3:40 PM

LGTM

This revision is now accepted and ready to land.Aug 24 2022, 3:40 PM

I didn't notice, but this only handled or. The and case ended up with an not due to SimplifyDemandedBits.

Fix the AND case

craig.topper requested review of this revision.Aug 24 2022, 4:42 PM

Can you land the prior version and post the xor n, -1 bit as a separate patch? It's slightly non-obvious.

This revision was not accepted when it landed; it landed in state Needs Review.Aug 25 2022, 8:54 AM
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.