[PATCH] D151945: Introduce G_OPAQUE and use it to prevent constant folding hoisted constants.
Pierre van Houtryve via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 5 00:15:04 PDT 2023
Pierre-vh added a comment.
Thanks a lot for making this change :)
================
Comment at: llvm/docs/GlobalISel/GenericOpcode.rst:945
+
+This operation is used as an opaque barrier to prevent constant folding. Combines
+and other transformations should not look through G_OPAQUE. These have no other
----------------
I would generalize this to "prevent optimizations such as constant folding, sinking, or other combines."
================
Comment at: llvm/include/llvm/Support/TargetOpcodes.def:335
+/// Constant folding barrier.
+HANDLE_TARGET_OPCODE(G_OPAQUE)
----------------
Same, this may be used for other combines so I'd just say "Combine optimization barrier" ?
================
Comment at: llvm/include/llvm/Target/GenericOpcodes.td:1477
+
+// Prevent constant folding of the source value with any users.
+def G_OPAQUE : GenericInstruction {
----------------
ditto
================
Comment at: llvm/lib/CodeGen/GlobalISel/InstructionSelect.cpp:170-171
+ // Eliminate hints or G_OPAQUE.
+ if (isPreISelGenericOptimizationHint(MI.getOpcode()) ||
+ MI.getOpcode() == TargetOpcode::G_OPAQUE) {
+ auto [DstReg, SrcReg] = MI.getFirst2Regs();
----------------
Could `G_OPAQUE` go in `isPreISelGenericOptimizationHint` as it's also some kind of optimization hint (barrier)?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D151945/new/
https://reviews.llvm.org/D151945
More information about the llvm-commits
mailing list