This is an archive of the discontinued LLVM Phabricator instance.

[RISCV]Fold xor(setcc x, y, cond), 1 --> setcc (x, y, inverted(cond))
AbandonedPublic

Authored by liaolucy on Jun 5 2023, 8:52 PM.

Details

Reviewers
craig.topper
asb
Summary

Similar to x86.
RISCV legalizing setgt to setlt, so this fold excludes setult,setlt,setule.
For setoeq, may not be the expected
https://github.com/llvm/llvm-project/blob/main/llvm/test/CodeGen/RISCV/float-br-fcmp.ll#L122

Diff Detail

Event Timeline

liaolucy created this revision.Jun 5 2023, 8:52 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 5 2023, 8:52 PM
liaolucy requested review of this revision.Jun 5 2023, 8:52 PM
liaolucy added inline comments.Jun 5 2023, 8:55 PM
llvm/test/CodeGen/RISCV/half-select-fcmp.ll
877

Here's the regression, which looks easy to fix

craig.topper added inline comments.Jun 5 2023, 9:34 PM
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
10328

getSetCCInverse expects the VT of the setcc operands not the VT of the result. This is needed to tell the difference between floating point and integer comparisons.

I'm pretty sure a lot of the changes from this patch are miscompiles due to using integer inversion for FP.

craig.topper requested changes to this revision.Jun 5 2023, 9:39 PM
This revision now requires changes to proceed.Jun 5 2023, 9:39 PM
liaolucy abandoned this revision.Jun 6 2023, 12:35 AM

After I changed it correctly and found that this patch is not needed anymore, thanks for review.