Meador Inge | 05a625a | 2012-10-31 14:58:26 +0000 | [diff] [blame] | 1 | ; Test that the strto* library call simplifiers works correctly. |
| 2 | ; |
Meador Inge | 6b6a161 | 2013-03-21 00:55:59 +0000 | [diff] [blame] | 3 | ; RUN: opt < %s -instcombine -functionattrs -S | FileCheck %s |
Meador Inge | 05a625a | 2012-10-31 14:58:26 +0000 | [diff] [blame] | 4 | |
| 5 | target 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 | |
| 7 | declare i64 @strtol(i8* %s, i8** %endptr, i32 %base) |
Nick Lewycky | c2ec072 | 2013-07-06 00:29:58 +0000 | [diff] [blame] | 8 | ; CHECK: declare i64 @strtol(i8* readonly, i8** nocapture, i32) |
Meador Inge | 05a625a | 2012-10-31 14:58:26 +0000 | [diff] [blame] | 9 | |
| 10 | declare double @strtod(i8* %s, i8** %endptr, i32 %base) |
Nick Lewycky | c2ec072 | 2013-07-06 00:29:58 +0000 | [diff] [blame] | 11 | ; CHECK: declare double @strtod(i8* readonly, i8** nocapture, i32) |
Meador Inge | 05a625a | 2012-10-31 14:58:26 +0000 | [diff] [blame] | 12 | |
| 13 | declare float @strtof(i8* %s, i8** %endptr, i32 %base) |
Nick Lewycky | c2ec072 | 2013-07-06 00:29:58 +0000 | [diff] [blame] | 14 | ; CHECK: declare float @strtof(i8* readonly, i8** nocapture, i32) |
Meador Inge | 05a625a | 2012-10-31 14:58:26 +0000 | [diff] [blame] | 15 | |
| 16 | declare i64 @strtoul(i8* %s, i8** %endptr, i32 %base) |
Nick Lewycky | c2ec072 | 2013-07-06 00:29:58 +0000 | [diff] [blame] | 17 | ; CHECK: declare i64 @strtoul(i8* readonly, i8** nocapture, i32) |
Meador Inge | 05a625a | 2012-10-31 14:58:26 +0000 | [diff] [blame] | 18 | |
| 19 | declare i64 @strtoll(i8* %s, i8** %endptr, i32 %base) |
Nick Lewycky | c2ec072 | 2013-07-06 00:29:58 +0000 | [diff] [blame] | 20 | ; CHECK: declare i64 @strtoll(i8* readonly, i8** nocapture, i32) |
Meador Inge | 05a625a | 2012-10-31 14:58:26 +0000 | [diff] [blame] | 21 | |
| 22 | declare double @strtold(i8* %s, i8** %endptr) |
Nick Lewycky | c2ec072 | 2013-07-06 00:29:58 +0000 | [diff] [blame] | 23 | ; CHECK: declare double @strtold(i8* readonly, i8** nocapture) |
Meador Inge | 05a625a | 2012-10-31 14:58:26 +0000 | [diff] [blame] | 24 | |
| 25 | declare i64 @strtoull(i8* %s, i8** %endptr, i32 %base) |
Nick Lewycky | c2ec072 | 2013-07-06 00:29:58 +0000 | [diff] [blame] | 26 | ; CHECK: declare i64 @strtoull(i8* readonly, i8** nocapture, i32) |
Meador Inge | 05a625a | 2012-10-31 14:58:26 +0000 | [diff] [blame] | 27 | |
| 28 | define void @test_simplify1(i8* %x, i8** %endptr) { |
Stephen Lin | c1c7a13 | 2013-07-14 01:42:54 +0000 | [diff] [blame] | 29 | ; CHECK-LABEL: @test_simplify1( |
Meador Inge | 05a625a | 2012-10-31 14:58:26 +0000 | [diff] [blame] | 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 | |
| 35 | define void @test_simplify2(i8* %x, i8** %endptr) { |
Stephen Lin | c1c7a13 | 2013-07-14 01:42:54 +0000 | [diff] [blame] | 36 | ; CHECK-LABEL: @test_simplify2( |
Meador Inge | 05a625a | 2012-10-31 14:58:26 +0000 | [diff] [blame] | 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 | |
| 42 | define void @test_simplify3(i8* %x, i8** %endptr) { |
Stephen Lin | c1c7a13 | 2013-07-14 01:42:54 +0000 | [diff] [blame] | 43 | ; CHECK-LABEL: @test_simplify3( |
Meador Inge | 05a625a | 2012-10-31 14:58:26 +0000 | [diff] [blame] | 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 | |
| 49 | define void @test_simplify4(i8* %x, i8** %endptr) { |
Stephen Lin | c1c7a13 | 2013-07-14 01:42:54 +0000 | [diff] [blame] | 50 | ; CHECK-LABEL: @test_simplify4( |
Meador Inge | 05a625a | 2012-10-31 14:58:26 +0000 | [diff] [blame] | 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 | |
| 56 | define void @test_simplify5(i8* %x, i8** %endptr) { |
Stephen Lin | c1c7a13 | 2013-07-14 01:42:54 +0000 | [diff] [blame] | 57 | ; CHECK-LABEL: @test_simplify5( |
Meador Inge | 05a625a | 2012-10-31 14:58:26 +0000 | [diff] [blame] | 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 | |
| 63 | define void @test_simplify6(i8* %x, i8** %endptr) { |
Stephen Lin | c1c7a13 | 2013-07-14 01:42:54 +0000 | [diff] [blame] | 64 | ; CHECK-LABEL: @test_simplify6( |
Meador Inge | 05a625a | 2012-10-31 14:58:26 +0000 | [diff] [blame] | 65 | call double @strtold(i8* %x, i8** null) |
| 66 | ; CHECK-NEXT: call double @strtold(i8* nocapture %x, i8** null) |
| 67 | ret void |
| 68 | } |
| 69 | |
| 70 | define void @test_simplify7(i8* %x, i8** %endptr) { |
Stephen Lin | c1c7a13 | 2013-07-14 01:42:54 +0000 | [diff] [blame] | 71 | ; CHECK-LABEL: @test_simplify7( |
Meador Inge | 05a625a | 2012-10-31 14:58:26 +0000 | [diff] [blame] | 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 | |
| 77 | define void @test_no_simplify1(i8* %x, i8** %endptr) { |
Stephen Lin | c1c7a13 | 2013-07-14 01:42:54 +0000 | [diff] [blame] | 78 | ; CHECK-LABEL: @test_no_simplify1( |
Meador Inge | 05a625a | 2012-10-31 14:58:26 +0000 | [diff] [blame] | 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 | } |