This is an archive of the discontinued LLVM Phabricator instance.

[LoopVectorize] Fix zext/sext cost calculations when types are shrunk
ClosedPublic

Authored by david-arm on Mar 29 2023, 6:33 AM.

Details

Summary

In getInstructionCost if we know a zext/sext is going to be shrunk
we should only be changing the destination type, and leave the
source type unchanged. For example, we may change a zext from

zext <16 x i8> %a to <16 x i32>

to

zext <16 x i8> %a to <16 x i16>

However, we were previously calculating the cost for doing

zext <16 x i16> %a to <16 x i16>

which is incorrect.

Diff Detail

Event Timeline

david-arm created this revision.Mar 29 2023, 6:33 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 29 2023, 6:33 AM
david-arm requested review of this revision.Mar 29 2023, 6:33 AM
kmclaughlin accepted this revision.Apr 5 2023, 5:24 AM
kmclaughlin added inline comments.
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
7370

Maybe not as part of this patch, but should we also leave SrcVecTy unchanged for truncates too?

This revision is now accepted and ready to land.Apr 5 2023, 5:24 AM
This revision was landed with ongoing or failed builds.Apr 6 2023, 1:52 AM
This revision was automatically updated to reflect the committed changes.