[all-commits] [llvm/llvm-project] 533190: [InstCombine] Canonicalize Bit Testing by Shifting...

mskamp via All-commits all-commits at lists.llvm.org
Sun Aug 4 00:33:02 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 533190acdb9d2ed774f96a998b5c03be3df4f857
      https://github.com/llvm/llvm-project/commit/533190acdb9d2ed774f96a998b5c03be3df4f857
  Author: mskamp <msk at posteo.org>
  Date:   2024-08-04 (Sun, 04 Aug 2024)

  Changed paths:
    M llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
    M llvm/test/Transforms/InstCombine/icmp-and-shift.ll
    M llvm/test/Transforms/InstCombine/load-cmp.ll

  Log Message:
  -----------
  [InstCombine] Canonicalize Bit Testing by Shifting to Bit 0 (#101838)

Implement a new transformation that fold the bit-testing expression
(icmp ne (and (lshr V B) 1) 0) to (icmp ne (and V (shl 1 B)) 0) for
constant V. This rule already existed for non-constant V and constants
other than 1; this restriction to non-constant V has been added in
commit c3b2111d975a39d19f0c5d635e2961a4449c5a71 to fix an infinite loop.
Avoid the infinite loop by allowing constant V only if the shift
instruction is an lshr and the constant is 1. Also fold the negated
variant of the LHS.
    
This transformation necessitates an adaption of existing tests in
`icmp-and-shift.ll` and `load-cmp.ll`. One test in `icmp-and-shift.ll`,
which previously was a negative test, now gets folded. Rename it to
indicate that it is a positive test.
    
Alive proof: https://alive2.llvm.org/ce/z/vcJJTx
    
Relates to issue #86813.



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