[all-commits] [llvm/llvm-project] d6d99d: [AMDGPU] Improve max3/min3 formation for tree-stru...

Dark Steve via All-commits all-commits at lists.llvm.org
Thu Apr 9 23:46:54 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: d6d99d9f600fc54bc9d0ee47e3130953372c56d5
      https://github.com/llvm/llvm-project/commit/d6d99d9f600fc54bc9d0ee47e3130953372c56d5
  Author: Dark Steve <Prasoon.Mishra at amd.com>
  Date:   2026-04-10 (Fri, 10 Apr 2026)

  Changed paths:
    M llvm/lib/Target/AMDGPU/SIISelLowering.cpp
    M llvm/test/CodeGen/AMDGPU/combine_andor_with_cmps.ll
    M llvm/test/CodeGen/AMDGPU/combine_andor_with_cmps_nnan.ll
    M llvm/test/CodeGen/AMDGPU/min3.ll
    A llvm/test/CodeGen/AMDGPU/minmax3-tree-reduction.ll
    M llvm/test/CodeGen/AMDGPU/vector-reduce-smax.ll
    M llvm/test/CodeGen/AMDGPU/vector-reduce-smin.ll
    M llvm/test/CodeGen/AMDGPU/vector-reduce-umax.ll
    M llvm/test/CodeGen/AMDGPU/vector-reduce-umin.ll

  Log Message:
  -----------
  [AMDGPU] Improve max3/min3 formation for tree-structured reductions (#190734)

The existing `performMinMaxCombine` forms `max3` by matching
`max(max(a,b), c) -> max3(a,b,c)`. For tree reductions like
`max(max(a,b), max(c,d))`, this produces `max3(a, b, max(c,d));` placing
`max3` on top. At the next tree level, `max(max3, max3)` cannot combine
because the 3-op opcode (`FMAXIMUM3`) differs from the 2-op opcode
(`FMAXIMUM`).

This patch:
1. Adds a tree combine: `max(max(a,b), max(c,d)) -> max(max3(a,b,c),
d)`, keeping a 2-op node on top that enables further combining.
2. Defers the existing combine when the operand is a tree node whose
children can still be combined, ensuring inner tree levels are optimized
before outer levels consume them.

Deferral is skipped when neither child has a single use, since the inner
combine cannot fire in that case.

Fix: LCOMPILER-1652



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list