Skip to content

Commit 8da4bd5

Browse files
tlivelynikic
authored andcommitted
[WebAssembly] Remove experimental SIMD instructions
Removes the instruction definitions, intrinsics, and builtins for qfma/qfms, signselect, and prefetch instructions, which were not included in the final WebAssembly SIMD spec. Depends on D98457. Differential Revision: https://reviews.llvm.org/D98466
1 parent ced1750 commit 8da4bd5

File tree

10 files changed

+0
-688
lines changed

10 files changed

+0
-688
lines changed

clang/include/clang/Basic/BuiltinsWebAssembly.def

-16
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,6 @@ TARGET_BUILTIN(__builtin_wasm_extadd_pairwise_i16x8_u_i32x4, "V4UiV8Us", "nc", "
141141

142142
TARGET_BUILTIN(__builtin_wasm_bitselect, "V4iV4iV4iV4i", "nc", "simd128")
143143

144-
TARGET_BUILTIN(__builtin_wasm_signselect_i8x16, "V16ScV16ScV16ScV16Sc", "nc", "simd128")
145-
TARGET_BUILTIN(__builtin_wasm_signselect_i16x8, "V8sV8sV8sV8s", "nc", "simd128")
146-
TARGET_BUILTIN(__builtin_wasm_signselect_i32x4, "V4iV4iV4iV4i", "nc", "simd128")
147-
TARGET_BUILTIN(__builtin_wasm_signselect_i64x2, "V2LLiV2LLiV2LLiV2LLi", "nc", "simd128")
148-
149144
TARGET_BUILTIN(__builtin_wasm_shuffle_v8x16, "V16ScV16ScV16ScIiIiIiIiIiIiIiIiIiIiIiIiIiIiIiIi", "nc", "simd128")
150145

151146
TARGET_BUILTIN(__builtin_wasm_any_true_i8x16, "iV16Sc", "nc", "simd128")
@@ -188,11 +183,6 @@ TARGET_BUILTIN(__builtin_wasm_dot_s_i32x4_i16x8, "V4iV8sV8s", "nc", "simd128")
188183
TARGET_BUILTIN(__builtin_wasm_sqrt_f32x4, "V4fV4f", "nc", "simd128")
189184
TARGET_BUILTIN(__builtin_wasm_sqrt_f64x2, "V2dV2d", "nc", "simd128")
190185

191-
TARGET_BUILTIN(__builtin_wasm_qfma_f32x4, "V4fV4fV4fV4f", "nc", "simd128")
192-
TARGET_BUILTIN(__builtin_wasm_qfms_f32x4, "V4fV4fV4fV4f", "nc", "simd128")
193-
TARGET_BUILTIN(__builtin_wasm_qfma_f64x2, "V2dV2dV2dV2d", "nc", "simd128")
194-
TARGET_BUILTIN(__builtin_wasm_qfms_f64x2, "V2dV2dV2dV2d", "nc", "simd128")
195-
196186
TARGET_BUILTIN(__builtin_wasm_trunc_saturate_s_i32x4_f32x4, "V4iV4f", "nc", "simd128")
197187
TARGET_BUILTIN(__builtin_wasm_trunc_saturate_u_i32x4_f32x4, "V4iV4f", "nc", "simd128")
198188

@@ -206,9 +196,6 @@ TARGET_BUILTIN(__builtin_wasm_widen_high_s_i32x4_i64x2, "V2LLiV4i", "nc", "simd1
206196
TARGET_BUILTIN(__builtin_wasm_widen_low_u_i32x4_i64x2, "V2LLUiV4Ui", "nc", "simd128")
207197
TARGET_BUILTIN(__builtin_wasm_widen_high_u_i32x4_i64x2, "V2LLUiV4Ui", "nc", "simd128")
208198

209-
TARGET_BUILTIN(__builtin_wasm_widen_s_i8x16_i32x4, "V4iV16ScIi", "nc", "simd128")
210-
TARGET_BUILTIN(__builtin_wasm_widen_u_i8x16_i32x4, "V4UiV16UcIi", "nc", "simd128")
211-
212199
TARGET_BUILTIN(__builtin_wasm_convert_low_s_i32x4_f64x2, "V2dV4i", "nc", "simd128")
213200
TARGET_BUILTIN(__builtin_wasm_convert_low_u_i32x4_f64x2, "V2dV4Ui", "nc", "simd128")
214201
TARGET_BUILTIN(__builtin_wasm_trunc_saturate_zero_s_f64x2_i32x4, "V4iV2d", "nc", "simd128")
@@ -230,8 +217,5 @@ TARGET_BUILTIN(__builtin_wasm_store64_lane, "vLLi*V2LLiIi", "n", "simd128")
230217

231218
TARGET_BUILTIN(__builtin_wasm_eq_i64x2, "V2LLiV2LLiV2LLi", "nc", "simd128")
232219

233-
TARGET_BUILTIN(__builtin_wasm_prefetch_t, "vv*", "n", "simd128")
234-
TARGET_BUILTIN(__builtin_wasm_prefetch_nt, "vv*", "n", "simd128")
235-
236220
#undef BUILTIN
237221
#undef TARGET_BUILTIN

clang/lib/CodeGen/CGBuiltin.cpp

-62
Original file line numberDiff line numberDiff line change
@@ -17075,17 +17075,6 @@ Value *CodeGenFunction::EmitWebAssemblyBuiltinExpr(unsigned BuiltinID,
1707517075
CGM.getIntrinsic(Intrinsic::wasm_bitselect, ConvertType(E->getType()));
1707617076
return Builder.CreateCall(Callee, {V1, V2, C});
1707717077
}
17078-
case WebAssembly::BI__builtin_wasm_signselect_i8x16:
17079-
case WebAssembly::BI__builtin_wasm_signselect_i16x8:
17080-
case WebAssembly::BI__builtin_wasm_signselect_i32x4:
17081-
case WebAssembly::BI__builtin_wasm_signselect_i64x2: {
17082-
Value *V1 = EmitScalarExpr(E->getArg(0));
17083-
Value *V2 = EmitScalarExpr(E->getArg(1));
17084-
Value *C = EmitScalarExpr(E->getArg(2));
17085-
Function *Callee =
17086-
CGM.getIntrinsic(Intrinsic::wasm_signselect, ConvertType(E->getType()));
17087-
return Builder.CreateCall(Callee, {V1, V2, C});
17088-
}
1708917078
case WebAssembly::BI__builtin_wasm_dot_s_i32x4_i16x8: {
1709017079
Value *LHS = EmitScalarExpr(E->getArg(0));
1709117080
Value *RHS = EmitScalarExpr(E->getArg(1));
@@ -17153,29 +17142,6 @@ Value *CodeGenFunction::EmitWebAssemblyBuiltinExpr(unsigned BuiltinID,
1715317142
Function *Callee = CGM.getIntrinsic(Intrinsic::sqrt, Vec->getType());
1715417143
return Builder.CreateCall(Callee, {Vec});
1715517144
}
17156-
case WebAssembly::BI__builtin_wasm_qfma_f32x4:
17157-
case WebAssembly::BI__builtin_wasm_qfms_f32x4:
17158-
case WebAssembly::BI__builtin_wasm_qfma_f64x2:
17159-
case WebAssembly::BI__builtin_wasm_qfms_f64x2: {
17160-
Value *A = EmitScalarExpr(E->getArg(0));
17161-
Value *B = EmitScalarExpr(E->getArg(1));
17162-
Value *C = EmitScalarExpr(E->getArg(2));
17163-
unsigned IntNo;
17164-
switch (BuiltinID) {
17165-
case WebAssembly::BI__builtin_wasm_qfma_f32x4:
17166-
case WebAssembly::BI__builtin_wasm_qfma_f64x2:
17167-
IntNo = Intrinsic::wasm_qfma;
17168-
break;
17169-
case WebAssembly::BI__builtin_wasm_qfms_f32x4:
17170-
case WebAssembly::BI__builtin_wasm_qfms_f64x2:
17171-
IntNo = Intrinsic::wasm_qfms;
17172-
break;
17173-
default:
17174-
llvm_unreachable("unexpected builtin ID");
17175-
}
17176-
Function *Callee = CGM.getIntrinsic(IntNo, A->getType());
17177-
return Builder.CreateCall(Callee, {A, B, C});
17178-
}
1717917145
case WebAssembly::BI__builtin_wasm_narrow_s_i8x16_i16x8:
1718017146
case WebAssembly::BI__builtin_wasm_narrow_u_i8x16_i16x8:
1718117147
case WebAssembly::BI__builtin_wasm_narrow_s_i16x8_i32x4:
@@ -17222,24 +17188,6 @@ Value *CodeGenFunction::EmitWebAssemblyBuiltinExpr(unsigned BuiltinID,
1722217188
Function *Callee = CGM.getIntrinsic(IntNo);
1722317189
return Builder.CreateCall(Callee, Vec);
1722417190
}
17225-
case WebAssembly::BI__builtin_wasm_widen_s_i8x16_i32x4:
17226-
case WebAssembly::BI__builtin_wasm_widen_u_i8x16_i32x4: {
17227-
Value *Vec = EmitScalarExpr(E->getArg(0));
17228-
llvm::APSInt SubVecConst =
17229-
*E->getArg(1)->getIntegerConstantExpr(getContext());
17230-
Value *SubVec = llvm::ConstantInt::get(getLLVMContext(), SubVecConst);
17231-
unsigned IntNo;
17232-
switch (BuiltinID) {
17233-
case WebAssembly::BI__builtin_wasm_widen_s_i8x16_i32x4:
17234-
IntNo = Intrinsic::wasm_widen_signed;
17235-
break;
17236-
case WebAssembly::BI__builtin_wasm_widen_u_i8x16_i32x4:
17237-
IntNo = Intrinsic::wasm_widen_unsigned;
17238-
break;
17239-
}
17240-
Function *Callee = CGM.getIntrinsic(IntNo);
17241-
return Builder.CreateCall(Callee, {Vec, SubVec});
17242-
}
1724317191
case WebAssembly::BI__builtin_wasm_convert_low_s_i32x4_f64x2:
1724417192
case WebAssembly::BI__builtin_wasm_convert_low_u_i32x4_f64x2: {
1724517193
Value *Vec = EmitScalarExpr(E->getArg(0));
@@ -17350,16 +17298,6 @@ Value *CodeGenFunction::EmitWebAssemblyBuiltinExpr(unsigned BuiltinID,
1735017298
Function *Callee = CGM.getIntrinsic(Intrinsic::wasm_shuffle);
1735117299
return Builder.CreateCall(Callee, Ops);
1735217300
}
17353-
case WebAssembly::BI__builtin_wasm_prefetch_t: {
17354-
Value *Ptr = EmitScalarExpr(E->getArg(0));
17355-
Function *Callee = CGM.getIntrinsic(Intrinsic::wasm_prefetch_t);
17356-
return Builder.CreateCall(Callee, Ptr);
17357-
}
17358-
case WebAssembly::BI__builtin_wasm_prefetch_nt: {
17359-
Value *Ptr = EmitScalarExpr(E->getArg(0));
17360-
Function *Callee = CGM.getIntrinsic(Intrinsic::wasm_prefetch_nt);
17361-
return Builder.CreateCall(Callee, Ptr);
17362-
}
1736317301
default:
1736417302
return nullptr;
1736517303
}

clang/test/CodeGen/builtins-wasm.c

-78
Original file line numberDiff line numberDiff line change
@@ -644,34 +644,6 @@ i32x4 bitselect(i32x4 x, i32x4 y, i32x4 c) {
644644
// WEBASSEMBLY-NEXT: ret
645645
}
646646

647-
i8x16 signselect_i8x16(i8x16 x, i8x16 y, i8x16 c) {
648-
return __builtin_wasm_signselect_i8x16(x, y, c);
649-
// WEBASSEMBLY: call <16 x i8> @llvm.wasm.signselect.v16i8(
650-
// WEBASSEMBLY-SAME: <16 x i8> %x, <16 x i8> %y, <16 x i8> %c)
651-
// WEBASSEMBLY-NEXT: ret
652-
}
653-
654-
i16x8 signselect_i16x8(i16x8 x, i16x8 y, i16x8 c) {
655-
return __builtin_wasm_signselect_i16x8(x, y, c);
656-
// WEBASSEMBLY: call <8 x i16> @llvm.wasm.signselect.v8i16(
657-
// WEBASSEMBLY-SAME: <8 x i16> %x, <8 x i16> %y, <8 x i16> %c)
658-
// WEBASSEMBLY-NEXT: ret
659-
}
660-
661-
i32x4 signselect_i32x4(i32x4 x, i32x4 y, i32x4 c) {
662-
return __builtin_wasm_signselect_i32x4(x, y, c);
663-
// WEBASSEMBLY: call <4 x i32> @llvm.wasm.signselect.v4i32(
664-
// WEBASSEMBLY-SAME: <4 x i32> %x, <4 x i32> %y, <4 x i32> %c)
665-
// WEBASSEMBLY-NEXT: ret
666-
}
667-
668-
i64x2 signselect_i64x2(i64x2 x, i64x2 y, i64x2 c) {
669-
return __builtin_wasm_signselect_i64x2(x, y, c);
670-
// WEBASSEMBLY: call <2 x i64> @llvm.wasm.signselect.v2i64(
671-
// WEBASSEMBLY-SAME: <2 x i64> %x, <2 x i64> %y, <2 x i64> %c)
672-
// WEBASSEMBLY-NEXT: ret
673-
}
674-
675647
i8x16 popcnt(i8x16 x) {
676648
return __builtin_wasm_popcnt_i8x16(x);
677649
// WEBASSEMBLY: call <16 x i8> @llvm.wasm.popcnt(<16 x i8> %x)
@@ -884,34 +856,6 @@ f64x2 sqrt_f64x2(f64x2 x) {
884856
// WEBASSEMBLY: ret
885857
}
886858

887-
f32x4 qfma_f32x4(f32x4 a, f32x4 b, f32x4 c) {
888-
return __builtin_wasm_qfma_f32x4(a, b, c);
889-
// WEBASSEMBLY: call <4 x float> @llvm.wasm.qfma.v4f32(
890-
// WEBASSEMBLY-SAME: <4 x float> %a, <4 x float> %b, <4 x float> %c)
891-
// WEBASSEMBLY-NEXT: ret
892-
}
893-
894-
f32x4 qfms_f32x4(f32x4 a, f32x4 b, f32x4 c) {
895-
return __builtin_wasm_qfms_f32x4(a, b, c);
896-
// WEBASSEMBLY: call <4 x float> @llvm.wasm.qfms.v4f32(
897-
// WEBASSEMBLY-SAME: <4 x float> %a, <4 x float> %b, <4 x float> %c)
898-
// WEBASSEMBLY-NEXT: ret
899-
}
900-
901-
f64x2 qfma_f64x2(f64x2 a, f64x2 b, f64x2 c) {
902-
return __builtin_wasm_qfma_f64x2(a, b, c);
903-
// WEBASSEMBLY: call <2 x double> @llvm.wasm.qfma.v2f64(
904-
// WEBASSEMBLY-SAME: <2 x double> %a, <2 x double> %b, <2 x double> %c)
905-
// WEBASSEMBLY-NEXT: ret
906-
}
907-
908-
f64x2 qfms_f64x2(f64x2 a, f64x2 b, f64x2 c) {
909-
return __builtin_wasm_qfms_f64x2(a, b, c);
910-
// WEBASSEMBLY: call <2 x double> @llvm.wasm.qfms.v2f64(
911-
// WEBASSEMBLY-SAME: <2 x double> %a, <2 x double> %b, <2 x double> %c)
912-
// WEBASSEMBLY-NEXT: ret
913-
}
914-
915859
i32x4 trunc_saturate_s_i32x4_f32x4(f32x4 f) {
916860
return __builtin_wasm_trunc_saturate_s_i32x4_f32x4(f);
917861
// WEBASSEMBLY: call <4 x i32> @llvm.wasm.trunc.saturate.signed.v4i32.v4f32(<4 x float> %f)
@@ -976,18 +920,6 @@ u64x2 widen_high_u_i32x4_i64x2(u32x4 x) {
976920
// WEBASSEMBLY: ret
977921
}
978922

979-
i32x4 widen_s_i8x16_i32x4(i8x16 x) {
980-
return __builtin_wasm_widen_s_i8x16_i32x4(x, 3);
981-
// WEBASSEMBLY: call <4 x i32> @llvm.wasm.widen.signed(<16 x i8> %x, i32 3)
982-
// WEBASSEMBLY: ret
983-
}
984-
985-
u32x4 widen_u_i8x16_i32x4(u8x16 x) {
986-
return __builtin_wasm_widen_u_i8x16_i32x4(x, 3);
987-
// WEBASSEMBLY: call <4 x i32> @llvm.wasm.widen.unsigned(<16 x i8> %x, i32 3)
988-
// WEBASSEMBLY: ret
989-
}
990-
991923
f64x2 convert_low_s_i32x4_f64x2(i32x4 x) {
992924
return __builtin_wasm_convert_low_s_i32x4_f64x2(x);
993925
// WEBASSEMBLY: call <2 x double> @llvm.wasm.convert.low.signed(<4 x i32> %x)
@@ -1050,13 +982,3 @@ i8x16 shuffle(i8x16 x, i8x16 y) {
1050982
// WEBASSEMBLY-SAME: i32 15
1051983
// WEBASSEMBLY-NEXT: ret
1052984
}
1053-
1054-
void prefetch_t(void *p) {
1055-
return __builtin_wasm_prefetch_t(p);
1056-
// WEBASSEMBLY: call void @llvm.wasm.prefetch.t(i8* %p)
1057-
}
1058-
1059-
void prefetch_nt(void *p) {
1060-
return __builtin_wasm_prefetch_nt(p);
1061-
// WEBASSEMBLY: call void @llvm.wasm.prefetch.nt(i8* %p)
1062-
}

llvm/include/llvm/IR/IntrinsicsWebAssembly.td

-35
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,6 @@ def int_wasm_bitmask :
143143
Intrinsic<[llvm_i32_ty],
144144
[llvm_anyvector_ty],
145145
[IntrNoMem, IntrSpeculatable]>;
146-
def int_wasm_qfma :
147-
Intrinsic<[llvm_anyvector_ty],
148-
[LLVMMatchType<0>, LLVMMatchType<0>, LLVMMatchType<0>],
149-
[IntrNoMem, IntrSpeculatable]>;
150-
def int_wasm_qfms :
151-
Intrinsic<[llvm_anyvector_ty],
152-
[LLVMMatchType<0>, LLVMMatchType<0>, LLVMMatchType<0>],
153-
[IntrNoMem, IntrSpeculatable]>;
154146
def int_wasm_dot :
155147
Intrinsic<[llvm_v4i32_ty],
156148
[llvm_v8i16_ty, llvm_v8i16_ty],
@@ -302,32 +294,13 @@ def int_wasm_extadd_pairwise_unsigned :
302294
[LLVMSubdivide2VectorType<0>],
303295
[IntrNoMem, IntrSpeculatable]>;
304296

305-
def int_wasm_signselect :
306-
Intrinsic<[llvm_anyvector_ty],
307-
[LLVMMatchType<0>, LLVMMatchType<0>, LLVMMatchType<0>],
308-
[IntrNoMem, IntrSpeculatable]>;
309-
310297
// TODO: Remove this intrinsic and the associated builtin if i64x2.eq gets
311298
// merged to the proposal.
312299
def int_wasm_eq :
313300
Intrinsic<[llvm_v2i64_ty],
314301
[llvm_v2i64_ty, llvm_v2i64_ty],
315302
[IntrNoMem, IntrSpeculatable]>;
316303

317-
// TODO: Remove this after experiments have been run. Use the target-agnostic
318-
// int_prefetch if this becomes specified at some point.
319-
def int_wasm_prefetch_t :
320-
Intrinsic<[], [llvm_ptr_ty],
321-
[IntrInaccessibleMemOrArgMemOnly, IntrWillReturn,
322-
ReadOnly<ArgIndex<0>>, NoCapture<ArgIndex<0>>],
323-
"", [SDNPMemOperand]>;
324-
325-
def int_wasm_prefetch_nt :
326-
Intrinsic<[], [llvm_ptr_ty],
327-
[IntrInaccessibleMemOrArgMemOnly, IntrWillReturn,
328-
ReadOnly<ArgIndex<0>>, NoCapture<ArgIndex<0>>],
329-
"", [SDNPMemOperand]>;
330-
331304
// TODO: Remove these if possible if they are merged to the spec.
332305
def int_wasm_convert_low_signed :
333306
Intrinsic<[llvm_v2f64_ty], [llvm_v4i32_ty],
@@ -348,14 +321,6 @@ def int_wasm_promote_low :
348321
Intrinsic<[llvm_v2f64_ty], [llvm_v4f32_ty],
349322
[IntrNoMem, IntrSpeculatable]>;
350323

351-
// TODO: Remove these if possible if they are merged to the spec.
352-
def int_wasm_widen_signed :
353-
Intrinsic<[llvm_v4i32_ty], [llvm_v16i8_ty, llvm_i32_ty],
354-
[IntrNoMem, IntrSpeculatable, ImmArg<ArgIndex<1>>]>;
355-
def int_wasm_widen_unsigned :
356-
Intrinsic<[llvm_v4i32_ty], [llvm_v16i8_ty, llvm_i32_ty],
357-
[IntrNoMem, IntrSpeculatable, ImmArg<ArgIndex<1>>]>;
358-
359324
//===----------------------------------------------------------------------===//
360325
// Thread-local storage intrinsics
361326
//===----------------------------------------------------------------------===//

llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.h

-2
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,6 @@ inline unsigned GetDefaultP2AlignAny(unsigned Opc) {
196196
WASM_LOAD_STORE(LOAD8_SPLAT)
197197
WASM_LOAD_STORE(LOAD_LANE_I8x16)
198198
WASM_LOAD_STORE(STORE_LANE_I8x16)
199-
WASM_LOAD_STORE(PREFETCH_T)
200-
WASM_LOAD_STORE(PREFETCH_NT)
201199
return 0;
202200
WASM_LOAD_STORE(LOAD16_S_I32)
203201
WASM_LOAD_STORE(LOAD16_U_I32)

llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp

-10
Original file line numberDiff line numberDiff line change
@@ -757,16 +757,6 @@ bool WebAssemblyTargetLowering::getTgtMemIntrinsic(IntrinsicInfo &Info,
757757
Info.align = MemAlign;
758758
return true;
759759
}
760-
case Intrinsic::wasm_prefetch_t:
761-
case Intrinsic::wasm_prefetch_nt: {
762-
Info.opc = ISD::INTRINSIC_VOID;
763-
Info.memVT = MVT::i8;
764-
Info.ptrVal = I.getArgOperand(0);
765-
Info.offset = 0;
766-
Info.align = Align(1);
767-
Info.flags = MachineMemOperand::MOLoad;
768-
return true;
769-
}
770760
default:
771761
return false;
772762
}

0 commit comments

Comments
 (0)