@@ -197,23 +197,18 @@ void buildOpSpirvDecorations(Register Reg, MachineIRBuilder &MIRBuilder,
197197 report_fatal_error (" Expect SPIR-V <Decoration> operand to be the first "
198198 " element of the decoration" );
199199
200- // NoContraction decoration is deprecated by SPV_KHR_float_controls2, and
201- // should be replaced with FPFastMathMode with appropriate flags. However, a
202- // instruction can have both NoContraction and FPFastMathMode decorations,
203- // and there is no guarantee about the order in which we will encounter
204- // them, so we store the information of both and will handle them separately
205- // after the loop so that we can combine them, if needed.
206- if (ST.canUseExtension (SPIRV::Extension::SPV_KHR_float_controls2) &&
200+ // The goal of `spirv.Decorations` metadata is to provide a way to
201+ // represent SPIR-V entities that do not map to LLVM in an obvious way.
202+ // FP flags do have obvious matches between LLVM IR and SPIR-V.
203+ // Additionally, we have no guarantee at this point that the flags passed
204+ // through the decoration are not violated already in the optimizer passes.
205+ // Therefore, we simply ignore FP flags, including NoContraction, and
206+ // FPFastMathMode.
207+ if (DecorationId->getZExtValue () ==
208+ static_cast <uint32_t >(SPIRV::Decoration::NoContraction) ||
207209 DecorationId->getZExtValue () ==
208- static_cast <uint32_t >(SPIRV::Decoration::NoContraction)) {
209- NoContractionFound = true ;
210- continue ; // NoContraction is handled separately.
211- } else if (DecorationId->getZExtValue () ==
212- static_cast <uint32_t >(SPIRV::Decoration::FPFastMathMode)) {
213- FPFastMathModeFound = true ;
214- FPFastMathFlags = mdconst::dyn_extract<ConstantInt>(OpMD->getOperand (1 ))
215- ->getZExtValue ();
216- continue ; // FPFastMathMode is handled separately.
210+ static_cast <uint32_t >(SPIRV::Decoration::FPFastMathMode)) {
211+ continue ; // Ignored.
217212 }
218213 auto MIB = MIRBuilder.buildInstr (SPIRV::OpDecorate)
219214 .addUse (Reg)
@@ -228,20 +223,6 @@ void buildOpSpirvDecorations(Register Reg, MachineIRBuilder &MIRBuilder,
228223 report_fatal_error (" Unexpected operand of the decoration" );
229224 }
230225 }
231- // If we have NoContraction decoration, we should set the
232- // FPFastMathMode::AllowContract bit to 0. If it has been set to 1 by
233- // FPFastMathMode decoration, we should report an error.
234- if (NoContractionFound &&
235- (FPFastMathFlags & SPIRV::FPFastMathMode::AllowContract))
236- report_fatal_error (
237- " Conflicting FPFastMathFlags: NoContraction and AllowContract" );
238-
239- if (NoContractionFound || FPFastMathModeFound) {
240- MIRBuilder.buildInstr (SPIRV::OpDecorate)
241- .addUse (Reg)
242- .addImm (static_cast <uint32_t >(SPIRV::Decoration::FPFastMathMode))
243- .addImm (FPFastMathFlags);
244- }
245226}
246227
247228MachineBasicBlock::iterator getOpVariableMBBIt (MachineInstr &I) {
0 commit comments