This is an archive of the discontinued LLVM Phabricator instance.

[AArch64] Small fix for getIntImmCost
ClosedPublic

Authored by zatrazz on Feb 20 2019, 10:07 AM.

Details

Summary

It uses the generic AArch64_IMM::expandMOVImm to get the correct
number of instruction used in immediate materialization.

Diff Detail

Event Timeline

zatrazz created this revision.Feb 20 2019, 10:07 AM

Needs a testcase.

lib/Target/AArch64/AArch64TargetTransformInfo.cpp
50

What is this function actually supposed to compute? If it's just the number of instructions an AArch64::MOVi64imm would expand to, I don't understand what a cost of "0" is supposed to mean.

We currently don't have any code to try to count the number of instructions AArch64ExpandPseudo::expandMOVImm will eventually emit. The complete logic is complicated if you're trying to compute whether we'll generate 2, 3, or 4 instructions... and "countLeadingZeros" is a terrible approximation. But I guess that isn't really important for most uses of getIntImmCost anyway.

zatrazz updated this revision to Diff 189177.Mar 4 2019, 11:41 AM
zatrazz edited the summary of this revision. (Show Details)

Updated patch based on previous comments. It depends on https://reviews.llvm.org/D58915. I am trying to come up with a testcase to actually test it. The the main difference for the cost analysis is just for some immediate that contains some 16-bit zero or one chunk (which will have the size adjusted from 3 to 2). Since they are not TCC_Free, TCC_Basic, or TCC_Expensive the change does not actually interfere in the further cost analysis.

I would expect an effect at least in some cases... for example 0xBEEF000000000000 goes from 4 to 1, unless I'm misreading the code.

zatrazz updated this revision to Diff 189494.Mar 6 2019, 6:11 AM

I added a testcase based on test/CodeGen/ARM/immcost.ll.

efriedma accepted this revision.Mar 6 2019, 3:16 PM

LGTM

This revision is now accepted and ready to land.Mar 6 2019, 3:16 PM
zatrazz closed this revision.Mar 18 2019, 11:49 AM