[PATCH] D156520: [TII] NFCI: Simplify the interface for isTriviallyReMaterializable

Sander de Smalen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 28 03:59:45 PDT 2023


sdesmalen created this revision.
sdesmalen added reviewers: arsenm, dexonsmith, craig.topper.
Herald added subscribers: pmatos, asb, foad, kerbowa, pengfei, kbarton, hiraditya, jgravelle-google, sbc100, jvesely, nemanjai, dschuff.
Herald added a project: All.
sdesmalen requested review of this revision.
Herald added subscribers: llvm-commits, aheejin, wdng.
Herald added a project: LLVM.

Currently `isTriviallyReMaterializable` calls
`isReallyTriviallyReMaterializable` and
`isReallyTriviallyReMaterializableGeneric`. The two interfaces
are confusing, but there are also some real issues with this.

The documentation of this function (see below) suggests that
`isReallyTriviallyRematerializable` allows the target to override the
default behaviour.

  /// For instructions with opcodes for which the M_REMATERIALIZABLE flag is
  /// set, this hook lets the target specify whether the instruction is actually
  /// trivially rematerializable, taking into consideration its operands.

It however implements something different. The default behaviour
is the analysis done in `isReallyTriviallyReMaterializableGeneric`,
which is testing if it is safe to rematerialize the MachineInstr.

The result of `isReallyTriviallyReMaterializable` is only considered if
`isReallyTriviallyReMaterializableGeneric` returns `false`.  That means
there is no way to override the default behaviour if
`isReallyTriviallyReMaterializableGeneric` returns true (i.e. it is safe to
rematerialize, but we'd rather not).

By making this a single interface, we can override the interface to do either.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156520

Files:
  llvm/include/llvm/CodeGen/MachineInstr.h
  llvm/include/llvm/CodeGen/TargetInstrInfo.h
  llvm/include/llvm/MC/MCInstrDesc.h
  llvm/lib/CodeGen/TargetInstrInfo.cpp
  llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
  llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp
  llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.cpp
  llvm/lib/Target/X86/X86InstrInfo.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156520.545093.patch
Type: text/x-patch
Size: 8225 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230728/448ae60b/attachment.bin>


More information about the llvm-commits mailing list