[LoopVectorize] Fix zext/sext cost calculations when types are shrunk
authorDavid Sherwood <david.sherwood@arm.com>
Wed, 29 Mar 2023 12:22:09 +0000 (12:22 +0000)
committerDavid Sherwood <david.sherwood@arm.com>
Thu, 6 Apr 2023 08:52:25 +0000 (08:52 +0000)
commit9278dd7b2bd9bab4a7122b074e43e9bdd0d5d20f
tree146deb34f293f088424a1fa314357ab75db901da
parent70e5a2a94354fd7cec577d3e0c3892cc5e7ef07a
[LoopVectorize] Fix zext/sext cost calculations when types are shrunk

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.

Differential Revision: https://reviews.llvm.org/D147152
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/test/Transforms/LoopVectorize/AArch64/type-shrinkage-zext-costs.ll