[PATCH] D139871: [WebAssembly] Replace LOAD_SPLAT with SPLAT_VECTOR

Luke Lau via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 12 12:12:43 PST 2022


luke added inline comments.


================
Comment at: llvm/test/CodeGen/WebAssembly/fpclamptosat_vec.ll:20-21
 ; CHECK-NEXT:    local.tee 0
-; CHECK-NEXT:    v128.const 2147483647, 2147483647
+; CHECK-NEXT:    i64.const 2147483647
+; CHECK-NEXT:    i64x2.splat
 ; CHECK-NEXT:    local.tee 1
----------------
Constant splats now get selected as a const and a splat, which can save code size for the smaller integer sizes since v128.const is always 18 bytes long. 


================
Comment at: llvm/test/CodeGen/WebAssembly/simd-load-splat.ll:8-14
 ; CHECK-LABEL: load_splat:
 ; CHECK-NEXT: .functype load_splat (i32, i32) -> (i32)
-; CHECK-NEXT: i32.load8_u $[[E:[0-9]+]]=, 0($0){{$}}
-; CHECK-NEXT: v128.load8_splat $push[[V:[0-9]+]]=, 0($0){{$}}
+; CHECK-NEXT: i32.load8_u $push[[E:[0-9]+]]=, 0($0){{$}}
+; CHECK-NEXT: local.tee $push[[T:[0-9]+]]=, $[[R:[0-9]+]]=, $pop[[E]]{{$}}
+; CHECK-NEXT: i8x16.splat $push[[V:[0-9]+]]=, $pop[[T]]{{$}}
 ; CHECK-NEXT: v128.store 0($1), $pop[[V]]{{$}}
+; CHECK-NEXT: return $[[R]]{{$}}
----------------
This results in one more instruction, but one less load. The resulting binary code size is probably comparable since tee is usually only two bytes.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D139871/new/

https://reviews.llvm.org/D139871



More information about the llvm-commits mailing list