1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -instcombine -S | FileCheck %s
5 declare i8* @memrchr(i8*, i32, i32)
7 define i8* @test1(i8* %str, i32 %c, i32 %n) {
9 ; CHECK-NEXT: [[RET:%.*]] = call i8* @memrchr(i8* [[STR:%.*]], i32 [[C:%.*]], i32 [[N:%.*]])
10 ; CHECK-NEXT: ret i8* [[RET]]
13 %ret = call i8* @memrchr(i8* %str, i32 %c, i32 %n)
17 define i8* @test2(i8* %str, i32 %c, i32 %n) {
18 ; CHECK-LABEL: @test2(
19 ; CHECK-NEXT: [[RET:%.*]] = call i8* @memrchr(i8* nonnull [[STR:%.*]], i32 [[C:%.*]], i32 [[N:%.*]])
20 ; CHECK-NEXT: ret i8* [[RET]]
23 %ret = call i8* @memrchr(i8* nonnull %str, i32 %c, i32 %n)
27 define i8* @test3(i8* %str, i32 %c) {
28 ; CHECK-LABEL: @test3(
29 ; CHECK-NEXT: [[RET:%.*]] = call i8* @memrchr(i8* [[STR:%.*]], i32 [[C:%.*]], i32 5)
30 ; CHECK-NEXT: ret i8* [[RET]]
33 %ret = call i8* @memrchr(i8* %str, i32 %c, i32 5)
37 define i8* @test4(i8* %str, i32 %c) null_pointer_is_valid {
38 ; CHECK-LABEL: @test4(
39 ; CHECK-NEXT: [[RET:%.*]] = call i8* @memrchr(i8* [[STR:%.*]], i32 [[C:%.*]], i32 5)
40 ; CHECK-NEXT: ret i8* [[RET]]
43 %ret = call i8* @memrchr(i8* %str, i32 %c, i32 5)
47 define i8* @test5(i8* %str, i32 %c) {
48 ; CHECK-LABEL: @test5(
49 ; CHECK-NEXT: [[RET:%.*]] = call i8* @memrchr(i8* [[STR:%.*]], i32 [[C:%.*]], i32 0)
50 ; CHECK-NEXT: ret i8* [[RET]]
53 %ret = call i8* @memrchr(i8* %str, i32 %c, i32 0)