[all-commits] [llvm/llvm-project] 625e66: [InstCombine] add tests for signum (spaceship) var...

Sanjay Patel via All-commits all-commits at lists.llvm.org
Mon Jan 16 09:58:45 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 625e666d0e5af8022570abc12be0135735e50b27
      https://github.com/llvm/llvm-project/commit/625e666d0e5af8022570abc12be0135735e50b27
  Author: Sanjay Patel <spatel at rotateright.com>
  Date:   2023-01-16 (Mon, 16 Jan 2023)

  Changed paths:
    M llvm/test/Transforms/InstCombine/add.ll

  Log Message:
  -----------
  [InstCombine] add tests for signum (spaceship) variant; NFC


  Commit: dedc58da49c7a9d059cc4364ce737f6c7dc15569
      https://github.com/llvm/llvm-project/commit/dedc58da49c7a9d059cc4364ce737f6c7dc15569
  Author: Sanjay Patel <spatel at rotateright.com>
  Date:   2023-01-16 (Mon, 16 Jan 2023)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
    M llvm/test/Transforms/InstCombine/add.ll

  Log Message:
  -----------
  [InstCombine] canonicalize a signum (spaceship) that ends in add

(A s>> (BW - 1)) + (zext (A s> 0)) --> (A s>> (BW - 1)) | (zext (A != 0))

https://alive2.llvm.org/ce/z/V-nM8N

This is not the form that we currently match as m_Signum(),
but I'm not sure if one is better than the other, so there's
a follow-up patch needed either way.

For this patch, it should be better for analysis to use a
not-null test and bitwise logic rather than >0 with add.
Codegen doesn't seem significantly different on any targets
that I looked at.

Also note that none of these variants is shown in issue #60012 -
those generally include at least one 'select', so that's likely
where these patterns will end up.


Compare: https://github.com/llvm/llvm-project/compare/caf393da1823...dedc58da49c7


More information about the All-commits mailing list