Cameron Esfahani | 17177d1 | 2015-02-05 02:09:33 +0000 | [diff] [blame] | 1 | ; RUN: opt -S -inline < %s | FileCheck %s |
Chandler Carruth | 625038d | 2016-12-27 07:18:43 +0000 | [diff] [blame] | 2 | ; RUN: opt -S -passes='cgscc(inline)' < %s | FileCheck %s |
Cameron Esfahani | 17177d1 | 2015-02-05 02:09:33 +0000 | [diff] [blame] | 3 | ; Make sure that soft float implementations are calculated as being more expensive |
| 4 | ; to the inliner. |
| 5 | |
| 6 | define i32 @test_nofp() #0 { |
| 7 | ; f_nofp() has the "use-soft-float" attribute, so it should never get inlined. |
| 8 | ; CHECK-LABEL: test_nofp |
| 9 | ; CHECK: call float @f_nofp |
| 10 | entry: |
| 11 | %responseX = alloca i32, align 4 |
| 12 | %responseY = alloca i32, align 4 |
| 13 | %responseZ = alloca i32, align 4 |
| 14 | %valueX = alloca i8, align 1 |
| 15 | %valueY = alloca i8, align 1 |
| 16 | %valueZ = alloca i8, align 1 |
| 17 | |
| 18 | call void @getX(i32* %responseX, i8* %valueX) |
| 19 | call void @getY(i32* %responseY, i8* %valueY) |
| 20 | call void @getZ(i32* %responseZ, i8* %valueZ) |
| 21 | |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 22 | %0 = load i32, i32* %responseX |
| 23 | %1 = load i8, i8* %valueX |
Cameron Esfahani | 17177d1 | 2015-02-05 02:09:33 +0000 | [diff] [blame] | 24 | %call = call float @f_nofp(i32 %0, i8 zeroext %1) |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 25 | %2 = load i32, i32* %responseZ |
| 26 | %3 = load i8, i8* %valueZ |
Cameron Esfahani | 17177d1 | 2015-02-05 02:09:33 +0000 | [diff] [blame] | 27 | %call2 = call float @f_nofp(i32 %2, i8 zeroext %3) |
| 28 | %call3 = call float @fabsf(float %call) |
| 29 | %cmp = fcmp ogt float %call3, 0x3FC1EB8520000000 |
| 30 | br i1 %cmp, label %if.end12, label %if.else |
| 31 | |
| 32 | if.else: ; preds = %entry |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 33 | %4 = load i32, i32* %responseY |
| 34 | %5 = load i8, i8* %valueY |
Cameron Esfahani | 17177d1 | 2015-02-05 02:09:33 +0000 | [diff] [blame] | 35 | %call1 = call float @f_nofp(i32 %4, i8 zeroext %5) |
| 36 | %call4 = call float @fabsf(float %call1) |
| 37 | %cmp5 = fcmp ogt float %call4, 0x3FC1EB8520000000 |
| 38 | br i1 %cmp5, label %if.end12, label %if.else7 |
| 39 | |
| 40 | if.else7: ; preds = %if.else |
| 41 | %call8 = call float @fabsf(float %call2) |
| 42 | %cmp9 = fcmp ogt float %call8, 0x3FC1EB8520000000 |
| 43 | br i1 %cmp9, label %if.then10, label %if.end12 |
| 44 | |
| 45 | if.then10: ; preds = %if.else7 |
| 46 | br label %if.end12 |
| 47 | |
| 48 | if.end12: ; preds = %if.else, %entry, %if.then10, %if.else7 |
| 49 | %success.0 = phi i32 [ 0, %if.then10 ], [ 1, %if.else7 ], [ 0, %entry ], [ 0, %if.else ] |
| 50 | ret i32 %success.0 |
| 51 | } |
| 52 | |
| 53 | define i32 @test_hasfp() #0 { |
| 54 | ; f_hasfp() does not have the "use-soft-float" attribute, so it should get inlined. |
| 55 | ; CHECK-LABEL: test_hasfp |
| 56 | ; CHECK-NOT: call float @f_hasfp |
| 57 | entry: |
| 58 | %responseX = alloca i32, align 4 |
| 59 | %responseY = alloca i32, align 4 |
| 60 | %responseZ = alloca i32, align 4 |
| 61 | %valueX = alloca i8, align 1 |
| 62 | %valueY = alloca i8, align 1 |
| 63 | %valueZ = alloca i8, align 1 |
| 64 | |
| 65 | call void @getX(i32* %responseX, i8* %valueX) |
| 66 | call void @getY(i32* %responseY, i8* %valueY) |
| 67 | call void @getZ(i32* %responseZ, i8* %valueZ) |
| 68 | |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 69 | %0 = load i32, i32* %responseX |
| 70 | %1 = load i8, i8* %valueX |
Cameron Esfahani | 17177d1 | 2015-02-05 02:09:33 +0000 | [diff] [blame] | 71 | %call = call float @f_hasfp(i32 %0, i8 zeroext %1) |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 72 | %2 = load i32, i32* %responseZ |
| 73 | %3 = load i8, i8* %valueZ |
Cameron Esfahani | 17177d1 | 2015-02-05 02:09:33 +0000 | [diff] [blame] | 74 | %call2 = call float @f_hasfp(i32 %2, i8 zeroext %3) |
| 75 | %call3 = call float @fabsf(float %call) |
| 76 | %cmp = fcmp ogt float %call3, 0x3FC1EB8520000000 |
| 77 | br i1 %cmp, label %if.end12, label %if.else |
| 78 | |
| 79 | if.else: ; preds = %entry |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 80 | %4 = load i32, i32* %responseY |
| 81 | %5 = load i8, i8* %valueY |
Cameron Esfahani | 17177d1 | 2015-02-05 02:09:33 +0000 | [diff] [blame] | 82 | %call1 = call float @f_hasfp(i32 %4, i8 zeroext %5) |
| 83 | %call4 = call float @fabsf(float %call1) |
| 84 | %cmp5 = fcmp ogt float %call4, 0x3FC1EB8520000000 |
| 85 | br i1 %cmp5, label %if.end12, label %if.else7 |
| 86 | |
| 87 | if.else7: ; preds = %if.else |
| 88 | %call8 = call float @fabsf(float %call2) |
| 89 | %cmp9 = fcmp ogt float %call8, 0x3FC1EB8520000000 |
| 90 | br i1 %cmp9, label %if.then10, label %if.end12 |
| 91 | |
| 92 | if.then10: ; preds = %if.else7 |
| 93 | br label %if.end12 |
| 94 | |
| 95 | if.end12: ; preds = %if.else, %entry, %if.then10, %if.else7 |
| 96 | %success.0 = phi i32 [ 0, %if.then10 ], [ 1, %if.else7 ], [ 0, %entry ], [ 0, %if.else ] |
| 97 | ret i32 %success.0 |
| 98 | } |
| 99 | |
| 100 | declare void @getX(i32*, i8*) #0 |
| 101 | |
| 102 | declare void @getY(i32*, i8*) #0 |
| 103 | |
| 104 | declare void @getZ(i32*, i8*) #0 |
| 105 | |
| 106 | define internal float @f_hasfp(i32 %response, i8 zeroext %value1) #0 { |
| 107 | entry: |
| 108 | %conv = zext i8 %value1 to i32 |
| 109 | %sub = add nsw i32 %conv, -1 |
| 110 | %conv1 = sitofp i32 %sub to float |
| 111 | %0 = tail call float @llvm.pow.f32(float 0x3FF028F5C0000000, float %conv1) |
| 112 | %mul = fmul float %0, 2.620000e+03 |
| 113 | %conv2 = sitofp i32 %response to float |
| 114 | %sub3 = fsub float %conv2, %mul |
| 115 | %div = fdiv float %sub3, %mul |
| 116 | ret float %div |
| 117 | } |
| 118 | |
| 119 | define internal float @f_nofp(i32 %response, i8 zeroext %value1) #1 { |
| 120 | entry: |
| 121 | %conv = zext i8 %value1 to i32 |
| 122 | %sub = add nsw i32 %conv, -1 |
| 123 | %conv1 = sitofp i32 %sub to float |
| 124 | %0 = tail call float @llvm.pow.f32(float 0x3FF028F5C0000000, float %conv1) |
| 125 | %mul = fmul float %0, 2.620000e+03 |
| 126 | %conv2 = sitofp i32 %response to float |
| 127 | %sub3 = fsub float %conv2, %mul |
| 128 | %div = fdiv float %sub3, %mul |
| 129 | ret float %div |
| 130 | } |
| 131 | |
| 132 | declare float @fabsf(float) optsize minsize |
| 133 | |
| 134 | declare float @llvm.pow.f32(float, float) optsize minsize |
| 135 | |
James Molloy | 6bed13c | 2016-11-28 11:07:37 +0000 | [diff] [blame] | 136 | attributes #0 = { optsize } |
| 137 | attributes #1 = { optsize "use-soft-float"="true" } |