Reland "[TargetLowering] Teach DemandedBits about VSCALE"
authorBenjamin Maxwell <benjamin.maxwell@arm.com>
Mon, 12 Dec 2022 16:26:20 +0000 (16:26 +0000)
committerBenjamin Maxwell <benjamin.maxwell@arm.com>
Thu, 15 Dec 2022 13:50:02 +0000 (13:50 +0000)
commit3010f60381bcd828d1b409cfaa576328bcd05bbc
tree3bdc07cd8549b5699cff8cabb023c331ea0a4645
parent1cdffa359a3344f966ed309de17af17f8abfbe4d
Reland "[TargetLowering] Teach DemandedBits about VSCALE"

Reland with a fixup to avoid converting APInts to int64_t which allowed for
overflows (UB) with sufficiently high/low multiplier values.

This allows DemandedBits to see the result of VSCALE will be at most
VScaleMax * some compile-time constant. This relies on the vscale_range()
attribute being present on the function, with a max set. (This is done by
default when clang is targeting AArch64+SVE).

Using this various redundant operations (zexts, sexts, ands, ors, etc)
can be eliminated.

Differential Revision: https://reviews.llvm.org/D138508
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
llvm/test/CodeGen/AArch64/vscale-and-sve-cnt-demandedbits.ll