This is an archive of the discontinued LLVM Phabricator instance.

[SPIR-V] Emit spv_undef intrinsic for aggregate undef operands
ClosedPublic

Authored by mpaszkowski on Feb 1 2023, 1:10 PM.

Details

Summary

This change adds a new spv_undef intrinsic which is emitted in place of aggregate undef operands and later selected to single OpUndef SPIR-V instruction. The behavior matches that of Khronos SPIR-V Translator and should support nested aggregates.

This is an alternative better approach to the one discussed in https://reviews.llvm.org/D141337.

Diff Detail

Event Timeline

mpaszkowski created this revision.Feb 1 2023, 1:10 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 1 2023, 1:10 PM
mpaszkowski requested review of this revision.Feb 1 2023, 1:10 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 1 2023, 1:10 PM

Fixed formatting

iliya-diyachkov added inline comments.Feb 1 2023, 2:44 PM
llvm/lib/Target/SPIRV/SPIRVEmitIntrinsics.cpp
165

The indentation level could be reduced by

if (!condition)
  continue;
arsenm added inline comments.Feb 2 2023, 8:39 AM
llvm/lib/Target/SPIRV/SPIRVEmitIntrinsics.cpp
155

I don't really understand why you need to handle this in an IR pass, undoes could easily appear at any time

166

You're using isa and dyn_cast, just use dyn_cast once

llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp
1345

dead break

iliya-diyachkov added inline comments.Feb 2 2023, 1:36 PM
llvm/lib/Target/SPIRV/SPIRVEmitIntrinsics.cpp
155

@arsenm This is required just before IRTranslator to pass aggregate undefs through it. Undefs appearing in other places are already supported.

mpaszkowski marked 3 inline comments as done.Feb 16 2023, 12:35 PM

Fixed issues

iliya-diyachkov accepted this revision.Feb 16 2023, 4:27 PM

The patch looks good to me, thanks Michal.

This revision is now accepted and ready to land.Feb 16 2023, 4:27 PM