[llvm] [DirectX] Infrastructure to collect shader flags for each function (PR #112967)

Justin Bogner via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 29 17:18:26 PDT 2024


================
@@ -13,36 +13,70 @@
 
 #include "DXILShaderFlags.h"
 #include "DirectX.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/IR/Instruction.h"
 #include "llvm/IR/Module.h"
+#include "llvm/Support/Error.h"
 #include "llvm/Support/FormatVariadic.h"
+#include "llvm/Support/raw_ostream.h"
 
 using namespace llvm;
 using namespace llvm::dxil;
 
-static void updateFlags(ComputedShaderFlags &Flags, const Instruction &I) {
+static void updateFlags(ComputedShaderFlags &CSF, const Instruction &I) {
   Type *Ty = I.getType();
-  if (Ty->isDoubleTy()) {
-    Flags.Doubles = true;
+  bool DoubleTyInUse = Ty->isDoubleTy();
+  for (Value *Op : I.operands()) {
+    DoubleTyInUse |= Op->getType()->isDoubleTy();
+  }
+
+  if (DoubleTyInUse) {
+    CSF.Doubles = true;
----------------
bogner wrote:

This would be simpler if you just modify `CSF.Doubles` directly.
```c++
if (I.getType()->isDoubleTy())
  CSF.Doubles = true;
for (Value *Op : I.getOperands())
  CSF.Doubles |= Op->getType()->isDoulbeTy());
if (CSF.Doubles) {
  // ...
}

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


More information about the llvm-commits mailing list