@@ -121,7 +121,10 @@ WebAssemblyTargetLowering::WebAssemblyTargetLowering(
121121 setOperationAction (ISD::VACOPY, MVT::Other, Expand);
122122 setOperationAction (ISD::VAEND, MVT::Other, Expand);
123123
124- for (auto T : {MVT::f32 , MVT::f64 , MVT::v4f32, MVT::v2f64}) {
124+ for (auto T : {MVT::f32 , MVT::f64 , MVT::v4f32, MVT::v2f64, MVT::v8f16}) {
125+ if (!Subtarget->hasFP16 () && T == MVT::v8f16) {
126+ continue ;
127+ }
125128 // Don't expand the floating-point types to constant pools.
126129 setOperationAction (ISD::ConstantFP, T, Legal);
127130 // Expand floating-point comparisons.
@@ -140,18 +143,16 @@ WebAssemblyTargetLowering::WebAssemblyTargetLowering(
140143 // Support minimum and maximum, which otherwise default to expand.
141144 setOperationAction (ISD::FMINIMUM, T, Legal);
142145 setOperationAction (ISD::FMAXIMUM, T, Legal);
143- // WebAssembly currently has no builtin f16 support.
144- setOperationAction (ISD::FP16_TO_FP, T, Expand);
145- setOperationAction (ISD::FP_TO_FP16, T, Expand);
146+ // When experimental v8f16 support is enabled these instructions don't need
147+ // to be expanded.
148+ if (T != MVT::v8f16) {
149+ setOperationAction (ISD::FP16_TO_FP, T, Expand);
150+ setOperationAction (ISD::FP_TO_FP16, T, Expand);
151+ }
146152 setLoadExtAction (ISD::EXTLOAD, T, MVT::f16 , Expand);
147153 setTruncStoreAction (T, MVT::f16 , Expand);
148154 }
149155
150- if (Subtarget->hasFP16 ()) {
151- setOperationAction (ISD::FMINIMUM, MVT::v8f16, Legal);
152- setOperationAction (ISD::FMAXIMUM, MVT::v8f16, Legal);
153- }
154-
155156 // Expand unavailable integer operations.
156157 for (auto Op :
157158 {ISD::BSWAP, ISD::SMUL_LOHI, ISD::UMUL_LOHI, ISD::MULHS, ISD::MULHU,
0 commit comments