This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Implement BuildSDIVPow2, use cmov to lower sdiv pow2.
AbandonedPublic

Authored by jacquesguan on Aug 20 2021, 12:22 AM.

Details

Summary

If extension Zbt is enabled, we could use cmov to lower sdiv pow2.

Diff Detail

Event Timeline

jacquesguan created this revision.Aug 20 2021, 12:22 AM
jacquesguan requested review of this revision.Aug 20 2021, 12:22 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 20 2021, 12:22 AM

Update test case.

Can you add test cases for dividing by power of 2 larger than 4096/-4096? Those will cause the add with pow2-1 to not fit in the an ADDI anymore. So I think that would be worse code?

I'm not sure it is worth doing this right now given that Zbt is not up for ratification and there has been a lot of discussion about how much encoding space cmov uses.

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

What about i128 and larger? Or is that already blocked by the caller?

Do not perform this transform if the divisor is larger than 12-bits imm or i128.

Can you add test cases for dividing by power of 2 larger than 4096/-4096? Those will cause the add with pow2-1 to not fit in the an ADDI anymore. So I think that would be worse code?

I'm not sure it is worth doing this right now given that Zbt is not up for ratification and there has been a lot of discussion about how much encoding space cmov uses.

Thanks, Now only perform this transform if the divisor is within 12-bits immediate.

What a coincidence.😁

I need to keep track of recent progress before I work on something.

jacquesguan abandoned this revision.Jan 11 2022, 3:48 AM