This is an archive of the discontinued LLVM Phabricator instance.

[ARM] Fix TTI IntImmCost
AbandonedPublic

Authored by samparker on Jan 30 2019, 4:26 AM.

Details

Summary

The cost of immediates returned from the backend was generally wrong, returning 1 for most immediates that could be directly encoded within an instruction. We now return 0 for these. The valuesreturned are now also more accurate, taking into consideration the exotic encoding patterns of Thumb2 immediates and calculating how many mov instructions would be needed to rematerialise a value.

Diff Detail

Event Timeline

samparker created this revision.Jan 30 2019, 4:26 AM

Some tests to follow...

It looks like APInt doesn't function the way I expected, nor in the way that the other authors of this area would have expected. I've posted a query: http://lists.llvm.org/pipermail/llvm-dev/2019-January/129781.html

xbolva00 added inline comments.
lib/Target/ARM/ARMTargetTransformInfo.cpp
111

Can we have a enum or so with these return constants and use them instead of “return 3”, “return 1”, ..

samparker marked an inline comment as done.Jan 31 2019, 6:33 AM
samparker added inline comments.
lib/Target/ARM/ARMTargetTransformInfo.cpp
111

Sure, I'll use TargetCostConstants.

efriedma added inline comments.Jan 31 2019, 9:08 AM
lib/Target/ARM/ARMTargetTransformInfo.cpp
99

Why are you throwing away the existing code using getT2SOImmVal/getSOImmVal and writing out the same logic inline?

108

Should this be guarded by useMovt?

158

Not sure I follow this logic; what does "Imm" actually mean in this case? Are we expecting that the result of the GEP will be folded into a load?

Actually, we already have some very similar code in ARMDAGToDAGISel::ConstantMaterializationCost; can we share that code somehow?

samparker marked 3 inline comments as done.Feb 1 2019, 3:22 AM

I like that idea, I think moving the logic into ARMISelLowering would be good as we already use similar logic there too.

lib/Target/ARM/ARMTargetTransformInfo.cpp
99

Thanks, I'll revert.

108

Will do.

158

Yes, I'm assuming an immediate index which will be directly used by a load/store. I know this assumption doesn't hold all the time... But I'm not sure what to do with the limited information here.

dexonsmith resigned from this revision.Aug 26 2019, 11:17 AM
samparker abandoned this revision.May 4 2020, 1:07 AM