This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Fold special case (xor (setcc constant, y, setlt), 1) -> (setcc y, constant + 1, setlt)
ClosedPublic

Authored by liaolucy on Jun 5 2023, 1:22 AM.

Details

Summary

Improve D151719.
(xor (setcc constant, y, setlt), 1) -> (setcc y, constant + 1, setlt)
https://alive2.llvm.org/ce/z/BZNEia

Diff Detail

Event Timeline

liaolucy created this revision.Jun 5 2023, 1:22 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 5 2023, 1:22 AM
liaolucy requested review of this revision.Jun 5 2023, 1:22 AM
liaolucy updated this revision to Diff 528312.Jun 5 2023, 1:41 AM

Update, add hasOneUse()

liaolucy updated this revision to Diff 528325.Jun 5 2023, 2:06 AM

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

liaolucy updated this revision to Diff 528327.Jun 5 2023, 2:11 AM

revert the last commit.sorry

liaolucy updated this revision to Diff 528328.Jun 5 2023, 2:14 AM

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

liaolucy updated this revision to Diff 528333.Jun 5 2023, 2:38 AM

revert the last commit.

I tried to set the related parent but it always failed, gave up for now.
I'll post next patch later. (Fold xor(setcc x, y, cond), 1 --> setcc (x, y, inverted(cond)))

I'm sorry to bother you all.

liaolucy updated this revision to Diff 531629.Jun 15 2023, 12:35 AM

Rebase and remove two temporary variables, clearer now.

craig.topper added inline comments.Jun 15 2023, 7:34 PM
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
10484

Use APInt methods here. I don't think we're protected against types being larger than i64 here. So getSExtValue() might assert.

10485

Imm+1 is undefined behavior if Imm happens to be INT64_MAX. Another reason to use APInt.

liaolucy updated this revision to Diff 532151.Jun 16 2023, 7:54 AM
liaolucy marked an inline comment as done.

address comments, use APInt methods, thanks.

This revision is now accepted and ready to land.Jun 16 2023, 11:12 AM