diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td b/llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td --- a/llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td +++ b/llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td @@ -1165,7 +1165,11 @@ OutPatFrag<(ops node:$val), (EXTRACT_LANE_I64x2 (NARROW_U_I8x16 - (AND (SPLAT_I32x4 (CONST_I32 0x00ff00ff)), node:$val), + (AND + (CONST_V128_I16x8 + 0x00ff, 0x00ff, 0x00ff, 0x00ff, + 0x00ff, 0x00ff, 0x00ff, 0x00ff), + node:$val), $val), // Unused input 0)>; @@ -1173,7 +1177,10 @@ OutPatFrag<(ops node:$val), (EXTRACT_LANE_I64x2 (NARROW_U_I16x8 - (AND (SPLAT_I32x4 (CONST_I32 0x0000ffff)), node:$val), + (AND + (CONST_V128_I32x4 + 0x0000ffff, 0x0000ffff, 0x0000ffff, 0x0000ffff), + node:$val), $val), // Unused input 0)>; diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp --- a/llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp @@ -121,14 +121,9 @@ Type::getDoubleTy(MF.getFunction().getContext()))); MI->addOperand(MachineOperand::CreateFPImm(Val)); } else if (RegClass == &WebAssembly::V128RegClass) { - // TODO: Replace this with v128.const 0 once that is supported in V8 - Register TempReg = MRI.createVirtualRegister(&WebAssembly::I32RegClass); - MI->setDesc(TII->get(WebAssembly::SPLAT_I32x4)); - MI->addOperand(MachineOperand::CreateReg(TempReg, false)); - MachineInstr *Const = BuildMI(*MI->getParent(), MI, MI->getDebugLoc(), - TII->get(WebAssembly::CONST_I32), TempReg) - .addImm(0); - LIS.InsertMachineInstrInMaps(*Const); + MI->setDesc(TII->get(WebAssembly::CONST_V128_I64x2)); + MI->addOperand(MachineOperand::CreateImm(0)); + MI->addOperand(MachineOperand::CreateImm(0)); } else { llvm_unreachable("Unexpected reg class"); } diff --git a/llvm/test/CodeGen/WebAssembly/implicit-def.ll b/llvm/test/CodeGen/WebAssembly/implicit-def.ll --- a/llvm/test/CodeGen/WebAssembly/implicit-def.ll +++ b/llvm/test/CodeGen/WebAssembly/implicit-def.ll @@ -97,10 +97,7 @@ } ; CHECK-LABEL: implicit_def_v4i32: -; CHECK: i32.const $push{{[0-9]+}}=, 0{{$}} -; CHECK: i32.const $push{{[0-9]+}}=, 0{{$}} -; CHECK: i32.const $push[[L0:[0-9]+]]=, 0{{$}} -; CHECK-NEXT: i32x4.splat $push[[R:[0-9]+]]=, $pop[[L0]] +; CHECK: v128.const $push[[R:[0-9]+]]=, 0, 0{{$}} ; CHECK-NEXT: return $pop[[R]]{{$}} define <4 x i32> @implicit_def_v4i32() { br i1 undef, label %A, label %X diff --git a/llvm/test/CodeGen/WebAssembly/simd-offset.ll b/llvm/test/CodeGen/WebAssembly/simd-offset.ll --- a/llvm/test/CodeGen/WebAssembly/simd-offset.ll +++ b/llvm/test/CodeGen/WebAssembly/simd-offset.ll @@ -923,8 +923,7 @@ ; CHECK: .functype store_narrowing_v8i16 (v128, i32) -> () ; CHECK-NEXT: # %bb.0: ; CHECK-NEXT: local.get 1 -; CHECK-NEXT: i32.const 16711935 -; CHECK-NEXT: i32x4.splat +; CHECK-NEXT: v128.const 255, 255, 255, 255, 255, 255, 255, 255 ; CHECK-NEXT: local.get 0 ; CHECK-NEXT: v128.and ; CHECK-NEXT: local.get 0 @@ -956,8 +955,7 @@ ; CHECK: .functype store_narrowing_v8i16_with_folded_offset (v128, i32) -> () ; CHECK-NEXT: # %bb.0: ; CHECK-NEXT: local.get 1 -; CHECK-NEXT: i32.const 16711935 -; CHECK-NEXT: i32x4.splat +; CHECK-NEXT: v128.const 255, 255, 255, 255, 255, 255, 255, 255 ; CHECK-NEXT: local.get 0 ; CHECK-NEXT: v128.and ; CHECK-NEXT: local.get 0 @@ -990,8 +988,7 @@ ; CHECK: .functype store_narrowing_v8i16_with_folded_gep_offset (v128, i32) -> () ; CHECK-NEXT: # %bb.0: ; CHECK-NEXT: local.get 1 -; CHECK-NEXT: i32.const 16711935 -; CHECK-NEXT: i32x4.splat +; CHECK-NEXT: v128.const 255, 255, 255, 255, 255, 255, 255, 255 ; CHECK-NEXT: local.get 0 ; CHECK-NEXT: v128.and ; CHECK-NEXT: local.get 0 @@ -1026,8 +1023,7 @@ ; CHECK-NEXT: local.get 1 ; CHECK-NEXT: i32.const -8 ; CHECK-NEXT: i32.add -; CHECK-NEXT: i32.const 16711935 -; CHECK-NEXT: i32x4.splat +; CHECK-NEXT: v128.const 255, 255, 255, 255, 255, 255, 255, 255 ; CHECK-NEXT: local.get 0 ; CHECK-NEXT: v128.and ; CHECK-NEXT: local.get 0 @@ -1064,8 +1060,7 @@ ; CHECK-NEXT: local.get 1 ; CHECK-NEXT: i32.const 16 ; CHECK-NEXT: i32.add -; CHECK-NEXT: i32.const 16711935 -; CHECK-NEXT: i32x4.splat +; CHECK-NEXT: v128.const 255, 255, 255, 255, 255, 255, 255, 255 ; CHECK-NEXT: local.get 0 ; CHECK-NEXT: v128.and ; CHECK-NEXT: local.get 0 @@ -1102,8 +1097,7 @@ ; CHECK-NEXT: local.get 1 ; CHECK-NEXT: i32.const 8 ; CHECK-NEXT: i32.add -; CHECK-NEXT: i32.const 16711935 -; CHECK-NEXT: i32x4.splat +; CHECK-NEXT: v128.const 255, 255, 255, 255, 255, 255, 255, 255 ; CHECK-NEXT: local.get 0 ; CHECK-NEXT: v128.and ; CHECK-NEXT: local.get 0 @@ -1134,8 +1128,7 @@ ; CHECK: .functype store_narrowing_v8i16_to_numeric_address (v128, i32) -> () ; CHECK-NEXT: # %bb.0: ; CHECK-NEXT: i32.const 0 -; CHECK-NEXT: i32.const 16711935 -; CHECK-NEXT: i32x4.splat +; CHECK-NEXT: v128.const 255, 255, 255, 255, 255, 255, 255, 255 ; CHECK-NEXT: local.get 0 ; CHECK-NEXT: v128.and ; CHECK-NEXT: local.get 0 @@ -1165,8 +1158,7 @@ ; CHECK: .functype store_narrowing_v8i16_to_global_address (v128) -> () ; CHECK-NEXT: # %bb.0: ; CHECK-NEXT: i32.const 0 -; CHECK-NEXT: i32.const 16711935 -; CHECK-NEXT: i32x4.splat +; CHECK-NEXT: v128.const 255, 255, 255, 255, 255, 255, 255, 255 ; CHECK-NEXT: local.get 0 ; CHECK-NEXT: v128.and ; CHECK-NEXT: local.get 0 @@ -1753,8 +1745,7 @@ ; CHECK: .functype store_narrowing_v4i32 (v128, i32) -> () ; CHECK-NEXT: # %bb.0: ; CHECK-NEXT: local.get 1 -; CHECK-NEXT: i32.const 65535 -; CHECK-NEXT: i32x4.splat +; CHECK-NEXT: v128.const 65535, 65535, 65535, 65535 ; CHECK-NEXT: local.get 0 ; CHECK-NEXT: v128.and ; CHECK-NEXT: local.get 0 @@ -1786,8 +1777,7 @@ ; CHECK: .functype store_narrowing_v4i32_with_folded_offset (v128, i32) -> () ; CHECK-NEXT: # %bb.0: ; CHECK-NEXT: local.get 1 -; CHECK-NEXT: i32.const 65535 -; CHECK-NEXT: i32x4.splat +; CHECK-NEXT: v128.const 65535, 65535, 65535, 65535 ; CHECK-NEXT: local.get 0 ; CHECK-NEXT: v128.and ; CHECK-NEXT: local.get 0 @@ -1820,8 +1810,7 @@ ; CHECK: .functype store_narrowing_v4i32_with_folded_gep_offset (v128, i32) -> () ; CHECK-NEXT: # %bb.0: ; CHECK-NEXT: local.get 1 -; CHECK-NEXT: i32.const 65535 -; CHECK-NEXT: i32x4.splat +; CHECK-NEXT: v128.const 65535, 65535, 65535, 65535 ; CHECK-NEXT: local.get 0 ; CHECK-NEXT: v128.and ; CHECK-NEXT: local.get 0 @@ -1856,8 +1845,7 @@ ; CHECK-NEXT: local.get 1 ; CHECK-NEXT: i32.const -8 ; CHECK-NEXT: i32.add -; CHECK-NEXT: i32.const 65535 -; CHECK-NEXT: i32x4.splat +; CHECK-NEXT: v128.const 65535, 65535, 65535, 65535 ; CHECK-NEXT: local.get 0 ; CHECK-NEXT: v128.and ; CHECK-NEXT: local.get 0 @@ -1894,8 +1882,7 @@ ; CHECK-NEXT: local.get 1 ; CHECK-NEXT: i32.const 16 ; CHECK-NEXT: i32.add -; CHECK-NEXT: i32.const 65535 -; CHECK-NEXT: i32x4.splat +; CHECK-NEXT: v128.const 65535, 65535, 65535, 65535 ; CHECK-NEXT: local.get 0 ; CHECK-NEXT: v128.and ; CHECK-NEXT: local.get 0 @@ -1932,8 +1919,7 @@ ; CHECK-NEXT: local.get 1 ; CHECK-NEXT: i32.const 8 ; CHECK-NEXT: i32.add -; CHECK-NEXT: i32.const 65535 -; CHECK-NEXT: i32x4.splat +; CHECK-NEXT: v128.const 65535, 65535, 65535, 65535 ; CHECK-NEXT: local.get 0 ; CHECK-NEXT: v128.and ; CHECK-NEXT: local.get 0 @@ -1964,8 +1950,7 @@ ; CHECK: .functype store_narrowing_v4i32_to_numeric_address (v128) -> () ; CHECK-NEXT: # %bb.0: ; CHECK-NEXT: i32.const 0 -; CHECK-NEXT: i32.const 65535 -; CHECK-NEXT: i32x4.splat +; CHECK-NEXT: v128.const 65535, 65535, 65535, 65535 ; CHECK-NEXT: local.get 0 ; CHECK-NEXT: v128.and ; CHECK-NEXT: local.get 0 @@ -1995,8 +1980,7 @@ ; CHECK: .functype store_narrowing_v4i32_to_global_address (v128) -> () ; CHECK-NEXT: # %bb.0: ; CHECK-NEXT: i32.const 0 -; CHECK-NEXT: i32.const 65535 -; CHECK-NEXT: i32x4.splat +; CHECK-NEXT: v128.const 65535, 65535, 65535, 65535 ; CHECK-NEXT: local.get 0 ; CHECK-NEXT: v128.and ; CHECK-NEXT: local.get 0