This is an archive of the discontinued LLVM Phabricator instance.

[SPIRV] fix build with clang and use PoisonValue instead of UndefValue
ClosedPublic

Authored by iliya-diyachkov on Sep 16 2022, 1:05 PM.

Details

Summary

The patch fixes the backend build using clang (#57773). It also replaces UndefValue with PoisonValue in SPIRVRegularizer.cpp as requested by @nlopes.

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptSep 16 2022, 1:05 PM
iliya-diyachkov requested review of this revision.Sep 16 2022, 1:05 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 16 2022, 1:05 PM
iliya-diyachkov edited the summary of this revision. (Show Details)Sep 16 2022, 1:10 PM
nlopes accepted this revision.Sep 17 2022, 3:37 AM
nlopes added inline comments.
llvm/lib/Target/SPIRV/SPIRVRegularizer.cpp
241

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).

This revision is now accepted and ready to land.Sep 17 2022, 3:37 AM
iliya-diyachkov marked an inline comment as done.Sep 19 2022, 4:57 AM
iliya-diyachkov added inline comments.
llvm/lib/Target/SPIRV/SPIRVRegularizer.cpp
241

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.

iliya-diyachkov marked an inline comment as done.
iliya-diyachkov edited the summary of this revision. (Show Details)

Add a comment.

python3kgae removed a subscriber: python3kgae.