[LV] Update logic for calculating register usage due to invariants
authorsgokhale <sgokhale@nvidia.com>
Mon, 27 Feb 2023 07:50:52 +0000 (13:20 +0530)
committersgokhale <sgokhale@nvidia.com>
Tue, 28 Feb 2023 05:35:26 +0000 (11:05 +0530)
commitd1628266946fdddb44bdad2b3ccf3cd5fc769f42
tree5a6a161ae4a49ead080388f0d1714a3a10b8df09
parenta2802dd24f62c14ae00d1691bb19a20d130ec68d
[LV] Update logic for calculating register usage due to invariants

Previously, while calculating register usage due to invariants, it was assumed that invariant would always be part of widening
instructions. This resulted in calculating vector register types for vectors which cant be legalized(check the newly added test for more details).

An invariant might not always need a vector register. For e.g., invariant might just be used for iteration check.

This patch checks if the invariant is part of any widening instruction and considers register usage accordingly. Fixes issue 60493

Differential Revision: https://reviews.llvm.org/D143422
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/test/Transforms/LoopVectorize/AArch64/reg-usage.ll [new file with mode: 0644]
llvm/test/Transforms/LoopVectorize/PowerPC/reg-usage.ll
llvm/test/Transforms/LoopVectorize/RISCV/reg-usage.ll
llvm/test/Transforms/LoopVectorize/RISCV/riscv-vector-reverse.ll
llvm/test/Transforms/LoopVectorize/X86/reg-usage-debug.ll