Issue 179145
Summary [WebAssembly] bitcast defeats extadd pattern
Labels new issue
Assignees
Reporter folkertdev
    Same general idea as https://github.com/llvm/llvm-project/issues/179143, see:

https://godbolt.org/z/cdnMsrjfe

```llvm
define <4 x i32> @with_bitcast(<4 x i32> %a) {
start:
  %a1 = bitcast <4 x i32> %a to <8 x i16>
  %0 = shufflevector <8 x i16> %a1, <8 x i16> %a1, <4 x i32> <i32 0, i32 2, i32 4, i32 6>
  %1 = shufflevector <8 x i16> %a1, <8 x i16> %a1, <4 x i32> <i32 1, i32 3, i32 5, i32 7>
  %2 = sext <4 x i16> %0 to <4 x i32>
 %3 = sext <4 x i16> %1 to <4 x i32>
  %4 = add nsw <4 x i32> %2, %3
  ret <4 x i32> %4
}

define <4 x i32> @without_bitcast(<8 x i16> %a) {
start:
  %0 = shufflevector <8 x i16> %a, <8 x i16> %a, <4 x i32> <i32 0, i32 2, i32 4, i32 6>
  %1 = shufflevector <8 x i16> %a, <8 x i16> %a, <4 x i32> <i32 1, i32 3, i32 5, i32 7>
  %2 = sext <4 x i16> %0 to <4 x i32>
 %3 = sext <4 x i16> %1 to <4 x i32>
  %4 = add nsw <4 x i32> %2, %3
  ret <4 x i32> %4
}


```

```asm
with_bitcast:
        local.get 0
        i32.const       16
        i32x4.shl
        i32.const 16
        i32x4.shr_s
        local.get       0
        local.get 0
        i8x16.shuffle   2, 3, 6, 7, 10, 11, 14, 15, 0, 1, 0, 1, 0, 1, 0, 1
        i32x4.extend_low_i16x8_s
        i32x4.add
 end_function

without_bitcast:
        local.get       0
 i32x4.extadd_pairwise_i16x8_s
        end_function
```

cc @badumbatish https://github.com/llvm/llvm-project/pull/167960
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to