This is an archive of the discontinued LLVM Phabricator instance.

Pass function attributes instead of simple flag in isIntDivCheap target query. Add test cases.
ClosedPublic

Authored by srking on Aug 24 2015, 3:15 PM.

Details

Summary

Changes isIntDivCheap() target query to take function attributes instead of a boolean optimization flag. Targets can use the function attributes to make more informed size/speed trade-offs, particularly for borderline -Os optimized code.

Refactors default BuildSDIVPow2 to call isIntDivCheap() in order to simplify SDIV by power-of-2 logic.

Adds a new regression test for x86, which is the only in-tree target that implements isIntDivCheap(). The test verifies that -Oz optimization level produces IDIV and -Os optimization level expands to a non-IDIV sequence.

Diff Detail

Event Timeline

srking updated this revision to Diff 33008.Aug 24 2015, 3:15 PM
srking retitled this revision from to Pass function attributes instead of simple flag in isIntDivCheap target query. Add test cases..
srking updated this object.
mehdi_amini accepted this revision.Aug 24 2015, 5:02 PM
mehdi_amini added a reviewer: mehdi_amini.
mehdi_amini added a subscriber: mehdi_amini.

LGTM.

test/CodeGen/X86/sdiv-pow2.ll
24

Bonus point if you add a comment on top of this one as well :)

This revision is now accepted and ready to land.Aug 24 2015, 5:02 PM
srking updated this revision to Diff 33034.Aug 24 2015, 6:15 PM
srking edited edge metadata.

Added new comment to tests.

srking marked an inline comment as done.Aug 24 2015, 6:17 PM
srking closed this revision.Aug 24 2015, 8:27 PM

r245921