[all-commits] [llvm/llvm-project] ac7694: [InstSimplify] add tests for or-of-shifted-one-bit...

RotateRight via All-commits all-commits at lists.llvm.org
Tue Aug 24 12:38:53 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: ac7694596dc5fe114b029384c2d87e6b49549116
      https://github.com/llvm/llvm-project/commit/ac7694596dc5fe114b029384c2d87e6b49549116
  Author: Sanjay Patel <spatel at rotateright.com>
  Date:   2021-08-24 (Tue, 24 Aug 2021)

  Changed paths:
    M llvm/test/Transforms/InstSimplify/or.ll

  Log Message:
  -----------
  [InstSimplify] add tests for or-of-shifted-one-bits; NFC


  Commit: 204038d52e03811cc39c18cc073c6020fbae4a4b
      https://github.com/llvm/llvm-project/commit/204038d52e03811cc39c18cc073c6020fbae4a4b
  Author: Sanjay Patel <spatel at rotateright.com>
  Date:   2021-08-24 (Tue, 24 Aug 2021)

  Changed paths:
    M llvm/lib/Analysis/InstructionSimplify.cpp
    M llvm/test/Transforms/InstSimplify/or.ll

  Log Message:
  -----------
  [InstSimplify] fold or+shifted -1 to -1

These are similar to the rotate pattern added with:
dcf659e8219b
...but we don't have guard ops on the shift amount,
so we don't canonicalize to the intrinsic.

  declare void @llvm.assume(i1)

  define i32 @src(i32 %shamt, i32 %bitwidth) {
    ; subtract must be in range of bitwidth
    %lt = icmp ule i32 %bitwidth, 32
    call void @llvm.assume(i1 %lt)

    %r = lshr i32 -1, %shamt
    %s = sub i32 %bitwidth, %shamt
    %l = shl i32 -1, %s
    %o = or i32 %r, %l
    ret i32 %o
  }

  define i32 @tgt(i32 %shamt, i32 %bitwidth) {
    ret i32 -1
  }

https://alive2.llvm.org/ce/z/aF7WHx


Compare: https://github.com/llvm/llvm-project/compare/9588b685c6b2...204038d52e03


More information about the All-commits mailing list