[llvm] [GlobalISel] Use G_ANYEXT instead of G_ZEXT for shift amount widening (PR #223136)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Sat Sep 12 16:07:47 PDT 2026
================
@@ -3044,9 +3044,10 @@ LegalizerHelper::widenScalar(MachineInstr &MI, unsigned TypeIdx, LLT WideTy) {
widenScalarDst(MI, WideTy);
} else {
assert(TypeIdx == 1);
- // The "number of bits to shift" operand must preserve its value as an
- // unsigned integer:
- widenScalarSrc(MI, WideTy, 2, TargetOpcode::G_ZEXT);
+ // The shift amount is undefined behavior for values >= type width,
+ // so we can use G_ANYEXT instead of G_ZEXT to avoid generating
+ // a redundant AND instruction.
----------------
arsenm wrote:
This depends on the specific source type width
https://github.com/llvm/llvm-project/pull/223136
More information about the llvm-commits
mailing list