[all-commits] [llvm/llvm-project] f3fdda: [AMDGPU][SIFoldOperands] Fold some redundant bitmasks

Pierre van Houtryve via All-commits all-commits at lists.llvm.org
Mon Mar 17 02:30:53 PDT 2025


  Branch: refs/heads/users/pierre-vh/sifold-bitmasks
  Home:   https://github.com/llvm/llvm-project
  Commit: f3fddad8dca1e8ed327d7cc7cfee7a465032dcc4
      https://github.com/llvm/llvm-project/commit/f3fddad8dca1e8ed327d7cc7cfee7a465032dcc4
  Author: pvanhout <pierre.vanhoutryve at amd.com>
  Date:   2025-03-17 (Mon, 17 Mar 2025)

  Changed paths:
    M llvm/lib/Target/AMDGPU/SIFoldOperands.cpp
    M llvm/test/CodeGen/AMDGPU/GlobalISel/ashr.ll
    M llvm/test/CodeGen/AMDGPU/GlobalISel/fshl.ll
    M llvm/test/CodeGen/AMDGPU/GlobalISel/fshr.ll
    M llvm/test/CodeGen/AMDGPU/GlobalISel/lshr.ll
    M llvm/test/CodeGen/AMDGPU/GlobalISel/shl.ll
    M llvm/test/CodeGen/AMDGPU/constrained-shift.ll
    M llvm/test/CodeGen/AMDGPU/si-fold-bitmasks.mir

  Log Message:
  -----------
  [AMDGPU][SIFoldOperands] Fold some redundant bitmasks

Instructions like shifts only read some of the bits of the shift amount operand, between 4 and 6 bits.
If the source operand is being masked, we can just ignore the mask.

Effects are minimal right now but this will kick in more once we disable uniform i16 operation widening in CGP.
With that disabled, we get more i16 shift amounts
that are zext'd and without this we'd end up with
more `s_and_b32 s1, s1, 0xFFFF` in the output.

Ideally ISel should handle this but it's proving difficult to get the patterns right, and after a few hours of trying I just decided to go with this as it's simple enough and it "just works" for this purpose.


  Commit: 82443bc225b62a0896075fe455e98a5b497b863b
      https://github.com/llvm/llvm-project/commit/82443bc225b62a0896075fe455e98a5b497b863b
  Author: pvanhout <pierre.vanhoutryve at amd.com>
  Date:   2025-03-17 (Mon, 17 Mar 2025)

  Changed paths:
    M llvm/lib/Target/AMDGPU/SIFoldOperands.cpp

  Log Message:
  -----------
  clang-format


Compare: https://github.com/llvm/llvm-project/compare/c18d66f0471b...82443bc225b6

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