[PATCH] D134071: [SPIRV] fix build with clang and use PoisonValue instead of UndefValue

Ilia Diachkov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 22 01:06:29 PDT 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rG4421b24fe2c8: [SPIRV] fix build with clang and use PoisonValue instead of UndefValue (authored by iliya-diyachkov).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D134071/new/

https://reviews.llvm.org/D134071

Files:
  llvm/lib/Target/SPIRV/SPIRVBuiltins.cpp
  llvm/lib/Target/SPIRV/SPIRVRegularizer.cpp


Index: llvm/lib/Target/SPIRV/SPIRVRegularizer.cpp
===================================================================
--- llvm/lib/Target/SPIRV/SPIRVRegularizer.cpp
+++ llvm/lib/Target/SPIRV/SPIRVRegularizer.cpp
@@ -220,13 +220,25 @@
   }
   assert(NewF);
 
+  // This produces an instruction sequence that implements a splat of
+  // CI->getOperand(1) to a vector Arg0Ty. However, we use InsertElementInst
+  // and ShuffleVectorInst to generate the same code as the SPIR-V translator.
+  // For instance (transcoding/OpMin.ll), this call
+  //   call spir_func <2 x i32> @_Z3minDv2_ii(<2 x i32> <i32 1, i32 10>, i32 5)
+  // is translated to
+  //    %8 = OpUndef %v2uint
+  //   %14 = OpConstantComposite %v2uint %uint_1 %uint_10
+  //   ...
+  //   %10 = OpCompositeInsert %v2uint %uint_5 %8 0
+  //   %11 = OpVectorShuffle %v2uint %10 %8 0 0
+  // %call = OpExtInst %v2uint %1 s_min %14 %11
   auto ConstInt = ConstantInt::get(IntegerType::get(CI->getContext(), 32), 0);
-  UndefValue *UndefVal = UndefValue::get(Arg0Ty);
+  PoisonValue *PVal = PoisonValue::get(Arg0Ty);
   Instruction *Inst =
-      InsertElementInst::Create(UndefVal, CI->getOperand(1), ConstInt, "", CI);
+      InsertElementInst::Create(PVal, CI->getOperand(1), ConstInt, "", CI);
   ElementCount VecElemCount = cast<VectorType>(Arg0Ty)->getElementCount();
   Constant *ConstVec = ConstantVector::getSplat(VecElemCount, ConstInt);
-  Value *NewVec = new ShuffleVectorInst(Inst, UndefVal, ConstVec, "", CI);
+  Value *NewVec = new ShuffleVectorInst(Inst, PVal, ConstVec, "", CI);
   CI->setOperand(1, NewVec);
   CI->replaceUsesOfWith(OldF, NewF);
   CI->mutateFunctionType(NewF->getFunctionType());
Index: llvm/lib/Target/SPIRV/SPIRVBuiltins.cpp
===================================================================
--- llvm/lib/Target/SPIRV/SPIRVBuiltins.cpp
+++ llvm/lib/Target/SPIRV/SPIRVBuiltins.cpp
@@ -1795,7 +1795,7 @@
 
 namespace SPIRV {
 SPIRVType *lowerBuiltinType(const StructType *OpaqueType,
-                            AccessQualifier::AccessQualifier AccessQual,
+                            SPIRV::AccessQualifier::AccessQualifier AccessQual,
                             MachineIRBuilder &MIRBuilder,
                             SPIRVGlobalRegistry *GR) {
   assert(OpaqueType->hasName() &&


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134071.462102.patch
Type: text/x-patch
Size: 2285 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220922/013de36b/attachment-0001.bin>


More information about the llvm-commits mailing list