This is an archive of the discontinued LLVM Phabricator instance.

[ARM] Lower UDIV+UREM to UDIV+MLS (and the same for SREM)
ClosedPublic

Authored by SjoerdMeijer on Sep 30 2016, 1:25 AM.

Details

Summary

Code size optimisation to lower udiv+urem to udiv+mls instead of a library call to __aeabi_uidivmod. This is an improved implementation of r280808, see also D24133, that got reverted because isel was stuck in a loop. That was caused by the optimisation incorrectly triggering on i64 ints, which shouldn't happen because there is no 64bit hwdiv support; that put isel's type legalization and this optimisation in a loop. A native ARM compiler and testing now shows that this is fixed.

Patch mostly by Pablo Barrio.

Diff Detail

Repository
rL LLVM

Event Timeline

SjoerdMeijer retitled this revision from to [ARM] Lower UDIV+UREM to UDIV+MLS (and the same for SREM).
SjoerdMeijer updated this object.
SjoerdMeijer added a subscriber: llvm-commits.
rengolin edited edge metadata.Oct 3 2016, 2:14 AM

Makes sense. The i64 type is "legal" because of the long divmod library call, which is not legal for UDIV/SDIV.

Shouldn't i16 and i8 also work, here? I'm guessing that they have type promotion earlier on, so just adding some tests should be fine.

If not, than you may need to update the type check (and maybe extend some types manually).

cheers,
--renato

SjoerdMeijer edited edge metadata.

Hi Renato,

Thanks for reviewing. Smaller int types indeed gets promoted to i32 and a "normal" udiv will be selected. I have added a test case to check this.

Cheers,
Sjoerd.

rengolin accepted this revision.Oct 3 2016, 3:08 AM
rengolin edited edge metadata.

Great, LGTM. Thanks!

This revision is now accepted and ready to land.Oct 3 2016, 3:08 AM
This revision was automatically updated to reflect the committed changes.