@@ -2094,25 +2094,24 @@ static unsigned getFastMathFlags(const MachineInstr &I,
20942094
20952095 if (CanUseKHRFloatControls2) {
20962096 // Error out if SPIRV::FPFastMathMode::Fast is enabled.
2097- if (Flags & SPIRV::FPFastMathMode::Fast)
2098- report_fatal_error (
2099- " FPFastMathMode::Fast flag is deprecated and it is not "
2100- " valid to use anymore." );
2097+ assert (!(Flags & SPIRV::FPFastMathMode::Fast) &&
2098+ " SPIRV::FPFastMathMode::Fast is deprecated and should not be used "
2099+ " anymore." );
21012100
21022101 // Error out if AllowTransform is enabled without AllowReassoc and
21032102 // AllowContract.
2104- if ((Flags & SPIRV::FPFastMathMode::AllowTransform) &&
2105- ( !(Flags & SPIRV::FPFastMathMode::AllowReassoc ) ||
2106- !( Flags & SPIRV::FPFastMathMode::AllowContract)))
2107- report_fatal_error (
2108- " FPFastMathMode::AllowTransform flag requires AllowReassoc and "
2109- " AllowContract flags to be enabled as well." );
2103+ assert (
2104+ !(Flags & SPIRV::FPFastMathMode::AllowTransform ) ||
2105+ (( Flags & SPIRV::FPFastMathMode::AllowReassoc &&
2106+ Flags & SPIRV::FPFastMathMode::AllowContract)) &&
2107+ " SPIRV:: FPFastMathMode::AllowTransform requires AllowReassoc and "
2108+ " AllowContract flags to be enabled as well." );
21102109 }
21112110
21122111 return Flags;
21132112}
21142113
2115- static bool isFastMathMathModeAvailable (const SPIRVSubtarget &ST) {
2114+ static bool isFastMathModeAvailable (const SPIRVSubtarget &ST) {
21162115 if (ST.isKernel ())
21172116 return true ;
21182117 if (ST.getSPIRVVersion () < VersionTuple (1 , 2 ))
@@ -2123,7 +2122,7 @@ static bool isFastMathMathModeAvailable(const SPIRVSubtarget &ST) {
21232122static void handleMIFlagDecoration (
21242123 MachineInstr &I, const SPIRVSubtarget &ST, const SPIRVInstrInfo &TII,
21252124 SPIRV::RequirementHandler &Reqs, const SPIRVGlobalRegistry *GR,
2126- SmallVector<SPIRV::FPFastMathDefaultInfo, 4 > &FPFastMathDefaultInfoVec) {
2125+ SmallVector<SPIRV::FPFastMathDefaultInfo, 3 > &FPFastMathDefaultInfoVec) {
21272126 if (I.getFlag (MachineInstr::MIFlag::NoSWrap) && TII.canUseNSW (I) &&
21282127 getSymbolicOperandRequirements (SPIRV::OperandCategory::DecorationOperand,
21292128 SPIRV::Decoration::NoSignedWrap, ST, Reqs)
@@ -2184,7 +2183,7 @@ static void handleMIFlagDecoration(
21842183 if (FMFlags == SPIRV::FPFastMathMode::None && !Emit)
21852184 return ;
21862185 }
2187- if (isFastMathMathModeAvailable (ST)) {
2186+ if (isFastMathModeAvailable (ST)) {
21882187 Register DstReg = I.getOperand (0 ).getReg ();
21892188 buildOpDecorate (DstReg, I, TII, SPIRV::Decoration::FPFastMathMode,
21902189 {FMFlags});
@@ -2250,7 +2249,7 @@ static void patchPhis(const Module &M, SPIRVGlobalRegistry *GR,
22502249 }
22512250}
22522251
2253- static SmallVector<SPIRV::FPFastMathDefaultInfo, 4 > &
2252+ static SmallVector<SPIRV::FPFastMathDefaultInfo, 3 > &
22542253getOrCreateFPFastMathDefaultInfoVec (const Module &M,
22552254 SPIRV::ModuleAnalysisInfo &MAI,
22562255 const Function *F) {
@@ -2259,29 +2258,27 @@ getOrCreateFPFastMathDefaultInfoVec(const Module &M,
22592258 return it->second ;
22602259
22612260 // If the map does not contain the entry, create a new one. Initialize it to
2262- // contain all 4 elements sorted by bit width of target type: {half, float,
2263- // double, fp128 }.
2264- SmallVector<SPIRV::FPFastMathDefaultInfo, 4 > FPFastMathDefaultInfoVec;
2261+ // contain all 3 elements sorted by bit width of target type: {half, float,
2262+ // double}.
2263+ SmallVector<SPIRV::FPFastMathDefaultInfo, 3 > FPFastMathDefaultInfoVec;
22652264 FPFastMathDefaultInfoVec.emplace_back (Type::getHalfTy (M.getContext ()),
22662265 SPIRV::FPFastMathMode::None);
22672266 FPFastMathDefaultInfoVec.emplace_back (Type::getFloatTy (M.getContext ()),
22682267 SPIRV::FPFastMathMode::None);
22692268 FPFastMathDefaultInfoVec.emplace_back (Type::getDoubleTy (M.getContext ()),
22702269 SPIRV::FPFastMathMode::None);
2271- FPFastMathDefaultInfoVec.emplace_back (Type::getFP128Ty (M.getContext ()),
2272- SPIRV::FPFastMathMode::None);
22732270 return MAI.FPFastMathDefaultInfoMap [F] = std::move (FPFastMathDefaultInfoVec);
22742271}
22752272
22762273static SPIRV::FPFastMathDefaultInfo &getFPFastMathDefaultInfo (
2277- SmallVector<SPIRV::FPFastMathDefaultInfo, 4 > &FPFastMathDefaultInfoVec,
2274+ SmallVector<SPIRV::FPFastMathDefaultInfo, 3 > &FPFastMathDefaultInfoVec,
22782275 const Type *Ty) {
22792276 size_t BitWidth = Ty->getScalarSizeInBits ();
22802277 int Index = computeFPFastMathDefaultInfoVecIndex (BitWidth);
2281- assert (Index >= 0 && Index < 4 &&
2282- " Expected FPFastMathDefaultInfo for half, float, double, or fp128 " );
2283- assert (FPFastMathDefaultInfoVec.size () == 4 &&
2284- " Expected FPFastMathDefaultInfoVec to have exactly 4 elements" );
2278+ assert (Index >= 0 && Index < 3 &&
2279+ " Expected FPFastMathDefaultInfo for half, float, or double " );
2280+ assert (FPFastMathDefaultInfoVec.size () == 3 &&
2281+ " Expected FPFastMathDefaultInfoVec to have exactly 3 elements" );
22852282 return FPFastMathDefaultInfoVec[Index];
22862283}
22872284
@@ -2317,7 +2314,7 @@ static void collectFPFastMathDefaults(const Module &M,
23172314 cast<ConstantInt>(
23182315 cast<ConstantAsMetadata>(MDN->getOperand (3 ))->getValue ())
23192316 ->getZExtValue ();
2320- SmallVector<SPIRV::FPFastMathDefaultInfo, 4 > &FPFastMathDefaultInfoVec =
2317+ SmallVector<SPIRV::FPFastMathDefaultInfo, 3 > &FPFastMathDefaultInfoVec =
23212318 getOrCreateFPFastMathDefaultInfoVec (M, MAI, F);
23222319 SPIRV::FPFastMathDefaultInfo &Info =
23232320 getFPFastMathDefaultInfo (FPFastMathDefaultInfoVec, T);
@@ -2329,7 +2326,7 @@ static void collectFPFastMathDefaults(const Module &M,
23292326
23302327 // We need to save this info for every possible FP type, i.e. {half,
23312328 // float, double, fp128}.
2332- SmallVector<SPIRV::FPFastMathDefaultInfo, 4 > &FPFastMathDefaultInfoVec =
2329+ SmallVector<SPIRV::FPFastMathDefaultInfo, 3 > &FPFastMathDefaultInfoVec =
23332330 getOrCreateFPFastMathDefaultInfoVec (M, MAI, F);
23342331 for (SPIRV::FPFastMathDefaultInfo &Info : FPFastMathDefaultInfoVec) {
23352332 Info.ContractionOff = true ;
@@ -2342,14 +2339,13 @@ static void collectFPFastMathDefaults(const Module &M,
23422339 cast<ConstantAsMetadata>(MDN->getOperand (2 ))->getValue ())
23432340 ->getZExtValue ();
23442341 // We need to save this info only for the FP type with TargetWidth.
2345- SmallVector<SPIRV::FPFastMathDefaultInfo, 4 > &FPFastMathDefaultInfoVec =
2342+ SmallVector<SPIRV::FPFastMathDefaultInfo, 3 > &FPFastMathDefaultInfoVec =
23462343 getOrCreateFPFastMathDefaultInfoVec (M, MAI, F);
23472344 int Index = computeFPFastMathDefaultInfoVecIndex (TargetWidth);
2348- assert (Index >= 0 && Index < 4 &&
2349- " Expected FPFastMathDefaultInfo for half, float, double, or "
2350- " fp128" );
2351- assert (FPFastMathDefaultInfoVec.size () == 4 &&
2352- " Expected FPFastMathDefaultInfoVec to have exactly 4 elements" );
2345+ assert (Index >= 0 && Index < 3 &&
2346+ " Expected FPFastMathDefaultInfo for half, float, or double" );
2347+ assert (FPFastMathDefaultInfoVec.size () == 3 &&
2348+ " Expected FPFastMathDefaultInfoVec to have exactly 3 elements" );
23532349 FPFastMathDefaultInfoVec[Index].SignedZeroInfNanPreserve = true ;
23542350 }
23552351 }
0 commit comments