This is an archive of the discontinued LLVM Phabricator instance.

[builtins] Write __divmoddi4/__divmodsi4 in terms __udivmod instead of __div and multiply.
ClosedPublic

Authored by craig.topper on Sep 9 2020, 10:20 PM.

Details

Summary

Previously we calculating the remainder by multiplying the
quotient and divisor and subtracting from the dividend.

__udivmod can calculate the remainder while calculating the
quotient. We just need to correct the sign afterward.

Diff Detail

Event Timeline

craig.topper created this revision.Sep 9 2020, 10:20 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 9 2020, 10:20 PM
Herald added a subscriber: Restricted Project. · View Herald Transcript
craig.topper requested review of this revision.Sep 9 2020, 10:20 PM
MaskRay added inline comments.Sep 10 2020, 12:06 AM
compiler-rt/lib/builtins/divmodsi4.c
19–28

Just bits_in_word? m1 is not used.

MaskRay accepted this revision.Sep 10 2020, 12:07 AM
MaskRay added inline comments.
compiler-rt/lib/builtins/divmodsi4.c
19–28

ok, m1 means minus 1...

This revision is now accepted and ready to land.Sep 10 2020, 12:07 AM
This revision was landed with ongoing or failed builds.Sep 10 2020, 8:10 AM
This revision was automatically updated to reflect the committed changes.