1 ; Test that the StrRChrOptimizer works correctly
2 ; RUN: opt < %s -simplify-libcalls -S | FileCheck %s
4 target datalayout = "-p:64:64:64"
6 @hello = constant [14 x i8] c"hello world\5Cn\00"
7 @null = constant [1 x i8] zeroinitializer
9 declare i8* @strrchr(i8*, i32)
11 define void @foo(i8* %bar) {
12 %hello_p = getelementptr [14 x i8]* @hello, i32 0, i32 0
13 %null_p = getelementptr [1 x i8]* @null, i32 0, i32 0
14 %world = call i8* @strrchr(i8* %hello_p, i32 119)
15 ; CHECK: getelementptr i8* %hello_p, i64 6
16 %ignore = call i8* @strrchr(i8* %null_p, i32 119)
17 ; CHECK-NOT: call i8* strrchr
18 %null = call i8* @strrchr(i8* %hello_p, i32 0)
19 ; CHECK: getelementptr i8* %hello_p, i64 13
20 %strchr = call i8* @strrchr(i8* %bar, i32 0)
21 ; CHECK: call i8* @strchr(i8* %bar, i32 0)