This is an archive of the discontinued LLVM Phabricator instance.

[SPIRV] add IR regularization pass
ClosedPublic

Authored by iliya-diyachkov on Sep 3 2022, 5:43 AM.

Details

Summary

The patch adds the regularization pass that prepare LLVM IR for the IR translation. It also implements a few small improvements and fixes some bugs:

  • reduce code indentation, make getNonParametrizedType, getSamplerType, getPipeType, getImageType, getSampledImageType static (SPIRVBuiltins.cpp),
  • rename mayBeOclOrSpirvBuiltin to getOclOrSpirvBuiltinDemangledName (SPIRVUtils.cpp),
  • move isOpenCLBuiltinType, isSPIRVBuiltinType, isSpecialType from SPIRVGlobalRegistry.cpp to SPIRVUtils.cpp, renaming isSpecialType to isSpecialOpaqueType,
  • implment getTgtMemIntrinsic() in SPIRVISelLowering,
  • add hasSideEffects = 0 in Pseudo (SPIRVInstrFormats.td),
  • add legalization rule for G_MEMSET, correct G_BRCOND rule (SPIRVLegalizerInfo.cpp),
  • add capability processing for OpBuildNDRange (SPIRVModuleAnalysis.cpp),
  • don't correct type of register holding constant and used in G_ADDRSPACE_CAST (SPIRVPreLegalizer.cpp),
  • lower memset/bswap intrinsics to functions (SPIRVPrepareFunctions.cpp),
  • change TLOF from TargetLoweringObjectFileELF to SPIRVTargetObjectFile (SPIRVTargetMachine.cpp),
  • correct comments.

5 LIT tests are added to show the improvement.

Diff Detail

Event Timeline

iliya-diyachkov created this revision.Sep 3 2022, 5:43 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 3 2022, 5:43 AM
iliya-diyachkov requested review of this revision.Sep 3 2022, 5:43 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 3 2022, 5:43 AM
nlopes added inline comments.Sep 3 2022, 6:09 AM
llvm/lib/Target/SPIRV/SPIRVLowerConstExpr.cpp
150 ↗(On Diff #457784)

Please use PoisonValue as a placeholder.

zuban32 requested changes to this revision.Sep 10 2022, 2:00 AM

Could you pls specify a list of these small bug fixes, at the very high level at least? An ideal variant would be to not mix them up with this regularization stuff at all.

llvm/lib/Target/SPIRV/SPIRVCallLowering.cpp
118

Alright, this doesn't look like a small change to me. Can this be moved into a separate patch, current description doesn't say anything specific about this anyway?

This revision now requires changes to proceed.Sep 10 2022, 2:00 AM
iliya-diyachkov retitled this revision from [SPIRV] add IR regularization passes to [SPIRV] add IR regularization pass.
iliya-diyachkov edited the summary of this revision. (Show Details)
iliya-diyachkov marked 2 inline comments as done.Sep 10 2022, 5:24 AM

Two issues are resolved in the new patch.

Could you pls specify a list of these small bug fixes, at the very high level at least?

Sure, I will add it later today.

Suggest small style test fixes.

llvm/test/CodeGen/SPIRV/lshr-constexpr.ll
6–12
llvm/test/CodeGen/SPIRV/opencl/get_global_id.ll
42–43
46–47
54
llvm/test/CodeGen/SPIRV/transcoding/OpMin.ll
5
7–8
iliya-diyachkov edited the summary of this revision. (Show Details)

Fix tests.

iliya-diyachkov marked 6 inline comments as done.Sep 10 2022, 7:35 AM
mpaszkowski accepted this revision.Sep 13 2022, 4:38 PM

Thanks for the patch and fixing the issues/comments! LGTM! I think this could be committed now.

zuban32 added inline comments.Sep 14 2022, 12:29 AM
llvm/lib/Target/SPIRV/SPIRVBuiltins.cpp
1738

Pls remove tabs

1747

Tabs

1784

Tabs

iliya-diyachkov marked 3 inline comments as done.Sep 14 2022, 1:13 AM

These are not tabs, but spaces. Phabricator shows in this way that the patch contains an indentation change. In this particular case, I inserted "static" and needed to add spaces before parameters.

zuban32 accepted this revision.Sep 14 2022, 5:17 PM

OK, LGTM then

This revision is now accepted and ready to land.Sep 14 2022, 5:17 PM
This revision was automatically updated to reflect the committed changes.

You committed the patch with undefvalue. Could you please use poison value instead? Thank you!