This is an archive of the discontinued LLVM Phabricator instance.

[DemandedBits] Add Div instruction to DetermineLiveOperandBits
Needs RevisionPublic

Authored by zjaffal on Oct 26 2022, 2:57 AM.

Details

Summary

DetermineLiveOperandBits is missing a case for div instructions. Before the patch, the pass assumed that the operand of div instructions uses all the available bits which can be an overestimate.

Diff Detail

Event Timeline

zjaffal created this revision.Oct 26 2022, 2:57 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 26 2022, 2:57 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
zjaffal published this revision for review.Oct 26 2022, 2:59 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 26 2022, 2:59 AM

Please can you add udiv/sdiv exhaustive test coverage to llvm-project\llvm\unittests\IR\DemandedBitsTest.cpp

Please can you add udiv/sdiv exhaustive test coverage to llvm-project\llvm\unittests\IR\DemandedBitsTest.cpp

Would be possible to use the same logic used for add and sub or I need to create something new? Also do you think we should add ir tests as well or that wouldn't be necessary

Please can you add udiv/sdiv exhaustive test coverage to llvm-project\llvm\unittests\IR\DemandedBitsTest.cpp

Would be possible to use the same logic used for add and sub or I need to create something new? Also do you think we should add ir tests as well or that wouldn't be necessary

You'll probably have to create a similar ForeachKnownBits system from scratch

Adding IR tests to test\Analysis\DemandedBits is always welcome - its pretty empty in there

I don't think this is how division works. It mixes bits up far more than add/sub/mul for which a bit in the input can only affect equal or lower ones in the output.

I don't think this is how division works. It mixes bits up far more than add/sub/mul for which a bit in the input can only affect equal or lower ones in the output.

This is why I wanted to see an exhaustive test, its more subtle than the current attempt - but there's definitely a case for a suitable demanded bitmask of the lower bits based off the number of common known leading sign/zero bits of the arguments.

fhahn requested changes to this revision.Nov 22 2022, 8:56 AM
fhahn added a subscriber: fhahn.

Marking as changes requested as per the previous comments.

This revision now requires changes to proceed.Nov 22 2022, 8:56 AM
lebedev.ri resigned from this revision.Jan 12 2023, 4:59 PM

This review may be stuck/dead, consider abandoning if no longer relevant.
Removing myself as reviewer in attempt to clean dashboard.