This is an archive of the discontinued LLVM Phabricator instance.

[RISCV][DAGCombiner] Custom lower ISD::ABS to sra (X, size(X)-1); sub (xor (X, Y), Y).
AbandonedPublic

Authored by craig.topper on Feb 6 2022, 5:18 PM.

Details

Summary

Default lowering does sra (X, size(X)-1); Z = add(X, Y); xor(Z, Y)

If we put the sub at the end we give opportunities to use subw if
the later ops want the value sign extended.

I had to limit DAGCombiner to prevent an infinite loop where this expansion would be turned back into ISD::ABS.

Diff Detail

Event Timeline

craig.topper created this revision.Feb 6 2022, 5:18 PM
craig.topper requested review of this revision.Feb 6 2022, 5:18 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 6 2022, 5:18 PM
craig.topper edited the summary of this revision. (Show Details)Feb 6 2022, 5:20 PM

Modify comment slightlyw

clang-format

What about just updating the default lowering?

What about just updating the default lowering?

I thought maybe the commutable xor at the end was useful for X86’s destructive instructions. But I didn’t check. I’ll change it and check the lit tests.

craig.topper abandoned this revision.Feb 21 2022, 9:54 AM