[PATCH] D132621: [AMDGPU] Drop _oneuse checks from med3 patterns

Justin Bogner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 24 16:35:13 PDT 2022


bogner created this revision.
bogner added a reviewer: arsenm.
Herald added subscribers: kosarev, foad, kerbowa, hiraditya, t-tye, tpr, dstuttard, yaxunl, jvesely, kzhuravl, mcrosier.
Herald added a project: All.
bogner requested review of this revision.
Herald added subscribers: llvm-commits, wdng.
Herald added a project: LLVM.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D132621

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D132621.455421.patch
Type: text/x-patch
Size: 26634 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220824/9e79669a/attachment-0001.bin>


More information about the llvm-commits mailing list