[llvm] [WebAssembly] Add support for avgr_u in loops (PR #153252)
Jasmine Tang via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 14 14:28:06 PDT 2025
================
----------------
badumbatish wrote:
Even at precommit, the compiler can turn the following this to avgr_u already by the pattern in the tablegen
```llvm
%a = add nuw <16 x i8> %x, %y
%b = add nuw <16 x i8> %a, <i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1,
i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1>
; replacing udiv with lshr in @avgr_u_v16i8 of llvm/test/CodeGen/WebAssembly/simd-arith.ll
%c = lshr <16 x i8> %b, <i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1,
i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1>
ret <16 x i8> %c
```
I think the point of the having the loop vectorizer test case is that the loop vectorizer will vectorize the loop into AVGCEIL_U, where we can match to it to produce avgr_u.
I'm not sure how to replicate this in raw llvm ir without going through the loop vectorizer?
https://github.com/llvm/llvm-project/pull/153252
More information about the llvm-commits
mailing list