[llvm] [WebAssembly] Add support for avgr_u in loops (PR #153252)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 20 22:48:50 PDT 2025


================

----------------
lukel97 wrote:

I went poking around and I think the reason why we're seeing the diff is because DAGCombiner needs the trunc to form ISD::AVGCEILU.
Can you try replacing this test with this in `simd-arith.ll` and see if this patch makes a difference now? 

```llvm
define <16 x i8> @avgr_u_v16i8_zext(<16 x i8> %x, <16 x i8> %y) {
  %x.zext = zext <16 x i8> %x to <16 x i16>
  %y.zext = zext <16 x i8> %y to <16 x i16>
  %a = add <16 x i16> %x.zext, %y.zext
  %b = add <16 x i16> %a, splat (i16 1)
  %c = lshr <16 x i16> %b, splat (i16 1)
  %c.trunc = trunc <16 x i16> %c to <16 x i8>
  ret <16 x i8> %c.trunc
}

```

And add a version for v8i16 too.

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


More information about the llvm-commits mailing list