[llvm] [InstCombine] Prevent constant operand shrinkage on returns of zero-extension ANDs (PR #146201)

Hanyang Xu via llvm-commits llvm-commits at lists.llvm.org
Sat Jun 28 22:49:14 PDT 2025


ericxu233 wrote:

> I don't think that the "return only use" here is really relevant -- it's a general property of x86 that it can encode a "low 32-bit" mask more compactly than other masks, regardless of where in the code it occurs.
> 
> Now, if you remove that special case and expose this to wider test coverage, you'll probably quickly find that this is going to break other optimizations that rely on the current demanded bits reduction.

I got rid of the return-only use, and only five additional test cases fail with ninja -C build check-llvm:

  LLVM :: Transforms/InstCombine/callsite_nonnull_args_through_casts.ll
  LLVM :: Transforms/InstCombine/icmp-trunc.ll
  LLVM :: Transforms/InstCombine/shift-shift.ll
  LLVM :: Transforms/InstCombine/shift.ll
  LLVM :: Transforms/InstCombine/sub-gep.ll

I haven't looked into them in more detail yet, but do you think that looking into them and fixing them would be worth it so we have a more general coverage?


https://github.com/llvm/llvm-project/pull/146201


More information about the llvm-commits mailing list