[InstCombine] Promote expression tree with @llvm.vscale when zero-extending result.
authorSander de Smalen <sander.desmalen@arm.com>
Tue, 31 Jan 2023 22:20:46 +0000 (22:20 +0000)
committerSander de Smalen <sander.desmalen@arm.com>
Thu, 2 Feb 2023 11:18:16 +0000 (11:18 +0000)
commitda4a5a46b3c86df436d37f81c0b7849f93d7fbde
tree662e5e1610fd237589635bebf50668094d7ac08d
parent4a1832a5c801a61bf4c30891aaebe63993712fd9
[InstCombine] Promote expression tree with @llvm.vscale when zero-extending result.

The LoopVectorizer emits the (scaled) element count as i32, which for
scalable VFs results in calls to @llvm.vscale.i32(). This value is scaled
and further zero-extended to i64.

The zero-extend can be folded away by executing the whole expression in i64
type using @llvm.vscale.i64(). Any logical `and` that would needed to mask
the result can be further folded away by KnownBits analysis when
vscale_range is set.

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D143016
llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
llvm/test/Transforms/InstCombine/vscale.ll [new file with mode: 0644]