This is an archive of the discontinued LLVM Phabricator instance.

[SVE] Fix TypeSize related warnings with IR truncates of scalable vectors
ClosedPublic

Authored by david-arm on Aug 24 2020, 12:56 AM.

Details

Summary

In getCastInstrCost when the instruction is a truncate we were relying
upon the implicit TypeSize -> uint64_t cast when asking if a given type
has the same size as a legal integer. I've changed the code to only
ask the question if the type is fixed length.

I have also changed InstCombinerImpl::SimplifyDemandedUseBits to bail
out for now if the type is a scalable vector.

I've added the following new tests:

Analysis/CostModel/AArch64/sve-trunc.ll
Transforms/InstCombine/AArch64/sve-trunc.ll

for both of these fixes.

Diff Detail

Event Timeline

david-arm created this revision.Aug 24 2020, 12:56 AM
Herald added a reviewer: efriedma. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
david-arm requested review of this revision.Aug 24 2020, 12:56 AM
fpetrogalli added inline comments.Aug 24 2020, 6:20 AM
llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
456

How comes that the test that uses scalable vectors on trunc is reporting zero? afaict, if we enter this methods with trunc of scalable vectors the cost reported by the function should be 1, no?

david-arm marked an inline comment as done.Aug 24 2020, 6:34 AM
david-arm added inline comments.
llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
456

Hi, the cost is actually then recalculated in BasicTTIImpl::getCastInstrCost if the cost != 0.

fpetrogalli accepted this revision.Aug 24 2020, 6:38 AM
fpetrogalli added inline comments.
llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
456

Thank you for explaining. LGTM!

This revision is now accepted and ready to land.Aug 24 2020, 6:38 AM
This revision was landed with ongoing or failed builds.Aug 25 2020, 1:18 AM
This revision was automatically updated to reflect the committed changes.
david-arm marked an inline comment as done.