[all-commits] [llvm/llvm-project] 77df60: [InstCombine] add tests for lshr(add(shl())); NFC

RotateRight via All-commits all-commits at lists.llvm.org
Wed Dec 29 13:10:24 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 77df60965f0c8297ac224cf02979b5b01efc7bce
      https://github.com/llvm/llvm-project/commit/77df60965f0c8297ac224cf02979b5b01efc7bce
  Author: Sanjay Patel <spatel at rotateright.com>
  Date:   2021-12-29 (Wed, 29 Dec 2021)

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

  Log Message:
  -----------
  [InstCombine] add tests for lshr(add(shl())); NFC


  Commit: baa22e9327a85ce16f2d112c610d828f2ce1cb1c
      https://github.com/llvm/llvm-project/commit/baa22e9327a85ce16f2d112c610d828f2ce1cb1c
  Author: Sanjay Patel <spatel at rotateright.com>
  Date:   2021-12-29 (Wed, 29 Dec 2021)

  Changed paths:
    M llvm/test/Transforms/InstCombine/unsigned-add-lack-of-overflow-check.ll

  Log Message:
  -----------
  [InstCombine] add tests for unsigned overflow of bitmask offset; NFC


  Commit: 6c716c8589506cec407f01b0cd60005a3e346cf0
      https://github.com/llvm/llvm-project/commit/6c716c8589506cec407f01b0cd60005a3e346cf0
  Author: Sanjay Patel <spatel at rotateright.com>
  Date:   2021-12-29 (Wed, 29 Dec 2021)

  Changed paths:
    M llvm/include/llvm/IR/PatternMatch.h
    M llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
    M llvm/test/Transforms/InstCombine/unsigned-add-lack-of-overflow-check.ll

  Log Message:
  -----------
  [InstCombine] add more folds for unsigned overflow checks

 ((Op1 + C) & C) u<  Op1 --> Op1 != 0
 ((Op1 + C) & C) u>= Op1 --> Op1 == 0
 Op0 u>  ((Op0 + C) & C) --> Op0 != 0
 Op0 u<= ((Op0 + C) & C) --> Op0 == 0

https://alive2.llvm.org/ce/z/iUfXJN
https://alive2.llvm.org/ce/z/caAtjj

  define i1 @src(i8 %x, i8 %y) {
    ; the add/mask must be with a low-bit mask (0x01ff...)
    %y1 = add i8 %y, 1
    %pop = call i8 @llvm.ctpop.i8(i8 %y1)
    %ismask = icmp eq i8 %pop, 1
    call void @llvm.assume(i1 %ismask)

    %a = add i8 %x, %y
    %m = and i8 %a, %y
    %r = icmp ult i8 %m, %x
    ret i1 %r
  }

  define i1 @tgt(i8 %x, i8 %y) {
    %r = icmp ne i8 %x, 0
    ret i1 %r
  }

I suspect this can be generalized in some way, but this
is the pattern I'm seeing in a motivating test based on
issue #52851.


Compare: https://github.com/llvm/llvm-project/compare/7df7586a0b09...6c716c858950


More information about the All-commits mailing list