llvm/llvm/test/Transforms/InstCombine/memrchr.ll

; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -passes=instcombine -S | FileCheck %s


declare ptr @memrchr(ptr, i32, i32)

define ptr @test1(ptr %str, i32 %c, i32 %n) {
; CHECK-LABEL: @test1(
; CHECK-NEXT:    [[RET:%.*]] = call ptr @memrchr(ptr [[STR:%.*]], i32 [[C:%.*]], i32 [[N:%.*]])
; CHECK-NEXT:    ret ptr [[RET]]
;

  %ret = call ptr @memrchr(ptr %str, i32 %c, i32 %n)
  ret ptr %ret
}

define ptr @test2(ptr %str, i32 %c, i32 %n) {
; CHECK-LABEL: @test2(
; CHECK-NEXT:    [[RET:%.*]] = call ptr @memrchr(ptr nonnull [[STR:%.*]], i32 [[C:%.*]], i32 [[N:%.*]])
; CHECK-NEXT:    ret ptr [[RET]]
;

  %ret = call ptr @memrchr(ptr nonnull %str, i32 %c, i32 %n)
  ret ptr %ret
}

define ptr @test3(ptr %str, i32 %c) {
; CHECK-LABEL: @test3(
; CHECK-NEXT:    [[RET:%.*]] = call ptr @memrchr(ptr [[STR:%.*]], i32 [[C:%.*]], i32 5)
; CHECK-NEXT:    ret ptr [[RET]]
;

  %ret = call ptr @memrchr(ptr %str, i32 %c, i32 5)
  ret ptr %ret
}

define ptr @test4(ptr %str, i32 %c) null_pointer_is_valid {
; CHECK-LABEL: @test4(
; CHECK-NEXT:    [[RET:%.*]] = call ptr @memrchr(ptr [[STR:%.*]], i32 [[C:%.*]], i32 5)
; CHECK-NEXT:    ret ptr [[RET]]
;

  %ret = call ptr @memrchr(ptr %str, i32 %c, i32 5)
  ret ptr %ret
}

define ptr @test5(ptr %str, i32 %c) {
; CHECK-LABEL: @test5(
; CHECK-NEXT:    [[RET:%.*]] = call ptr @memrchr(ptr [[STR:%.*]], i32 [[C:%.*]], i32 0)
; CHECK-NEXT:    ret ptr [[RET]]
;

  %ret = call ptr @memrchr(ptr %str, i32 %c, i32 0)
  ret ptr %ret
}