[llvm] [SPIR-V] Consistent handling of TargetExtTypes in emit-intrinsics (PR #135682)

Steven Perron via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 15 07:49:33 PDT 2025


================
@@ -1947,10 +1947,14 @@ void SPIRVEmitIntrinsics::insertAssignTypeIntrs(Instruction *I,
           GR->buildAssignPtr(B, ElemTy ? ElemTy : deduceElementType(Op, true),
                              Op);
         } else {
+          Value *OpTyVal = Op;
+          if (OpTy->isTargetExtTy()) {
+            OpTyVal = getNormalizedPoisonValue(OpTy);
+          }
           CallInst *AssignCI =
               buildIntrWithMD(Intrinsic::spv_assign_type, {OpTy},
-                              getNormalizedPoisonValue(OpTy), Op, {}, B);
-          GR->addAssignPtrTypeInstr(Op, AssignCI);
+                              getNormalizedPoisonValue(OpTy), OpTyVal, {}, B);
+          GR->addAssignPtrTypeInstr(OpTyVal, AssignCI);
----------------
s-perron wrote:

Not a big deal. More my personal preference. If find this harder when there is a small if statement in the middle of the code. This might be better:

```
} else if (OpTy->isTargetExtTy()) {
          Value *OpTyVal = getNormalizedPoisonValue(OpTy);
          CallInst *AssignCI =
              buildIntrWithMD(Intrinsic::spv_assign_type, {OpTy},
                              getNormalizedPoisonValue(OpTy), OpTyVal, {}, B);
          GR->addAssignPtrTypeInstr(OpTyVal, AssignCI);
} else {
          CallInst *AssignCI =
              buildIntrWithMD(Intrinsic::spv_assign_type, {OpTy},
                              getNormalizedPoisonValue(OpTy), Op, {}, B);
          GR->addAssignPtrTypeInstr(Op, AssignCI);
}
```

Feel free to ignore if you disagree.

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


More information about the llvm-commits mailing list