This is an archive of the discontinued LLVM Phabricator instance.

[SelectionDAG] Add FP_TO_UINT_SAT/FP_TO_SINT_SAT to computeKnownBits/computeNumSignBits.
ClosedPublic

Authored by craig.topper on Jan 8 2022, 1:34 PM.

Details

Summary

These nodes should saturate to their saturating VT. We can use this
information to know the bits past the VT are all zeros or all sign bits.

I think we might only have test coverage for the unsigned case. I'll
verify and add tests.

Diff Detail

Event Timeline

craig.topper created this revision.Jan 8 2022, 1:34 PM
craig.topper requested review of this revision.Jan 8 2022, 1:34 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 8 2022, 1:34 PM

Rebase after adding more tests including tests for sign bits.

nikic accepted this revision.Jan 9 2022, 12:54 AM

LGTM

This revision is now accepted and ready to land.Jan 9 2022, 12:54 AM
foad added inline comments.Jan 9 2022, 1:03 AM
llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
3588

"UINT"

foad added inline comments.Jan 10 2022, 1:03 AM
llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
3588

Could you also update the comments for FP_TO_[US]INT_SAT in include/llvm/CodeGen/ISDOpcodes.h to document the properties you are relying on here? Currently it says nothing about the value of the bits between the saturating type and the result type.

craig.topper added inline comments.Jan 10 2022, 6:09 PM
llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
3588
foad added inline comments.Jan 11 2022, 12:22 AM
llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
3588

Thanks!