Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Addresses nit in PR
  • Loading branch information
badumbatish committed Jul 20, 2025
commit 8a8c1533cf3534330f91582a6e94f019c531bb6a
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,6 @@ WebAssemblyTTIImpl::enableMemCmpExpansion(bool OptSize, bool IsZeroCmp) const {
Options.AllowOverlappingLoads = true;

// TODO: Teach WebAssembly backend about load v128.
// if (ST->hasSIMD128())
// Options.LoadSizes.push_back(16);

Options.LoadSizes.append({8, 4, 2, 1});
Comment thread
badumbatish marked this conversation as resolved.
Options.MaxNumLoads = TLI->getMaxExpandSizeMemcmp(OptSize);
Expand Down
19 changes: 13 additions & 6 deletions llvm/test/CodeGen/WebAssembly/memcmp-expand.ll
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
; RUN: llc < %s -O3 -verify-machineinstrs -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers -mattr=+simd128 | FileCheck %s
; RUN: llc < %s -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers | FileCheck %s

target triple = "wasm32-unknown-unknown"

Expand Down Expand Up @@ -101,6 +101,18 @@ define i1 @memcmp_expand_2(ptr %a, ptr %b) {
ret i1 %res
}

define i1 @memcmp_expand_2_align(ptr align(2) %a, ptr align(2) %b) {
; CHECK-LABEL: memcmp_expand_2_align:
; CHECK: .functype memcmp_expand_2_align (i32, i32) -> (i32)
; CHECK-NEXT: # %bb.0:
; CHECK-NEXT: i32.load16_u $push1=, 0($0)
; CHECK-NEXT: i32.load16_u $push0=, 0($1)
; CHECK-NEXT: i32.eq $push2=, $pop1, $pop0
; CHECK-NEXT: return $pop2
%cmp_2 = call i32 @memcmp(ptr %a, ptr %b, i32 2)
%res = icmp eq i32 %cmp_2, 0
ret i1 %res
}

define i1 @memcmp_expand_8(ptr %a, ptr %b) {
; CHECK-LABEL: memcmp_expand_8:
Expand All @@ -115,7 +127,6 @@ define i1 @memcmp_expand_8(ptr %a, ptr %b) {
ret i1 %res
}


; TODO: Should be using a single load i64x2 or equivalent in bitsizes
define i1 @memcmp_expand_16(ptr %a, ptr %b) {
; CHECK-LABEL: memcmp_expand_16:
Expand All @@ -138,7 +149,3 @@ define i1 @memcmp_expand_16(ptr %a, ptr %b) {
%res = icmp eq i32 %cmp_16, 0
ret i1 %res
}




Loading