Moving these into the middle-end pipeline will allow for additional optimization of the expansion result, such as CSE of redundant loads (c.f. https://godbolt.org/z/bEna4Md9r). For now, we conservatively place the passes at the end of the middle-end pipeline, so we mostly don't benefit from additional optimizations yet. The pipeline position will be moved in a future change. This builds on work done by legrosbuffle in https://reviews.llvm.org/D60318. --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
28 lines
1.0 KiB
LLVM
28 lines
1.0 KiB
LLVM
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 6
|
|
; RUN: opt -passes=expand-memcmp -mtriple=wasm32 -mattr=+simd128 -S < %s | llc -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.eqz
|
|
; 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
|
|
}
|