This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Add RISCVISD::BR_CC similar to RISCVISD::SELECT_CC.
ClosedPublic

Authored by craig.topper on Mar 7 2021, 4:06 PM.

Details

Summary

This allows me to introduce similar combines for branches as
we have recently added for SELECT_CC. Some of them are less
useful for standalone setccs and only help branch instructions.
By having a BR_CC node its easier to only affect branches.

I'm using CondCodeSDNode to make isel patterns easier to
write so we can refer to the codes by name. SELECT_CC uses a
constant instead.

I've normalizing the condition code just like SELECT_CC so
we need less patterns for the swapped conditions. I've also
folded the setlt X, -1 handling into the normalize to get rid
of that special case isel pattern.

computeKnownBitsForTargetNode support for SELECT_CC is added
to allow MaskedValueIsZero to work for cases where the true
and false values of the SELECT_CC are setccs and the
result of the SELECT_CC is used by a BR_CC. This was needed
to avoid regressions in some of the overflow tests.

Diff Detail

Event Timeline

craig.topper created this revision.Mar 7 2021, 4:06 PM
craig.topper requested review of this revision.Mar 7 2021, 4:06 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 7 2021, 4:06 PM
Herald added a subscriber: MaskRay. · View Herald Transcript

Rebase. The change to normaliseSetCC was already commited in a separate patch.

luismarques accepted this revision.Mar 15 2021, 1:38 AM

LGTM.

(Perhaps it would have been better to have split it into the NFC patch and the rest?)

llvm/lib/Target/RISCV/RISCVISelLowering.cpp
4297

Add empty line before?

This revision is now accepted and ready to land.Mar 15 2021, 1:38 AM

LGTM.

(Perhaps it would have been better to have split it into the NFC patch and the rest?)

I'm not sure there was much of a clean separation, but I'll see if I can split some of it when I commit.

craig.topper added inline comments.Mar 15 2021, 10:29 AM
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
1887

I'll split this out or drop it. It was a little less bad when we were also changing the signature of normaliseSetCC in this patch.

Remove non-functional change in LowerSELECT.
Add blank line.

Waiting for D98449 to commit before committing this since the isel pattern
for that will become obsolete, but the test from D98449 is still valid.

This revision was landed with ongoing or failed builds.Mar 15 2021, 11:54 AM
This revision was automatically updated to reflect the committed changes.