[all-commits] [llvm/llvm-project] a81c7d: [AMDGPU] Drop _oneuse checks from med3 patterns

Justin Bogner via All-commits all-commits at lists.llvm.org
Wed Sep 7 16:32:22 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: a81c7dbf0d067bfe0c27f75af95dbdcc96d1a5da
      https://github.com/llvm/llvm-project/commit/a81c7dbf0d067bfe0c27f75af95dbdcc96d1a5da
  Author: Justin Bogner <mail at justinbogner.com>
  Date:   2022-09-07 (Wed, 07 Sep 2022)

  Changed paths:
    M llvm/lib/Target/AMDGPU/SIInstructions.td
    M llvm/test/CodeGen/AMDGPU/GlobalISel/inst-select-pattern-smed3.mir
    M llvm/test/CodeGen/AMDGPU/GlobalISel/inst-select-pattern-smed3.s16.mir
    M llvm/test/CodeGen/AMDGPU/GlobalISel/inst-select-pattern-umed3.mir
    M llvm/test/CodeGen/AMDGPU/GlobalISel/inst-select-pattern-umed3.s16.mir
    M llvm/test/CodeGen/AMDGPU/smed3.ll
    M llvm/test/CodeGen/AMDGPU/umed3.ll

  Log Message:
  -----------
  [AMDGPU] Drop _oneuse checks from med3 patterns

We use _oneuse checks to make sure combines won't accidentally
increase code size, but this prevents the optimization in cases where
we happen to want to clamp multiple values to the same range

It's safe to drop these checks for two reasons:

1. The pattern of max/min operations for med3 is complicated enough
   it's unlikely to come up by accident, so this will still only fire
   when appropriate to do so
2. Even if every intermediate is used and we don't save a single
   operation, we still won't end up with more operations since the
   med3 replaces the final max/min.

In pathological cases we could potentially end up with a larger
encoding size or possibly slightly increased vgpr pressure, but the
risk of that is low, especially considering the upside.

Differential Revision: https://reviews.llvm.org/D132621




More information about the All-commits mailing list