[PATCH] D150587: [KnownBits] Make shl/lshr/ashr implementations optimal

Noah Goldstein via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 15 11:24:16 PDT 2023


goldstein.w.n added inline comments.


================
Comment at: llvm/test/CodeGen/AMDGPU/amdgpu.private-memory.ll:224
 ; SI-PROMOTE-VECT: s_lshr_b32 [[SREG:s[0-9]+]], 0x10000, [[SCALED_IDX]]
-; SI-PROMOTE-VECT: s_and_b32 s{{[0-9]+}}, [[SREG]], 0xffff
+; SI-PROMOTE-VECT: s_and_b32 s{{[0-9]+}}, [[SREG]], 1
 define amdgpu_kernel void @short_array(ptr addrspace(1) %out, i32 %index) #0 {
----------------
nikic wrote:
> I believe this is correct, because SCALED_IDX is `IDX << 4` and as such at least 16. As such, `0x10000 >> SCALED_IDX` is either zero or one and the and mask can be narrowed to 1.
Was the old value buggy then?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D150587/new/

https://reviews.llvm.org/D150587



More information about the llvm-commits mailing list