[PATCH] D151945: Introduce G_OPAQUE and use it to prevent constant folding hoisted constants.
Amara Emerson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 1 15:18:11 PDT 2023
aemerson created this revision.
aemerson added reviewers: arsenm, Pierre-vh, tschuett, foad.
aemerson added a project: LLVM.
Herald added subscribers: StephenFan, hiraditya.
Herald added a project: All.
aemerson requested review of this revision.
Herald added a subscriber: wdng.
This obsoletes D150179 <https://reviews.llvm.org/D150179>
The constant hoisting pass tries to hoist large constants into predecessors and also
generates remat instructions in terms of the hoisted constants. These aim to prevent
codegen from rematerializing expensive constants multiple times. So we can re-use
this optimization, we can preserve the no-op bitcasts that are used to anchor
constants to the predecessor blocks.
SelectionDAG achieves this by having the OpaqueConstant node, which is just a
normal constant with an opaque flag set. I've opted to avoid introducing a new
constant generic instruction here. Instead, we have a new G_OPAQUE operation that
constitutes a folding barrier.
These are somewhat like the optimization hints, G_ASSERT_ZEXT in that they're
eliminated by the generic instruction selection code.
This change by itself has very minor improvements in -Os CTMark overall. What this
does allow is better optimizations when future combines are added that rely on having
expensive constants remain unfolded.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D151945
Files:
llvm/docs/GlobalISel/GenericOpcode.rst
llvm/include/llvm/Support/TargetOpcodes.def
llvm/include/llvm/Target/GenericOpcodes.td
llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp
llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp
llvm/test/CodeGen/AArch64/GlobalISel/irtranslator-bitcast.ll
llvm/test/CodeGen/AArch64/GlobalISel/irtranslator-hoisted-constants.ll
llvm/test/CodeGen/AArch64/GlobalISel/legalizer-info-validation.mir
llvm/test/CodeGen/AArch64/GlobalISel/localizer-arm64-tti.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D151945.527644.patch
Type: text/x-patch
Size: 16732 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230601/58cc8f0f/attachment.bin>
More information about the llvm-commits
mailing list