blob: ae917f70f4f1411291d74a24d69f0a4be958c3be [file] [log] [blame]
Chris Lattner3d2e54b2007-04-06 23:36:59 +00001; PR1307
Dan Gohmanf2f6ce62009-09-11 18:01:28 +00002; RUN: opt < %s -simplify-libcalls -instcombine -S > %t
Chandler Carruth4177e6f2012-07-02 12:47:22 +00003; RUN: grep "@str,.*i64 3" %t
4; RUN: grep "@str1,.*i64 7" %t
5; RUN: grep "ret i8.*null" %t
Reid Spencer894cfff2007-04-15 05:16:38 +00006; END.
Chris Lattner3d2e54b2007-04-06 23:36:59 +00007
8@str = internal constant [5 x i8] c"foog\00"
9@str1 = internal constant [8 x i8] c"blahhh!\00"
10@str2 = internal constant [5 x i8] c"Ponk\00"
11
12define i8* @test1() {
13 %tmp3 = tail call i8* @strchr( i8* getelementptr ([5 x i8]* @str, i32 0, i32 2), i32 103 ) ; <i8*> [#uses=1]
14 ret i8* %tmp3
15}
16
17declare i8* @strchr(i8*, i32)
18
19define i8* @test2() {
20 %tmp3 = tail call i8* @strchr( i8* getelementptr ([8 x i8]* @str1, i32 0, i32 2), i32 0 ) ; <i8*> [#uses=1]
21 ret i8* %tmp3
22}
23
24define i8* @test3() {
25entry:
26 %tmp3 = tail call i8* @strchr( i8* getelementptr ([5 x i8]* @str2, i32 0, i32 1), i32 80 ) ; <i8*> [#uses=1]
27 ret i8* %tmp3
28}
29