This is an archive of the discontinued LLVM Phabricator instance.

[CostModel] Modify BasicTTI getCastInstrCost
ClosedPublic

Authored by samparker on Apr 27 2020, 5:25 AM.

Details

Summary

Copy some of the DataLayout checking, for int/ptr conversions, into BasicTTI and fix the assumption that all bitcasts of the same type sizes are free. We now only assume that bitcasts between ints and ptrs of the same size are free. This allows TTImpl->getUserCost to just call the concrete implementation of getCastInstrCost.

Diff Detail

Event Timeline

samparker created this revision.Apr 27 2020, 5:25 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 27 2020, 5:25 AM
samparker updated this revision to Diff 260318.Apr 27 2020, 7:10 AM

Call BaseT instead of copying code.

dmgreen added inline comments.Apr 30 2020, 10:53 AM
llvm/test/Analysis/CostModel/ARM/cast.ll
1871

These do sound better to me, at least on ARM.

craig.topper added inline comments.Apr 30 2020, 11:23 AM
llvm/include/llvm/CodeGen/BasicTTIImpl.h
692

This line says isIntegerTy twice.

samparker updated this revision to Diff 261435.May 1 2020, 12:21 AM

Thanks. Fixed IntegerTy -> PointerTy.

spatel accepted this revision.May 12 2020, 8:26 AM

LGTM, but give @craig.topper / @RKSimon a day at least to comment further. I can't tell if there are any target-specific issues that can arise from a change like this.

llvm/test/Transforms/SLPVectorizer/X86/load-merge.ll
115–122

I looked at this diff through x86 codegen, and it seems like an improvement to create the vector trunc here. But it's likely a moot point in the motivating real-world example from the bug report because instcombine reduces the IR before SLP sees this form. We may be able to add some load-combining transforms to -vector-combine to catch this.

This revision is now accepted and ready to land.May 12 2020, 8:26 AM
This revision was automatically updated to reflect the committed changes.