[llvm] [SPIR-V] Implement SPV_KHR_float_controls2 (PR #146941)

Nathan Gauër via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 9 02:55:52 PDT 2025


================
@@ -159,6 +186,13 @@ struct ModuleAnalysisInfo {
   InstrList MS[NUM_MODULE_SECTIONS];
   // The table maps MBB number to SPIR-V unique ID register.
   DenseMap<std::pair<const MachineFunction *, int>, MCRegister> BBNumToRegMap;
+  // The table maps function pointers to their default FP fast math info. It can
+  // be assumed that the SmallVector is sorted by the bit width of the type. The
+  // first element is the smallest bit width, and the last element is the
+  // largest bit width, therefore, we will have {half, float, double} in
+  // the order of their bit widths.
+  DenseMap<const Function *, SmallVector<FPFastMathDefaultInfo, 3>>
----------------
Keenuts wrote:

nit: I'll be in favor or having `SmallVector<FPFastMathDefaultInfo, 3>` changed into:

```cpp
struct FPFastMathDefaultInfoVector : public SmallVector<FPFastMathDefaultInfo, 3> {
  static size_t computeFPFastMathDefaultInfoVecIndex(size_t BitWidth) {
     // the code from SPIRVUtils
```

This way you keep the index magic numbers close to the object using them.
Also, seems like there is a reimplementation of the FPFastMathDefaultInfo in the emit intrinsincs, meaning this couldn't be reused there. But once this code duplication removed, all `SmallVector<Info, 3>` bits can be replaced with this new class.

https://github.com/llvm/llvm-project/pull/146941


More information about the llvm-commits mailing list