[PATCH] D141302: [MachineCombiner] Lift same-bb restriction for reassociable ops.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 9 09:38:48 PST 2023


fhahn created this revision.
fhahn added reviewers: dmgreen, kawashima-fj, RKSimon, Gerolf, ab.
Herald added subscribers: StephenFan, pengfei, hiraditya, qcolombet.
Herald added a project: All.
fhahn requested review of this revision.
Herald added a subscriber: pcwang-thead.
Herald added a project: LLVM.

This patch relaxes the restriction that both reassociate operands must
be in the same block as the root instruction.

The comment indicates that the reason for this restriction was that the
operands not in the same block won't have a depth in the trace.

I believe this is outdated; if the operand is in a different block, it
must dominate the current block (otherwise it would need to be phi),
which in turn means the operand's block must be included in the current
rance, and depths must be available.

There's a test case (no_reassociate_different_block) added in
70520e2f1c5fc4 <https://reviews.llvm.org/rG70520e2f1c5fc48afd578aeb320ec61e05d79813> which shows that we have accurate depths for operands
defined in other blocks.

This allows reassociation of code that computes the final reduction
value after vectorization, among other things.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141302

Files:
  llvm/lib/CodeGen/TargetInstrInfo.cpp
  llvm/test/CodeGen/AArch64/machine-combiner-reassociate-ops-in-different-blocks.mir
  llvm/test/CodeGen/X86/AMX/amx-greedy-ra-spill-shape.ll
  llvm/test/CodeGen/X86/mul-constant-result.ll
  llvm/test/CodeGen/X86/optimize-max-0.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D141302.487482.patch
Type: text/x-patch
Size: 37090 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230109/b07cadeb/attachment-0001.bin>


More information about the llvm-commits mailing list