Derek Schuff 87a4b36fbe
[WebAssembly] Use MVT::i32 instead of i1 in performAnyAllCombine (#183866)
The CombineSetCC helpers and performAnyAllCombine generate MVT::i1
results.
However MVT::i1 is an illegal type in WebAssembly, and this combiner can
run either before or after legalization. Directly creating the intrinsic
and negating its result using XOR instead of i1 and a NOT operation
avoids this problem.

Fixes #183842
2026-03-03 15:19:23 -08:00

29 lines
1.0 KiB
LLVM

; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 6
; RUN: llc < %s -verify-machineinstrs -mattr=+simd128 | FileCheck %s
target datalayout = "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-i128:128-n32:64-S128-ni:1:10:20"
target triple = "wasm32"
declare void @llvm.memset.p0.i32(ptr writeonly, i8, i32, i1 immarg)
declare i32 @memcmp(ptr noundef, ptr noundef, i32 noundef)
define i1 @memcmp_zero(ptr %d) {
; CHECK-LABEL: memcmp_zero:
; CHECK: .functype memcmp_zero (i32) -> (i32)
; CHECK-NEXT: # %bb.0: # %entry
; CHECK-NEXT: local.get 0
; CHECK-NEXT: v128.const 0, 0
; CHECK-NEXT: v128.store 0:p2align=0
; CHECK-NEXT: i32.const 0
; CHECK-NEXT: v128.load 0:p2align=0
; CHECK-NEXT: v128.any_true
; CHECK-NEXT: i32.const 1
; CHECK-NEXT: i32.ne
; CHECK-NEXT: # fallthrough-return
entry:
call void @llvm.memset.p0.i32(ptr %d, i8 0, i32 16, i1 false)
%call = call i32 @memcmp(ptr null, ptr %d, i32 16)
%tobool.not = icmp eq i32 %call, 0
ret i1 %tobool.not
}