blob: 16c0c67970db887f946e4096dbb6c75ae604a1e9 [file] [log] [blame]
Meador Inge05a625a2012-10-31 14:58:26 +00001; Test that the strto* library call simplifiers works correctly.
2;
3; RUN: opt < %s -instcombine -S | FileCheck %s
4
5target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
6
7declare i64 @strtol(i8* %s, i8** %endptr, i32 %base)
8; CHECK: declare i64 @strtol(i8*, i8**, i32)
9
10declare double @strtod(i8* %s, i8** %endptr, i32 %base)
11; CHECK: declare double @strtod(i8*, i8**, i32)
12
13declare float @strtof(i8* %s, i8** %endptr, i32 %base)
14; CHECK: declare float @strtof(i8*, i8**, i32)
15
16declare i64 @strtoul(i8* %s, i8** %endptr, i32 %base)
17; CHECK: declare i64 @strtoul(i8*, i8**, i32)
18
19declare i64 @strtoll(i8* %s, i8** %endptr, i32 %base)
20; CHECK: declare i64 @strtoll(i8*, i8**, i32)
21
22declare double @strtold(i8* %s, i8** %endptr)
23; CHECK: declare double @strtold(i8*, i8**)
24
25declare i64 @strtoull(i8* %s, i8** %endptr, i32 %base)
26; CHECK: declare i64 @strtoull(i8*, i8**, i32)
27
28define void @test_simplify1(i8* %x, i8** %endptr) {
29; CHECK: @test_simplify1
30 call i64 @strtol(i8* %x, i8** null, i32 10)
31; CHECK-NEXT: call i64 @strtol(i8* nocapture %x, i8** null, i32 10)
32 ret void
33}
34
35define void @test_simplify2(i8* %x, i8** %endptr) {
36; CHECK: @test_simplify2
37 call double @strtod(i8* %x, i8** null, i32 10)
38; CHECK-NEXT: call double @strtod(i8* nocapture %x, i8** null, i32 10)
39 ret void
40}
41
42define void @test_simplify3(i8* %x, i8** %endptr) {
43; CHECK: @test_simplify3
44 call float @strtof(i8* %x, i8** null, i32 10)
45; CHECK-NEXT: call float @strtof(i8* nocapture %x, i8** null, i32 10)
46 ret void
47}
48
49define void @test_simplify4(i8* %x, i8** %endptr) {
50; CHECK: @test_simplify4
51 call i64 @strtoul(i8* %x, i8** null, i32 10)
52; CHECK-NEXT: call i64 @strtoul(i8* nocapture %x, i8** null, i32 10)
53 ret void
54}
55
56define void @test_simplify5(i8* %x, i8** %endptr) {
57; CHECK: @test_simplify5
58 call i64 @strtoll(i8* %x, i8** null, i32 10)
59; CHECK-NEXT: call i64 @strtoll(i8* nocapture %x, i8** null, i32 10)
60 ret void
61}
62
63define void @test_simplify6(i8* %x, i8** %endptr) {
64; CHECK: @test_simplify6
65 call double @strtold(i8* %x, i8** null)
66; CHECK-NEXT: call double @strtold(i8* nocapture %x, i8** null)
67 ret void
68}
69
70define void @test_simplify7(i8* %x, i8** %endptr) {
71; CHECK: @test_simplify7
72 call i64 @strtoull(i8* %x, i8** null, i32 10)
73; CHECK-NEXT: call i64 @strtoull(i8* nocapture %x, i8** null, i32 10)
74 ret void
75}
76
77define void @test_no_simplify1(i8* %x, i8** %endptr) {
78; CHECK: @test_no_simplify1
79 call i64 @strtol(i8* %x, i8** %endptr, i32 10)
80; CHECK-NEXT: call i64 @strtol(i8* %x, i8** %endptr, i32 10)
81 ret void
82}