[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
Mon Sep 19 04:57:04 PDT 2022
iliya-diyachkov marked an inline comment as done.
iliya-diyachkov added inline comments.
================
Comment at: llvm/lib/Target/SPIRV/SPIRVRegularizer.cpp:229
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);
----------------
nlopes wrote:
> This code seems to be implementing a splat of CI->getOperand(1) to a vector of type ArgoTy.
> You can use IRBuilder's CreateVectorSplat() to simplify this code (https://llvm.org/doxygen/classllvm_1_1IRBuilderBase.html#a40ed7274ff11f079e5b5eae34c818c51).
Thanks, Nuno. Yes it gives the same result as splat, but for now we'd prefer the backend to generate the same code as the SIPR-V translator does (inserting InsertElementInst and ShuffleVectorInst instructions). For instance (transcoding/OpMin.ll), it converts this call in LLVM IR
```
%call = tail call spir_func <2 x i32> @_Z3minDv2_ii(<2 x i32> <i32 1, i32 10>, i32 5) #2
```
to the following SPIR-V fragment:
```
%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
```
so InsertElementInst and ShuffleVectorInst are required.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D134071/new/
https://reviews.llvm.org/D134071
More information about the llvm-commits
mailing list