This is an archive of the discontinued LLVM Phabricator instance.

[ARM] Fix cost computation for constant hoisting
ClosedPublic

Authored by weimingz on Jun 23 2016, 5:12 PM.

Details

Summary

Bug: https://llvm.org/bugs/show_bug.cgi?id=28282

Currently the cost model of constant hoisting checks the bit width of the data type of the constants.
However, the actual immediate value is small enough and not need to be hoisted.
This patch checks for the actual bit width needed for the constant.

Diff Detail

Event Timeline

weimingz updated this revision to Diff 61747.Jun 23 2016, 5:12 PM
weimingz retitled this revision from to [ARM] Fix cost computation for constant hoisting.
weimingz updated this object.
weimingz set the repository for this revision to rL LLVM.
weimingz added a subscriber: llvm-commits.
weimingz updated this revision to Diff 61811.Jun 24 2016, 11:01 AM
weimingz removed rL LLVM as the repository for this revision.

using ">=" because when convert to signed values, getMinSignedBits() may return 65. Instead of checking both activeBits and MinSignedBits(), we just check if activeBits() is no larger than 64.

rengolin edited edge metadata.Jun 26 2016, 8:56 AM

Hi Weiming,

The code makes sense, but the test is not clear as to what it's all about or what's the expected output, which will make it very hard for people to follow up when it breaks for other reasons.

Can you add a comment to the test explaining what's this is about and what's the expected behaviour?

cheers,
--renato

test/Transforms/ConstantHoisting/ARM/bad-cases.ll
107

Was this line supposed to be a CHECK?

weimingz updated this revision to Diff 61931.Jun 26 2016, 11:09 PM
weimingz edited edge metadata.
weimingz set the repository for this revision to rL LLVM.

Hi Renato,

Thanks for the feedback.
I Simplified the test case and added comments.

weimingz updated this object.Jun 28 2016, 10:46 AM
rengolin accepted this revision.Jun 28 2016, 2:53 PM
rengolin edited edge metadata.

LGTM, thanks!

This revision is now accepted and ready to land.Jun 28 2016, 2:53 PM
This revision was automatically updated to reflect the committed changes.