llvm.org GIT mirror llvm / 39f4e8d
Update Transforms tests to use CHECK-LABEL for easier debugging. No functionality change. This update was done with the following bash script: find test/Transforms -name "*.ll" | \ while read NAME; do echo "$NAME" if ! grep -q "^; *RUN: *llc" $NAME; then TEMP=`mktemp -t temp` cp $NAME $TEMP sed -n "s/^define [^@]*@\([A-Za-z0-9_]*\)(.*$/\1/p" < $NAME | \ while read FUNC; do sed -i '' "s/;\(.*\)\([A-Za-z0-9_]*\):\( *\)@$FUNC\([( ]*\)\$/;\1\2-LABEL:\3@$FUNC(/g" $TEMP done mv $TEMP $NAME fi done git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186268 91177308-0d34-0410-b5e6-96231b3b80d8 Stephen Lin 6 years ago
444 changed file(s) with 2479 addition(s) and 2479 deletion(s). Raw diff Collapse all Expand all
1010 %tobool21 = icmp ne %"struct.btSoftBody"* %n2, null
1111 %cond22 = zext i1 %tobool21 to i32
1212 ret void
13 ; CHECK: @test1
13 ; CHECK-LABEL: @test1(
1414 }
1515
66 define void @test1(double* noalias %out, double* noalias %in1, double* noalias %in2) nounwind uwtable {
77 entry:
88 br label %for.body
9 ; CHECK: @test1
10 ; CHECK-UNRL: @test1
9 ; CHECK-LABEL: @test1(
10 ; CHECK-UNRL-LABEL: @test1(
1111
1212 for.body: ; preds = %for.body, %entry
1313 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
4545
4646 return: ; preds = %entry
4747 ret void
48 ; CHECK: @ptoa
48 ; CHECK-LABEL: @ptoa(
4949 }
5050
5151 declare noalias i8* @malloc() nounwind
7676 %and390 = shl i8 %conv3898, 6
7777 store i8 %and390, i8* %incdec.ptr387, align 1
7878 unreachable
79 ; CHECK: @gsm_encode
79 ; CHECK-LABEL: @gsm_encode(
8080 }
8181
8282 declare void @Gsm_Coder(%struct.gsm_state.2.8.14.15.16.17.19.22.23.25.26.28.29.31.32.33.35.36.37.38.40.41.42.44.45.47.48.50.52.53.54.56.57.58.59.60.61.62.63.66.73.83.84.89.90.91.92.93.94.95.96.99.100.101.102.103.104.106.107.114.116.121.122.129.130.135.136.137.138.139.140.141.142.143.144.147.148.149.158.159.160.161.164.165.166.167.168.169.172.179.181.182.183.188.195.200.201.202.203.204.205.208.209.210.212.213.214.215.222.223.225.226.230.231.232.233.234.235.236.237.238.239.240.241.242.243.244.352*, i16*, i16*, i16*, i16*, i16*, i16*, i16*)
161161 %conv365 = trunc i32 %or364 to i8
162162 store i8 %conv365, i8* %incdec.ptr350, align 1
163163 unreachable
164 ; CHECK: @gsm_encode
164 ; CHECK-LABEL: @gsm_encode(
165165 }
166166
167167 declare void @Gsm_Coder(%struct.gsm_state.2.8.39.44.45.55.56.57.58.59.62.63.64.65.74.75.76.77.80.87.92.93.94.95.96.97.110.111.112.113.114.128.130.135.136.137.138.139.140.141.142.143.144.145.148.149.150.151.152.169.170.177.178.179.184.185.186.187.188.201.208.209.219.220.221.223.224.225.230.231.232.233.235.236.237.238.245.246.248.249.272.274.279.280.281.282.283.286.293.298.299.314.315.316.317.318.319.320.321.322.323.324.325.326.327.328.329.330.331.332.333.334.335.336.337.338.339.340.341.342.343.344.345.346.347.348.349.350.351.352.353.565*, i16*, i16*, i16*, i16*, i16*, i16*, i16*)
1717
1818 %R = fmul <4 x float> %Y1, %Y2
1919 ret <4 x float> %R
20 ; CHECK: @test7
20 ; CHECK-LABEL: @test7(
2121 ; CHECK-NOT: <8 x float>
2222 ; CHECK: ret <4 x float>
2323 }
1515 %Z2 = fadd double %Y2, %B2
1616 %R = fmul double %Z1, %Z2
1717 ret double %R
18 ; CHECK: @test1
18 ; CHECK-LABEL: @test1(
1919 ; CHECK: ret double %R
2020 }
2121
2929 %Z2 = fadd double %Y2, %B2
3030 %R = fmul double %Z1, %Z2
3131 ret double %R
32 ; CHECK: @test1a
32 ; CHECK-LABEL: @test1a(
3333 ; CHECK: ret double %R
3434 }
3535
4343 %Z2 = fadd double %Y2, %B2
4444 %R = fmul double %Z1, %Z2
4545 ret double %R
46 ; CHECK: @test2
46 ; CHECK-LABEL: @test2(
4747 ; CHECK: ret double %R
4848 }
4949
5757 %Z2 = fadd double %Y2, %B2
5858 %R = fmul double %Z1, %Z2
5959 ret double %R
60 ; CHECK: @test3
60 ; CHECK-LABEL: @test3(
6161 ; CHECK: ret double %R
6262 }
6363
7272 %Z2 = fadd double %Y2, %B2
7373 %R = fmul double %Z1, %Z2
7474 ret double %R
75 ; CHECK: @test4
75 ; CHECK-LABEL: @test4(
7676 ; CHECK: ret double %R
7777 }
7878
1515 %arrayidx5 = getelementptr inbounds double* %c, i64 1
1616 store double %mul5, double* %arrayidx5, align 8
1717 ret void
18 ; CHECK: @test1
18 ; CHECK-LABEL: @test1(
1919 ; CHECK: %i0.v.i0 = bitcast double* %a to <2 x double>*
2020 ; CHECK: %i1.v.i0 = bitcast double* %b to <2 x double>*
2121 ; CHECK: %i0 = load <2 x double>* %i0.v.i0, align 8
1010 %Z2 = fadd double %Y2, %B2
1111 %R = fmul double %Z1, %Z2
1212 ret double %R
13 ; CHECK: @test1
13 ; CHECK-LABEL: @test1(
1414 ; CHECK: fsub <2 x double>
1515 ; CHECK: fmul <2 x double>
1616 ; CHECK: fadd <2 x double>
3737 %S2 = fadd double %W2, %Q2
3838 %R = fmul double %S1, %S2
3939 ret double %R
40 ; CHECK: @test1a
40 ; CHECK-LABEL: @test1a(
4141 ; CHECK: %X1.v.i1.1 = insertelement <2 x double> undef, double %B1, i32 0
4242 ; CHECK: %X1.v.i1.2 = insertelement <2 x double> %X1.v.i1.1, double %B2, i32 1
4343 ; CHECK: %X1.v.i0.1 = insertelement <2 x double> undef, double %A1, i32 0
6565 %Z2 = fadd double %Y1, %B2
6666 %R = fmul double %Z1, %Z2
6767 ret double %R
68 ; CHECK: @test2
68 ; CHECK-LABEL: @test2(
6969 ; CHECK: insertelement
7070 ; CHECK: insertelement
7171 ; CHECK: insertelement
8787 %W2 = fadd double %Y1, %Z2
8888 %R = fmul double %Z1, %Z2
8989 ret double %R
90 ; CHECK: @test4
90 ; CHECK-LABEL: @test4(
9191 ; CHECK: insertelement
9292 ; CHECK: insertelement
9393 ; CHECK: insertelement
112112 %Q2 = shufflevector <8 x i8> %Z2, <8 x i8> %Z2, <8 x i32>
113113 %R = mul <8 x i8> %Q1, %Q2
114114 ret <8 x i8> %R
115 ; CHECK: @test6
115 ; CHECK-LABEL: @test6(
116116 ; CHECK-NOT: sub <16 x i8>
117117 ; CHECK: ret <8 x i8>
118118 }
66 %0 = bitcast <2 x i64> undef to i128
77 %1 = bitcast <2 x i64> undef to i128
88 ret void
9 ; CHECK: @main
9 ; CHECK-LABEL: @main(
1010 }
1111
104104 br i1 %or.cond, label %done, label %go
105105 done:
106106 ret void
107 ; CHECK: @test1
107 ; CHECK-LABEL: @test1(
108108 ; CHECK: go:
109109 ; CHECK: %conv.v.i0.1 = insertelement <2 x i32> undef, i32 %n.0, i32 0
110110 ; FIXME: When tree pruning is deterministic, include the entire output.
2121 %add15 = fadd double %mul13, %i5
2222 %mul16 = fmul double %add11, %add15
2323 ret double %mul16
24 ; CHECK: @test1
24 ; CHECK-LABEL: @test1(
2525 ; CHECK: %i0.v.i0 = bitcast double* %a to <2 x double>*
2626 ; CHECK: %i1.v.i0 = bitcast double* %b to <2 x double>*
2727 ; CHECK: %i2.v.i0 = bitcast double* %c to <2 x double>*
66 define void @test1(double* noalias %out, double* noalias %in1, double* noalias %in2) nounwind uwtable {
77 entry:
88 br label %for.body
9 ; CHECK: @test1
10 ; CHECK-UNRL: @test1
9 ; CHECK-LABEL: @test1(
10 ; CHECK-UNRL-LABEL: @test1(
1111
1212 for.body: ; preds = %for.body, %entry
1313 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
55 @B = common global [1024 x float] zeroinitializer, align 16
66
77 define i32 @test1() nounwind {
8 ; CHECK: @test1
8 ; CHECK-LABEL: @test1(
99 %V1 = load float* getelementptr inbounds ([1024 x float]* @A, i64 0, i64 0), align 16
1010 %V2 = load float* getelementptr inbounds ([1024 x float]* @A, i64 0, i64 1), align 4
1111 %V3= load float* getelementptr inbounds ([1024 x float]* @A, i64 0, i64 2), align 8
1515 %arrayidx5 = getelementptr inbounds double* %c, i64 1
1616 store double %mul5, double* %arrayidx5, align 8
1717 ret void
18 ; CHECK: @test1
18 ; CHECK-LABEL: @test1(
1919 ; CHECK: !fpmath
2020 ; CHECK: ret void
2121 }
3535 %arrayidx5 = getelementptr inbounds i64* %c, i64 1
3636 store i64 %mul5, i64* %arrayidx5, align 8
3737 ret void
38 ; CHECK: @test2
38 ; CHECK-LABEL: @test2(
3939 ; CHECK-NOT: !range
4040 ; CHECK: ret void
4141 }
1616 store i64 %v3a, i64* %a3, align 8
1717 %r = add i64 %v2, %v3
1818 ret i64 %r
19 ; CHECK: @test2
19 ; CHECK-LABEL: @test2(
2020 ; CHECK-NOT: getelementptr <2 x i64*>
2121 }
2222
88 %Y2 = fmul double %X2, %A2
99 %R = fmul double %Y1, %Y2
1010 ret double %R
11 ; CHECK-RD3: @test1
12 ; CHECK-RD2: @test1
11 ; CHECK-RD3-LABEL: @test1(
12 ; CHECK-RD2-LABEL: @test1(
1313 ; CHECK-RD3-NOT: <2 x double>
1414 ; CHECK-RD2: <2 x double>
1515 }
22 ; RUN: opt < %s -bb-vectorize -bb-vectorize-req-chain-depth=3 -bb-vectorize-search-limit=4 -bb-vectorize-ignore-target-info -instcombine -gvn -S | FileCheck %s -check-prefix=CHECK-SL4
33
44 define double @test1(double %A1, double %A2, double %B1, double %B2) {
5 ; CHECK: @test1
6 ; CHECK-SL4: @test1
5 ; CHECK-LABEL: @test1(
6 ; CHECK-SL4-LABEL: @test1(
77 ; CHECK-SL4-NOT: <2 x double>
88 ; CHECK: %X1.v.i1.1 = insertelement <2 x double> undef, double %B1, i32 0
99 ; CHECK: %X1.v.i1.2 = insertelement <2 x double> %X1.v.i1.1, double %B2, i32 1
1515 %Z2 = fadd double %Y2, %B2
1616 %R = fmul double %Z1, %Z2
1717 ret double %R
18 ; CHECK: @test1
18 ; CHECK-LABEL: @test1(
1919 ; CHECK: %X1.v.i1.1 = insertelement <2 x double> undef, double %B1, i32 0
2020 ; CHECK: %X1.v.i1.2 = insertelement <2 x double> %X1.v.i1.1, double %B2, i32 1
2121 ; CHECK: %X1.v.i0.1 = insertelement <2 x double> undef, double %A1, i32 0
4141 %Z2 = fadd double %Y2, %B2
4242 %R = fmul double %Z1, %Z2
4343 ret double %R
44 ; CHECK: @test1a
44 ; CHECK-LABEL: @test1a(
4545 ; CHECK: %X1.v.i1.1 = insertelement <2 x double> undef, double %B1, i32 0
4646 ; CHECK: %X1.v.i1.2 = insertelement <2 x double> %X1.v.i1.1, double %B2, i32 1
4747 ; CHECK: %X1.v.i0.1 = insertelement <2 x double> undef, double %A1, i32 0
6767 %Z2 = fadd double %Y2, %B2
6868 %R = fmul double %Z1, %Z2
6969 ret double %R
70 ; CHECK: @test2
70 ; CHECK-LABEL: @test2(
7171 ; CHECK: %X1.v.i1.1 = insertelement <2 x double> undef, double %B1, i32 0
7272 ; CHECK: %X1.v.i1.2 = insertelement <2 x double> %X1.v.i1.1, double %B2, i32 1
7373 ; CHECK: %X1.v.i0.1 = insertelement <2 x double> undef, double %A1, i32 0
9292 %Z2 = fadd double %Y2, %B2
9393 %R = fmul double %Z1, %Z2
9494 ret double %R
95 ; CHECK: @test3
95 ; CHECK-LABEL: @test3(
9696 ; CHECK: %X1.v.i1.1 = insertelement <2 x double> undef, double %B1, i32 0
9797 ; CHECK: %X1.v.i1.2 = insertelement <2 x double> %X1.v.i1.1, double %B2, i32 1
9898 ; CHECK: %X1.v.i0.1 = insertelement <2 x double> undef, double %A1, i32 0
118118 %Z2 = fadd double %Y2, %B2
119119 %R = fmul double %Z1, %Z2
120120 ret double %R
121 ; CHECK: @test4
121 ; CHECK-LABEL: @test4(
122122 ; CHECK-NOT: <2 x double>
123123 ; CHECK: ret double %R
124124 }
2626 %arrayidx5 = getelementptr inbounds i64* %c, i64 1
2727 store i64 %mul5, i64* %arrayidx5, align 8
2828 ret double %r
29 ; CHECK: @test1
29 ; CHECK-LABEL: @test1(
3030 ; CHECK: %i0.v.i0 = bitcast i64* %a to <2 x i64>*
3131 ; CHECK: %i1.v.i0 = bitcast i64* %b to <2 x i64>*
3232 ; CHECK: %i0 = load <2 x i64>* %i0.v.i0, align 8
4242 ; CHECK: %0 = bitcast i64* %c to <2 x i64>*
4343 ; CHECK: store <2 x i64> %mul, <2 x i64>* %0, align 8
4444 ; CHECK: ret double %r
45 ; CHECK-AO: @test1
45 ; CHECK-AO-LABEL: @test1(
4646 ; CHECK-AO-NOT: load <2 x
4747 }
4848
6363 %arrayidx5 = getelementptr inbounds i64** %c, i64 1
6464 store i64* %ptr3, i64** %arrayidx5, align 8
6565 ret void
66 ; CHECK: @test2
66 ; CHECK-LABEL: @test2(
6767 ; CHECK: %i0.v.i0 = bitcast i64** %a to <2 x i64*>*
6868 ; CHECK: %i1 = load i64** %b, align 8
6969 ; CHECK: %i0 = load <2 x i64*>* %i0.v.i0, align 8
7777 ; CHECK: %0 = bitcast i64** %c to <2 x i64*>*
7878 ; CHECK: store <2 x i64*> %ptr0, <2 x i64*>* %0, align 8
7979 ; CHECK: ret void
80 ; CHECK-AO: @test2
80 ; CHECK-AO-LABEL: @test2(
8181 ; CHECK-AO-NOT: <2 x
8282 }
8383
107107 %arrayidx5 = getelementptr inbounds <2 x i64*>* %c, i64 1
108108 store <2 x i64*> %rtr3, <2 x i64*>* %arrayidx5, align 8
109109 ret void
110 ; CHECK: @test3
110 ; CHECK-LABEL: @test3(
111111 ; CHECK: %i0.v.i0 = bitcast <2 x i64*>* %a to <4 x i64*>*
112112 ; CHECK: %i1 = load <2 x i64*>* %b, align 8
113113 ; CHECK: %i0 = load <4 x i64*>* %i0.v.i0, align 8
127127 ; CHECK: %1 = shufflevector <2 x i64*> %rtr0, <2 x i64*> %rtr3, <4 x i32>
128128 ; CHECK: store <4 x i64*> %1, <4 x i64*>* %0, align 8
129129 ; CHECK: ret void
130 ; CHECK-AO: @test3
130 ; CHECK-AO-LABEL: @test3(
131131 ; CHECK-AO-NOT: <4 x
132132 }
133133
1616 %arrayidx5 = getelementptr inbounds double* %c, i64 1
1717 store double %mul5, double* %arrayidx5, align 8
1818 ret void
19 ; CHECK: @test1
19 ; CHECK-LABEL: @test1(
2020 ; CHECK: %i0.v.i0 = bitcast double* %a to <2 x double>*
2121 ; CHECK: %i1.v.i0 = bitcast double* %b to <2 x double>*
2222 ; CHECK: %i0 = load <2 x double>* %i0.v.i0, align 8
2525 ; CHECK: %0 = bitcast double* %c to <2 x double>*
2626 ; CHECK: store <2 x double> %mul, <2 x double>* %0, align 8
2727 ; CHECK: ret void
28 ; CHECK-AO: @test1
28 ; CHECK-AO-LABEL: @test1(
2929 ; CHECK-AO-NOT: <2 x double>
3030 }
3131
4848 %arrayidx5 = getelementptr inbounds double* %c, i64 1
4949 store double %mul5, double* %arrayidx5, align 8
5050 ret void
51 ; CHECK: @test2
51 ; CHECK-LABEL: @test2(
5252 ; CHECK: %i0f.v.i0 = bitcast float* %a to <2 x float>*
5353 ; CHECK: %i1f.v.i0 = bitcast float* %b to <2 x float>*
5454 ; CHECK: %i0f = load <2 x float>* %i0f.v.i0, align 4
5959 ; CHECK: %0 = bitcast double* %c to <2 x double>*
6060 ; CHECK: store <2 x double> %mul, <2 x double>* %0, align 8
6161 ; CHECK: ret void
62 ; CHECK-AO: @test2
62 ; CHECK-AO-LABEL: @test2(
6363 ; CHECK-AO-NOT: <2 x double>
6464 }
6565
8080 %arrayidx5 = getelementptr inbounds float* %c, i64 1
8181 store float %mul5f, float* %arrayidx5, align 4
8282 ret void
83 ; CHECK: @test3
83 ; CHECK-LABEL: @test3(
8484 ; CHECK: %i0.v.i0 = bitcast double* %a to <2 x double>*
8585 ; CHECK: %i1.v.i0 = bitcast double* %b to <2 x double>*
8686 ; CHECK: %i0 = load <2 x double>* %i0.v.i0, align 8
9090 ; CHECK: %0 = bitcast float* %c to <2 x float>*
9191 ; CHECK: store <2 x float> %mulf, <2 x float>* %0, align 8
9292 ; CHECK: ret void
93 ; CHECK-AO: @test3
93 ; CHECK-AO-LABEL: @test3(
9494 ; CHECK-AO: %i0 = load double* %a, align 8
9595 ; CHECK-AO: %i1 = load double* %b, align 8
9696 ; CHECK-AO: %arrayidx3 = getelementptr inbounds double* %a, i64 1
133133
134134 if.end:
135135 ret void
136 ; CHECK: @test4
136 ; CHECK-LABEL: @test4(
137137 ; CHECK-NOT: <2 x double>
138 ; CHECK-AO: @test4
138 ; CHECK-AO-LABEL: @test4(
139139 ; CHECK-AO-NOT: <2 x double>
140140 }
141141
154154 store double %mul5, double* %arrayidx5, align 8
155155 store double %mul, double* %c, align 4
156156 ret void
157 ; CHECK: @test5
157 ; CHECK-LABEL: @test5(
158158 ; CHECK: %i0.v.i0 = bitcast double* %a to <2 x double>*
159159 ; CHECK: %i1.v.i0 = bitcast double* %b to <2 x double>*
160160 ; CHECK: %i0 = load <2 x double>* %i0.v.i0, align 8
163163 ; CHECK: %0 = bitcast double* %c to <2 x double>*
164164 ; CHECK: store <2 x double> %mul, <2 x double>* %0, align 4
165165 ; CHECK: ret void
166 ; CHECK-AO: @test5
166 ; CHECK-AO-LABEL: @test5(
167167 ; CHECK-AO-NOT: <2 x double>
168168 }
169169
33
44 ; Basic depth-3 chain with select
55 define double @test1(double %A1, double %A2, double %B1, double %B2, i1 %C1, i1 %C2) {
6 ; CHECK: @test1
6 ; CHECK-LABEL: @test1(
77 ; CHECK: %X1.v.i1.1 = insertelement <2 x double> undef, double %B1, i32 0
88 ; CHECK: %X1.v.i1.2 = insertelement <2 x double> %X1.v.i1.1, double %B2, i32 1
99 ; CHECK: %X1.v.i0.1 = insertelement <2 x double> undef, double %A1, i32 0
2929
3030 ; Basic depth-3 chain with select (and vect. compare)
3131 define double @test2(double %A1, double %A2, double %B1, double %B2) {
32 ; CHECK: @test2
33 ; CHECK-NB: @test2
32 ; CHECK-LABEL: @test2(
33 ; CHECK-NB-LABEL: @test2(
3434 ; CHECK: %X1.v.i1.1 = insertelement <2 x double> undef, double %B1, i32 0
3535 ; CHECK: %X1.v.i1.2 = insertelement <2 x double> %X1.v.i1.1, double %B2, i32 1
3636 ; CHECK: %X1.v.i0.1 = insertelement <2 x double> undef, double %A1, i32 0
33
44 ; Basic depth-3 chain (target-specific type should not vectorize)
55 define ppc_fp128 @test7(ppc_fp128 %A1, ppc_fp128 %A2, ppc_fp128 %B1, ppc_fp128 %B2) {
6 ; CHECK: @test7
6 ; CHECK-LABEL: @test7(
77 ; CHECK-NOT: <2 x ppc_fp128>
88 %X1 = fsub ppc_fp128 %A1, %B1
99 %X2 = fsub ppc_fp128 %A2, %B2
22
33 ; Basic depth-3 chain
44 define double @test1(double %A1, double %A2, double %B1, double %B2) {
5 ; CHECK: @test1
5 ; CHECK-LABEL: @test1(
66 ; CHECK: %X1.v.i1.1 = insertelement <2 x double> undef, double %B1, i32 0
77 ; CHECK: %X1.v.i1.2 = insertelement <2 x double> %X1.v.i1.1, double %B2, i32 1
88 ; CHECK: %X1.v.i0.1 = insertelement <2 x double> undef, double %A1, i32 0
2626
2727 ; Basic depth-3 chain (last pair permuted)
2828 define double @test2(double %A1, double %A2, double %B1, double %B2) {
29 ; CHECK: @test2
29 ; CHECK-LABEL: @test2(
3030 ; CHECK: %X1.v.i1.1 = insertelement <2 x double> undef, double %B1, i32 0
3131 ; CHECK: %X1.v.i1.2 = insertelement <2 x double> %X1.v.i1.1, double %B2, i32 1
3232 ; CHECK: %X1.v.i0.1 = insertelement <2 x double> undef, double %A1, i32 0
5252
5353 ; Basic depth-3 chain (last pair first splat)
5454 define double @test3(double %A1, double %A2, double %B1, double %B2) {
55 ; CHECK: @test3
55 ; CHECK-LABEL: @test3(
5656 ; CHECK: %X1.v.i1.1 = insertelement <2 x double> undef, double %B1, i32 0
5757 ; CHECK: %X1.v.i1.2 = insertelement <2 x double> %X1.v.i1.1, double %B2, i32 1
5858 ; CHECK: %X1.v.i0.1 = insertelement <2 x double> undef, double %A1, i32 0
7777
7878 ; Basic depth-3 chain (last pair second splat)
7979 define double @test4(double %A1, double %A2, double %B1, double %B2) {
80 ; CHECK: @test4
80 ; CHECK-LABEL: @test4(
8181 ; CHECK: %X1.v.i1.1 = insertelement <2 x double> undef, double %B1, i32 0
8282 ; CHECK: %X1.v.i1.2 = insertelement <2 x double> %X1.v.i1.1, double %B2, i32 1
8383 ; CHECK: %X1.v.i0.1 = insertelement <2 x double> undef, double %A1, i32 0
102102
103103 ; Basic depth-3 chain
104104 define <2 x float> @test5(<2 x float> %A1, <2 x float> %A2, <2 x float> %B1, <2 x float> %B2) {
105 ; CHECK: @test5
105 ; CHECK-LABEL: @test5(
106106 ; CHECK: %X1.v.i1 = shufflevector <2 x float> %B1, <2 x float> %B2, <4 x i32>
107107 ; CHECK: %X1.v.i0 = shufflevector <2 x float> %A1, <2 x float> %A2, <4 x i32>
108108 %X1 = fsub <2 x float> %A1, %B1
124124
125125 ; Basic chain with shuffles
126126 define <8 x i8> @test6(<8 x i8> %A1, <8 x i8> %A2, <8 x i8> %B1, <8 x i8> %B2) {
127 ; CHECK: @test6
127 ; CHECK-LABEL: @test6(
128128 ; CHECK: %X1.v.i1 = shufflevector <8 x i8> %B1, <8 x i8> %B2, <16 x i32>
129129 ; CHECK: %X1.v.i0 = shufflevector <8 x i8> %A1, <8 x i8> %A2, <16 x i32>
130130 %X1 = sub <8 x i8> %A1, %B1
150150
151151 ; Basic depth-3 chain (flipped order)
152152 define double @test7(double %A1, double %A2, double %B1, double %B2) {
153 ; CHECK: @test7
153 ; CHECK-LABEL: @test7(
154154 ; CHECK: %X1.v.i1.1 = insertelement <2 x double> undef, double %B1, i32 0
155155 ; CHECK: %X1.v.i1.2 = insertelement <2 x double> %X1.v.i1.1, double %B2, i32 1
156156 ; CHECK: %X1.v.i0.1 = insertelement <2 x double> undef, double %A1, i32 0
174174
175175 ; Basic depth-3 chain (subclass data)
176176 define i64 @test8(i64 %A1, i64 %A2, i64 %B1, i64 %B2) {
177 ; CHECK: @test8
177 ; CHECK-LABEL: @test8(
178178 ; CHECK: %X1.v.i1.1 = insertelement <2 x i64> undef, i64 %B1, i32 0
179179 ; CHECK: %X1.v.i1.2 = insertelement <2 x i64> %X1.v.i1.1, i64 %B2, i32 1
180180 ; CHECK: %X1.v.i0.1 = insertelement <2 x i64> undef, i64 %A1, i32 0
22
33 ; Basic depth-3 chain
44 define double @test1(double %A1, double %A2, double %A3, double %B1, double %B2, double %B3) {
5 ; CHECK: @test1
5 ; CHECK-LABEL: @test1(
66 ; CHECK: %X1.v.i1.11 = insertelement <3 x double> undef, double %B1, i32 0
77 ; CHECK: %X1.v.i1.22 = insertelement <3 x double> %X1.v.i1.11, double %B2, i32 1
88 ; CHECK: %X1.v.i1 = insertelement <3 x double> %X1.v.i1.22, double %B3, i32 2
22 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
33 target triple = "x86_64-apple-darwin10.0.0"
44
5 ; CHECK: @test1
5 ; CHECK-LABEL: @test1(
66 ; objectsize should fold to a constant, which causes the branch to fold to an
77 ; uncond branch. Next, we fold the control flow alltogether.
88 ; rdar://8785296
1515 br label %BB3
1616
1717 BB3:
18 ; CHECK: @test1
18 ; CHECK-LABEL: @test1(
1919 ; CHECK: %Ret = phi i32 [ 0, %BB1 ], [ 1, %BB2 ]
2020 %Ret = phi i32 [ %Val, %BB1 ], [ 1, %BB2 ]
2121 ret i32 %Ret
3030 bb:
3131 ret i1 %V
3232
33 ; CHECK: @test2
33 ; CHECK-LABEL: @test2(
3434 ; CHECK: ret i1 true
3535 }
3636
3737 define i1 @TNAN() {
38 ; CHECK: @TNAN
38 ; CHECK-LABEL: @TNAN(
3939 ; CHECK: ret i1 true
4040 %A = fcmp uno double 0x7FF8000000000000, 1.000000e+00
4141 %B = fcmp uno double 1.230000e+02, 1.000000e+00
4646 define i128 @vector_to_int_cast() {
4747 %A = bitcast <4 x i32> to i128
4848 ret i128 %A
49 ; CHECK: @vector_to_int_cast
49 ; CHECK-LABEL: @vector_to_int_cast(
5050 ; CHECK: ret i128 85070591750041656499021422275829170176
5151 }
5252
33 define <1 x i64> @test1() {
44 %A = bitcast i64 63 to <1 x i64>
55 ret <1 x i64> %A
6 ; CHECK: @test1
6 ; CHECK-LABEL: @test1(
77 ; CHECK: ret <1 x i64>
88 }
99
1010 declare double @exp2(double)
1111
1212 define double @T() {
13 ; CHECK: @T
13 ; CHECK-LABEL: @T(
1414 ; CHECK-NOT: call
1515 ; CHECK: ret
1616 %A = call double @cos(double 0.000000e+00)
2828 }
2929
3030 define i1 @test_sse_cvt() nounwind readnone {
31 ; CHECK: @test_sse_cvt
31 ; CHECK-LABEL: @test_sse_cvt(
3232 ; CHECK-NOT: call
3333 ; CHECK: ret i1 true
3434 entry:
6262
6363 define double @test_intrinsic_pow() nounwind uwtable ssp {
6464 entry:
65 ; CHECK: @test_intrinsic_pow
65 ; CHECK-LABEL: @test_intrinsic_pow(
6666 ; CHECK-NOT: call
6767 %0 = call double @llvm.pow.f64(double 1.500000e+00, double 3.000000e+00)
6868 ret double %0
7171
7272 ; Shouldn't fold because of -fno-builtin
7373 define double @sin_() nounwind uwtable ssp {
74 ; FNOBUILTIN: @sin_
74 ; FNOBUILTIN-LABEL: @sin_(
7575 ; FNOBUILTIN: %1 = call double @sin(double 3.000000e+00)
7676 %1 = call double @sin(double 3.000000e+00)
7777 ret double %1
7979
8080 ; Shouldn't fold because of -fno-builtin
8181 define double @sqrt_() nounwind uwtable ssp {
82 ; FNOBUILTIN: @sqrt_
82 ; FNOBUILTIN-LABEL: @sqrt_(
8383 ; FNOBUILTIN: %1 = call double @sqrt(double 3.000000e+00)
8484 %1 = call double @sqrt(double 3.000000e+00)
8585 ret double %1
8787
8888 ; Shouldn't fold because of -fno-builtin
8989 define float @sqrtf_() nounwind uwtable ssp {
90 ; FNOBUILTIN: @sqrtf_
90 ; FNOBUILTIN-LABEL: @sqrtf_(
9191 ; FNOBUILTIN: %1 = call float @sqrtf(float 3.000000e+00)
9292 %1 = call float @sqrtf(float 3.000000e+00)
9393 ret float %1
9696
9797 ; Shouldn't fold because of -fno-builtin
9898 define float @sinf_() nounwind uwtable ssp {
99 ; FNOBUILTIN: @sinf_
99 ; FNOBUILTIN-LABEL: @sinf_(
100100 ; FNOBUILTIN: %1 = call float @sinf(float 3.000000e+00)
101101 %1 = call float @sinf(float 3.000000e+00)
102102 ret float %1
105105
106106 ; Shouldn't fold because of -fno-builtin
107107 define double @tan_() nounwind uwtable ssp {
108 ; FNOBUILTIN: @tan_
108 ; FNOBUILTIN-LABEL: @tan_(
109109 ; FNOBUILTIN: %1 = call double @tan(double 3.000000e+00)
110110 %1 = call double @tan(double 3.000000e+00)
111111 ret double %1
113113
114114 ; Shouldn't fold because of -fno-builtin
115115 define double @tanh_() nounwind uwtable ssp {
116 ; FNOBUILTIN: @tanh_
116 ; FNOBUILTIN-LABEL: @tanh_(
117117 ; FNOBUILTIN: %1 = call double @tanh(double 3.000000e+00)
118118 %1 = call double @tanh(double 3.000000e+00)
119119 ret double %1
122122
123123 ; Shouldn't fold because of -fno-builtin
124124 define double @pow_() nounwind uwtable ssp {
125 ; FNOBUILTIN: @pow_
125 ; FNOBUILTIN-LABEL: @pow_(
126126 ; FNOBUILTIN: %1 = call double @pow(double 3.000000e+00, double 3.000000e+00)
127127 %1 = call double @pow(double 3.000000e+00, double 3.000000e+00)
128128 ret double %1
131131
132132 ; Shouldn't fold because of -fno-builtin
133133 define double @fmod_() nounwind uwtable ssp {
134 ; FNOBUILTIN: @fmod_
134 ; FNOBUILTIN-LABEL: @fmod_(
135135 ; FNOBUILTIN: %1 = call double @fmod(double 3.000000e+00, double 3.000000e+00)
136136 %1 = call double @fmod(double 3.000000e+00, double 3.000000e+00)
137137 ret double %1
140140
141141 ; Shouldn't fold because of -fno-builtin
142142 define double @atan2_() nounwind uwtable ssp {
143 ; FNOBUILTIN: @atan2_
143 ; FNOBUILTIN-LABEL: @atan2_(
144144 ; FNOBUILTIN: %1 = call double @atan2(double 3.000000e+00, double 3.000000e+00)
145145 %1 = call double @atan2(double 3.000000e+00, double 3.000000e+00)
146146 ret double %1
44 define i32 @test1() {
55 %A = extractvalue %struct { i32 2, [4 x i8] c"foo\00" }, 0
66 ret i32 %A
7 ; CHECK: @test1
7 ; CHECK-LABEL: @test1(
88 ; CHECK: ret i32 2
99 }
1010
1111 define i8 @test2() {
1212 %A = extractvalue %struct { i32 2, [4 x i8] c"foo\00" }, 1, 2
1313 ret i8 %A
14 ; CHECK: @test2
14 ; CHECK-LABEL: @test2(
1515 ; CHECK: ret i8 111
1616 }
1717
1818 define i32 @test3() {
1919 %A = extractvalue [3 x %struct] [ %struct { i32 0, [4 x i8] c"aaaa" }, %struct { i32 1, [4 x i8] c"bbbb" }, %struct { i32 2, [4 x i8] c"cccc" } ], 1, 0
2020 ret i32 %A
21 ; CHECK: @test3
21 ; CHECK-LABEL: @test3(
2222 ; CHECK: ret i32 1
2323 }
2424
44 define %struct @test1() {
55 %A = insertvalue %struct { i32 2, [4 x i8] c"foo\00" }, i32 1, 0
66 ret %struct %A
7 ; CHECK: @test1
7 ; CHECK-LABEL: @test1(
88 ; CHECK: ret %struct { i32 1, [4 x i8] c"foo\00" }
99 }
1010
1111 define %struct @test2() {
1212 %A = insertvalue %struct { i32 2, [4 x i8] c"foo\00" }, i8 1, 1, 2
1313 ret %struct %A
14 ; CHECK: @test2
14 ; CHECK-LABEL: @test2(
1515 ; CHECK: ret %struct { i32 2, [4 x i8] c"fo\01\00" }
1616 }
1717
1818 define [3 x %struct] @test3() {
1919 %A = insertvalue [3 x %struct] [ %struct { i32 0, [4 x i8] c"aaaa" }, %struct { i32 1, [4 x i8] c"bbbb" }, %struct { i32 2, [4 x i8] c"cccc" } ], i32 -1, 1, 0
2020 ret [3 x %struct] %A
21 ; CHECK: @test3
21 ; CHECK-LABEL: @test3(
2222 ; CHECK:ret [3 x %struct] [%struct { i32 0, [4 x i8] c"aaaa" }, %struct { i32 -1, [4 x i8] c"bbbb" }, %struct { i32 2, [4 x i8] c"cccc" }]
2323 }
2424
1212 ret i32 %r
1313
1414 ; 0xDEADBEEF
15 ; LE: @test1
15 ; LE-LABEL: @test1(
1616 ; LE: ret i32 -559038737
1717
1818 ; 0xDEADBEEF
19 ; BE: @test1
19 ; BE-LABEL: @test1(
2020 ; BE: ret i32 -559038737
2121 }
2222
2727 ret i16 %r
2828
2929 ; 0xBEEF
30 ; LE: @test2
30 ; LE-LABEL: @test2(
3131 ; LE: ret i16 -16657
3232
3333 ; 0xDEAD
34 ; BE: @test2
34 ; BE-LABEL: @test2(
3535 ; BE: ret i16 -8531
3636 }
3737
4141 ret i16 %r
4242
4343 ; 0xDEAD
44 ; LE: @test3
44 ; LE-LABEL: @test3(
4545 ; LE: ret i16 -8531
4646
4747 ; 0xBEEF
48 ; BE: @test3
48 ; BE-LABEL: @test3(
4949 ; BE: ret i16 -16657
5050 }
5151
5555 ret i16 %r
5656
5757 ; 0x00BA
58 ; LE: @test4
58 ; LE-LABEL: @test4(
5959 ; LE: ret i16 186
6060
6161 ; 0xBA00
62 ; BE: @test4
62 ; BE-LABEL: @test4(
6363 ; BE: ret i16 -17920
6464 }
6565
6969 ret i64 %r
7070
7171 ; 0x3FF_0000000000000
72 ; LE: @test6
72 ; LE-LABEL: @test6(
7373 ; LE: ret i64 4607182418800017408
7474
7575 ; 0x3FF_0000000000000
76 ; BE: @test6
76 ; BE-LABEL: @test6(
7777 ; BE: ret i64 4607182418800017408
7878 }
7979
8383 ret i16 %r
8484
8585 ; 0x0000
86 ; LE: @test7
86 ; LE-LABEL: @test7(
8787 ; LE: ret i16 0
8888
8989 ; 0x3FF0
90 ; BE: @test7
90 ; BE-LABEL: @test7(
9191 ; BE: ret i16 16368
9292 }
9393
9696 %r = load double* bitcast({{i32,i8},i32}* @g1 to double*)
9797 ret double %r
9898
99 ; LE: @test8
99 ; LE-LABEL: @test8(
100100 ; LE: ret double 0xBADEADBEEF
101101
102 ; BE: @test8
102 ; BE-LABEL: @test8(
103103 ; BE: ret double 0xDEADBEEFBA000000
104104 }
105105
110110 ret i128 %r
111111
112112 ; 0x00000000_06B1BFF8_00000000_0000007B
113 ; LE: @test9
113 ; LE-LABEL: @test9(
114114 ; LE: ret i128 2071796475790618158476296315
115115
116116 ; 0x00000000_0000007B_00000000_06B1BFF8
117 ; BE: @test9
117 ; BE-LABEL: @test9(
118118 ; BE: ret i128 2268949521066387161080
119119 }
120120
123123 %r = load <2 x i64>* bitcast({i64, i64}* @g3 to <2 x i64>*)
124124 ret <2 x i64> %r
125125
126 ; LE: @test10
126 ; LE-LABEL: @test10(
127127 ; LE: ret <2 x i64>
128128
129 ; BE: @test10
129 ; BE-LABEL: @test10(
130130 ; BE: ret <2 x i64>
131131 }
132132
141141 ret i16 %a
142142
143143 ; 0x08A1
144 ; LE: @test11
144 ; LE-LABEL: @test11(
145145 ; LE: ret i16 2209
146146
147147 ; 0xA108
148 ; BE: @test11
148 ; BE-LABEL: @test11(
149149 ; BE: ret i16 -24312
150150 }
151151
158158 ret i16 %a
159159
160160 ; 0x0062
161 ; LE: @test12
161 ; LE-LABEL: @test12(
162162 ; LE: ret i16 98
163163
164164 ; 0x6200
165 ; BE: @test12
165 ; BE-LABEL: @test12(
166166 ; BE: ret i16 25088
167167 }
168168
173173 %A = load i1* bitcast (i8* @g5 to i1*)
174174 ret i1 %A
175175
176 ; LE: @test13
176 ; LE-LABEL: @test13(
177177 ; LE: ret i1 false
178178
179 ; BE: @test13
179 ; BE-LABEL: @test13(
180180 ; BE: ret i1 false
181181 }
182182
186186 %tmp = load i64* bitcast ([2 x i8*]* @g6 to i64*)
187187 ret i64 %tmp
188188
189 ; LE: @test14
189 ; LE-LABEL: @test14(
190190 ; LE: ret i64 1
191191
192 ; BE: @test14
192 ; BE-LABEL: @test14(
193193 ; BE: ret i64 1
194194 }
195195
198198 %tmp = load i64* bitcast (i8** getelementptr inbounds ([2 x i8*]* @g6, i32 0, i64 1) to i64*)
199199 ret i64 %tmp
200200
201 ; LE: @test15
201 ; LE-LABEL: @test15(
202202 ; LE: ret i64 2
203203
204 ; BE: @test15
204 ; BE-LABEL: @test15(
205205 ; BE: ret i64 2
206206 }
1717 %t = call {i8, i1} @llvm.uadd.with.overflow.i8(i8 42, i8 100)
1818 ret {i8, i1} %t
1919
20 ; CHECK: @uadd_1
20 ; CHECK-LABEL: @uadd_1(
2121 ; CHECK: ret { i8, i1 } { i8 -114, i1 false }
2222 }
2323
2626 %t = call {i8, i1} @llvm.uadd.with.overflow.i8(i8 142, i8 120)
2727 ret {i8, i1} %t
2828
29 ; CHECK: @uadd_2
29 ; CHECK-LABEL: @uadd_2(
3030 ; CHECK: ret { i8, i1 } { i8 6, i1 true }
3131 }
3232
3939 %t = call {i8, i1} @llvm.usub.with.overflow.i8(i8 4, i8 2)
4040 ret {i8, i1} %t
4141
42 ; CHECK: @usub_1
42 ; CHECK-LABEL: @usub_1(
4343 ; CHECK: ret { i8, i1 } { i8 2, i1 false }
4444 }
4545
4848 %t = call {i8, i1} @llvm.usub.with.overflow.i8(i8 4, i8 6)
4949 ret {i8, i1} %t
5050
51 ; CHECK: @usub_2
51 ; CHECK-LABEL: @usub_2(
5252 ; CHECK: ret { i8, i1 } { i8 -2, i1 true }
5353 }
5454
6161 %t = call {i8, i1} @llvm.umul.with.overflow.i8(i8 100, i8 3)
6262 ret {i8, i1} %t
6363
64 ; CHECK: @umul_1
64 ; CHECK-LABEL: @umul_1(
6565 ; CHECK: ret { i8, i1 } { i8 44, i1 true }
6666 }
6767
7070 %t = call {i8, i1} @llvm.umul.with.overflow.i8(i8 100, i8 2)
7171 ret {i8, i1} %t
7272
73 ; CHECK: @umul_2
73 ; CHECK-LABEL: @umul_2(
7474 ; CHECK: ret { i8, i1 } { i8 -56, i1 false }
7575 }
7676
8383 %t = call {i8, i1} @llvm.sadd.with.overflow.i8(i8 42, i8 2)
8484 ret {i8, i1} %t
8585
86 ; CHECK: @sadd_1
86 ; CHECK-LABEL: @sadd_1(
8787 ; CHECK: ret { i8, i1 } { i8 44, i1 false }
8888 }
8989
9292 %t = call {i8, i1} @llvm.sadd.with.overflow.i8(i8 120, i8 10)
9393 ret {i8, i1} %t
9494
95 ; CHECK: @sadd_2
95 ; CHECK-LABEL: @sadd_2(
9696 ; CHECK: ret { i8, i1 } { i8 -126, i1 true }
9797 }
9898
101101 %t = call {i8, i1} @llvm.sadd.with.overflow.i8(i8 -120, i8 10)
102102 ret {i8, i1} %t
103103
104 ; CHECK: @sadd_3
104 ; CHECK-LABEL: @sadd_3(
105105 ; CHECK: ret { i8, i1 } { i8 -110, i1 false }
106106 }
107107
110110 %t = call {i8, i1} @llvm.sadd.with.overflow.i8(i8 -120, i8 -10)
111111 ret {i8, i1} %t
112112
113 ; CHECK: @sadd_4
113 ; CHECK-LABEL: @sadd_4(
114114 ; CHECK: ret { i8, i1 } { i8 126, i1 true }
115115 }
116116
119119 %t = call {i8, i1} @llvm.sadd.with.overflow.i8(i8 2, i8 -10)
120120 ret {i8, i1} %t
121121
122 ; CHECK: @sadd_5
122 ; CHECK-LABEL: @sadd_5(
123123 ; CHECK: ret { i8, i1 } { i8 -8, i1 false }
124124 }
125125
133133 %t = call {i8, i1} @llvm.ssub.with.overflow.i8(i8 4, i8 2)
134134 ret {i8, i1} %t
135135
136 ; CHECK: @ssub_1
136 ; CHECK-LABEL: @ssub_1(
137137 ; CHECK: ret { i8, i1 } { i8 2, i1 false }
138138 }
139139
142142 %t = call {i8, i1} @llvm.ssub.with.overflow.i8(i8 4, i8 6)
143143 ret {i8, i1} %t
144144
145 ; CHECK: @ssub_2
145 ; CHECK-LABEL: @ssub_2(
146146 ; CHECK: ret { i8, i1 } { i8 -2, i1 false }
147147 }
148148
151151 %t = call {i8, i1} @llvm.ssub.with.overflow.i8(i8 -10, i8 120)
152152 ret {i8, i1} %t
153153
154 ; CHECK: @ssub_3
154 ; CHECK-LABEL: @ssub_3(
155155 ; CHECK: ret { i8, i1 } { i8 126, i1 true }
156156 }
157157
160160 %t = call {i8, i1} @llvm.ssub.with.overflow.i8(i8 -10, i8 10)
161161 ret {i8, i1} %t
162162
163 ; CHECK: @ssub_3b
163 ; CHECK-LABEL: @ssub_3b(
164164 ; CHECK: ret { i8, i1 } { i8 -20, i1 false }
165165 }
166166
169169 %t = call {i8, i1} @llvm.ssub.with.overflow.i8(i8 120, i8 -10)
170170 ret {i8, i1} %t
171171
172 ; CHECK: @ssub_4
172 ; CHECK-LABEL: @ssub_4(
173173 ; CHECK: ret { i8, i1 } { i8 -126, i1 true }
174174 }
175175
178178 %t = call {i8, i1} @llvm.ssub.with.overflow.i8(i8 20, i8 -10)
179179 ret {i8, i1} %t
180180
181 ; CHECK: @ssub_4b
181 ; CHECK-LABEL: @ssub_4b(
182182 ; CHECK: ret { i8, i1 } { i8 30, i1 false }
183183 }
184184
187187 %t = call {i8, i1} @llvm.ssub.with.overflow.i8(i8 -20, i8 -10)
188188 ret {i8, i1} %t
189189
190 ; CHECK: @ssub_5
190 ; CHECK-LABEL: @ssub_5(
191191 ; CHECK: ret { i8, i1 } { i8 -10, i1 false }
192192 }
193193
201201 %t = call {i8, i1} @llvm.smul.with.overflow.i8(i8 -20, i8 -10)
202202 ret {i8, i1} %t
203203
204 ; CHECK: @smul_1
204 ; CHECK-LABEL: @smul_1(
205205 ; CHECK: ret { i8, i1 } { i8 -56, i1 true }
206206 }
0 ; RUN: opt -S < %s -correlated-propagation | FileCheck %s
11
2 ; CHECK: @test
2 ; CHECK-LABEL: @test(
33 define i16 @test(i32 %a, i1 %b) {
44 entry:
55 %c = icmp eq i32 %a, 0
0 ; RUN: opt < %s -correlated-propagation -S | FileCheck %s
11 ; PR2581
22
3 ; CHECK: @test1
3 ; CHECK-LABEL: @test1(
44 define i32 @test1(i1 %C) nounwind {
55 br i1 %C, label %exit, label %body
66
1717
1818 ; PR4420
1919 declare i1 @ext()
20 ; CHECK: @test2
20 ; CHECK-LABEL: @test2(
2121 define i1 @test2() {
2222 entry:
2323 %cond = tail call i1 @ext() ; [#uses=2]
4141
4242 ; PR4855
4343 @gv = internal constant i8 7
44 ; CHECK: @test3
44 ; CHECK-LABEL: @test3(
4545 define i8 @test3(i8* %a) nounwind {
4646 entry:
4747 %cond = icmp eq i8* %a, @gv
5757 }
5858
5959 ; PR1757
60 ; CHECK: @test4
60 ; CHECK-LABEL: @test4(
6161 define i32 @test4(i32) {
6262 EntryBlock:
6363 ; CHECK: icmp sgt i32 %0, 2
8282
8383 declare i32* @f(i32*)
8484 define void @test5(i32* %x, i32* %y) {
85 ; CHECK: @test5
85 ; CHECK-LABEL: @test5(
8686 entry:
8787 %pre = icmp eq i32* %x, null
8888 br i1 %pre, label %return, label %loop
101101 }
102102
103103 define i32 @switch1(i32 %s) {
104 ; CHECK: @switch1
104 ; CHECK-LABEL: @switch1(
105105 entry:
106106 %cmp = icmp slt i32 %s, 0
107107 br i1 %cmp, label %negative, label %out
133133 }
134134
135135 define i32 @switch2(i32 %s) {
136 ; CHECK: @switch2
136 ; CHECK-LABEL: @switch2(
137137 entry:
138138 %cmp = icmp sgt i32 %s, 0
139139 br i1 %cmp, label %positive, label %out
156156 }
157157
158158 define i32 @switch3(i32 %s) {
159 ; CHECK: @switch3
159 ; CHECK-LABEL: @switch3(
160160 entry:
161161 %cmp = icmp sgt i32 %s, 0
162162 br i1 %cmp, label %positive, label %out
179179 }
180180
181181 define void @switch4(i32 %s) {
182 ; CHECK: @switch4
182 ; CHECK-LABEL: @switch4(
183183 entry:
184184 %cmp = icmp eq i32 %s, 0
185185 br i1 %cmp, label %zero, label %out
1616 end:
1717 ret i32 2
1818
19 ; CHECK: @test1
19 ; CHECK-LABEL: @test1(
2020 ; CHECK: then:
2121 ; CHECK-NEXT: br i1 false, label %end, label %else
2222 }
3636 end:
3737 ret i32 2
3838
39 ; CHECK: @test2
39 ; CHECK-LABEL: @test2(
4040 ; CHECK: then:
4141 ; CHECK-NEXT: br i1 false, label %end, label %else
4242 }
4343
44 ; CHECK: @test3
44 ; CHECK-LABEL: @test3(
4545 define i32 @test3(i32 %c) nounwind {
4646 %cmp = icmp slt i32 %c, 2
4747 br i1 %cmp, label %if.then, label %if.end
7070 ret i32 4
7171 }
7272
73 ; CHECK: @test4
73 ; CHECK-LABEL: @test4(
7474 define i32 @test4(i32 %c) nounwind {
7575 switch i32 %c, label %sw.default [
7676 i32 1, label %sw.bb
9898 ret i32 %retval.0
9999 }
100100
101 ; CHECK: @test5
101 ; CHECK-LABEL: @test5(
102102 define i1 @test5(i32 %c) nounwind {
103103 %cmp = icmp slt i32 %c, 5
104104 br i1 %cmp, label %if.then, label %if.end
120120 ret i1 %cmp2
121121 }
122122
123 ; CHECK: @test6
123 ; CHECK-LABEL: @test6(
124124 define i1 @test6(i32 %c) nounwind {
125125 %cmp = icmp ule i32 %c, 7
126126 br i1 %cmp, label %if.then, label %if.end
142142 ret i1 %cmp2
143143 }
144144
145 ; CHECK: @test7
145 ; CHECK-LABEL: @test7(
146146 define i1 @test7(i32 %c) nounwind {
147147 entry:
148148 switch i32 %c, label %sw.default [
66 define void @foo() {
77 call void @test(i32 0)
88 ret void
9 ; CHECK: @foo
9 ; CHECK-LABEL: @foo(
1010 ; CHECK: i32 undef
1111 }
1212
44
55 %"class.std::auto_ptr" = type { i32* }
66
7 ; CHECK: @_Z3foov
7 ; CHECK-LABEL: @_Z3foov(
88 define void @_Z3foov(%"class.std::auto_ptr"* noalias nocapture sret %agg.result) uwtable ssp {
99 _ZNSt8auto_ptrIiED1Ev.exit:
1010 %temp.lvalue = alloca %"class.std::auto_ptr", align 8
77 @glob2 = global %struct.vec2plusi zeroinitializer, align 16
88
99 define void @write24to28(i32* nocapture %p) nounwind uwtable ssp {
10 ; CHECK: @write24to28
10 ; CHECK-LABEL: @write24to28(
1111 entry:
1212 %arrayidx0 = getelementptr inbounds i32* %p, i64 1
1313 %p3 = bitcast i32* %arrayidx0 to i8*
1919 }
2020
2121 define void @write28to32(i32* nocapture %p) nounwind uwtable ssp {
22 ; CHECK: @write28to32
22 ; CHECK-LABEL: @write28to32(
2323 entry:
2424 %p3 = bitcast i32* %p to i8*
2525 ; CHECK: call void @llvm.memset.p0i8.i64(i8* %p3, i8 0, i64 28, i32 4, i1 false)
3030 }
3131
3232 define void @dontwrite28to32memset(i32* nocapture %p) nounwind uwtable ssp {
33 ; CHECK: @dontwrite28to32memset
33 ; CHECK-LABEL: @dontwrite28to32memset(
3434 entry:
3535 %p3 = bitcast i32* %p to i8*
3636 ; CHECK: call void @llvm.memset.p0i8.i64(i8* %p3, i8 0, i64 32, i32 16, i1 false)
4141 }
4242
4343 define void @write32to36(%struct.vec2plusi* nocapture %p) nounwind uwtable ssp {
44 ; CHECK: @write32to36
44 ; CHECK-LABEL: @write32to36(
4545 entry:
4646 %0 = bitcast %struct.vec2plusi* %p to i8*
4747 ; CHECK: tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %0, i8* bitcast (%struct.vec2plusi* @glob2 to i8*), i64 32, i32 16, i1 false)
5252 }
5353
5454 define void @write16to32(%struct.vec2* nocapture %p) nounwind uwtable ssp {
55 ; CHECK: @write16to32
55 ; CHECK-LABEL: @write16to32(
5656 entry:
5757 %0 = bitcast %struct.vec2* %p to i8*
5858 ; CHECK: tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %0, i8* bitcast (%struct.vec2* @glob1 to i8*), i64 16, i32 16, i1 false)
6363 }
6464
6565 define void @dontwrite28to32memcpy(%struct.vec2* nocapture %p) nounwind uwtable ssp {
66 ; CHECK: @dontwrite28to32memcpy
66 ; CHECK-LABEL: @dontwrite28to32memcpy(
6767 entry:
6868 %0 = bitcast %struct.vec2* %p to i8*
6969 ; CHECK: tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %0, i8* bitcast (%struct.vec2* @glob1 to i8*), i64 32, i32 16, i1 false)
7979 %struct.trapframe = type { i64, i64, i64 }
8080
8181 ; bugzilla 11455 - make sure negative GEP's don't break this optimisation
82 ; CHECK: @cpu_lwp_fork
82 ; CHECK-LABEL: @cpu_lwp_fork(
8383 define void @cpu_lwp_fork(%struct.trapframe* %md_regs, i64 %pcb_rsp0) nounwind uwtable noinline ssp {
8484 entry:
8585 %0 = inttoptr i64 %pcb_rsp0 to %struct.trapframe*
77 store i8 0, i8* %V2
88 store i32 1234567, i32* %V
99 ret void
10 ; CHECK: @test1
10 ; CHECK-LABEL: @test1(
1111 ; CHECK-NEXT: store i32 1234567
1212 }
1313
1414 ; Note that we could do better by merging the two stores into one.
1515 define void @test2(i32* %P) {
16 ; CHECK: @test2
16 ; CHECK-LABEL: @test2(
1717 store i32 0, i32* %P
1818 ; CHECK: store i32
1919 %Q = bitcast i32* %P to i16*
2424
2525
2626 define i32 @test3(double %__x) {
27 ; CHECK: @test3
27 ; CHECK-LABEL: @test3(
2828 ; CHECK: store double
2929 %__u = alloca { [3 x i32] }
3030 %tmp.1 = bitcast { [3 x i32] }* %__u to double*
3838
3939 ; PR6043
4040 define void @test4(i8* %P) {
41 ; CHECK: @test4
41 ; CHECK-LABEL: @test4(
4242 ; CHECK-NEXT: bitcast
4343 ; CHECK-NEXT: store double
4444
6363
6464 call void @test5a(i32* %A)
6565 ret void
66 ; CHECK: @test5(
66 ; CHECK-LABEL: @test5(
6767 ; CHECK-NEXT: alloca
6868 ; CHECK-NEXT: store i32 20
6969 ; CHECK-NEXT: call void @test5a
44 declare void @free(i8* nocapture)
55 declare noalias i8* @malloc(i64)
66
7 ; CHECK: @test
7 ; CHECK-LABEL: @test(
88 ; CHECK-NEXT: bitcast
99 ; CHECK-NEXT: @free
1010 ; CHECK-NEXT: ret void
1616 ret void
1717 }
1818
19 ; CHECK: @test2
19 ; CHECK-LABEL: @test2(
2020 ; CHECK-NEXT: bitcast
2121 ; CHECK-NEXT: @free
2222 ; CHECK-NEXT: ret void
2828 ret void
2929 }
3030
31 ; CHECK: @test3
31 ; CHECK-LABEL: @test3(
3232 ; CHECK-NOT: store
3333 ; CHECK: ret void
3434 define void @test3() {
4141 }
4242
4343 ; PR11240
44 ; CHECK: @test4
44 ; CHECK-LABEL: @test4(
4545 ; CHECK-NOT: store
4646 ; CHECK: ret void
4747 define void @test4(i1 %x) nounwind {
5858 ret void
5959 }
6060
61 ; CHECK: @test5
61 ; CHECK-LABEL: @test5(
6262 define void @test5() {
6363 br label %bb
6464
11
22 declare i8* @strcpy(i8* %dest, i8* %src) nounwind
33 define void @test1(i8* %src) {
4 ; CHECK: @test1
4 ; CHECK-LABEL: @test1(
55 %B = alloca [16 x i8]
66 %dest = getelementptr inbounds [16 x i8]* %B, i64 0, i64 0
77 ; CHECK-NOT: @strcpy
1212
1313 declare i8* @strncpy(i8* %dest, i8* %src, i32 %n) nounwind
1414 define void @test2(i8* %src) {
15 ; CHECK: @test2
15 ; CHECK-LABEL: @test2(
1616 %B = alloca [16 x i8]
1717 %dest = getelementptr inbounds [16 x i8]* %B, i64 0, i64 0
1818 ; CHECK-NOT: @strncpy
2323
2424 declare i8* @strcat(i8* %dest, i8* %src) nounwind
2525 define void @test3(i8* %src) {
26 ; CHECK: @test3
26 ; CHECK-LABEL: @test3(
2727 %B = alloca [16 x i8]
2828 %dest = getelementptr inbounds [16 x i8]* %B, i64 0, i64 0
2929 ; CHECK-NOT: @strcat
3434
3535 declare i8* @strncat(i8* %dest, i8* %src, i32 %n) nounwind
3636 define void @test4(i8* %src) {
37 ; CHECK: @test4
37 ; CHECK-LABEL: @test4(
3838 %B = alloca [16 x i8]
3939 %dest = getelementptr inbounds [16 x i8]* %B, i64 0, i64 0
4040 ; CHECK-NOT: @strncat
4444 }
4545
4646 define void @test5(i8* nocapture %src) {
47 ; CHECK: @test5
47 ; CHECK-LABEL: @test5(
4848 %dest = alloca [100 x i8], align 16
4949 %arraydecay = getelementptr inbounds [100 x i8]* %dest, i64 0, i64 0
5050 %call = call i8* @strcpy(i8* %arraydecay, i8* %src)
5656
5757 declare void @user(i8* %p)
5858 define void @test6(i8* %src) {
59 ; CHECK: @test6
59 ; CHECK-LABEL: @test6(
6060 %B = alloca [16 x i8]
6161 %dest = getelementptr inbounds [16 x i8]* %B, i64 0, i64 0
6262 ; CHECK: @strcpy
66 declare void @llvm.memset.p0i8.i8(i8* nocapture, i8, i8, i32, i1) nounwind
77
88 define void @test1() {
9 ; CHECK: @test1
9 ; CHECK-LABEL: @test1(
1010 %A = alloca i8
1111
1212 store i8 0, i8* %A ;; Written to by memset
44 declare void @llvm.memset.p0i8.i8(i8* nocapture, i8, i8, i32, i1) nounwind
55
66 define void @test1() {
7 ; CHECK: @test1
7 ; CHECK-LABEL: @test1(
88 %A = alloca i8
99 %B = alloca i8
1010
1818 }
1919
2020 define void @test2() {
21 ; CHECK: @test2
21 ; CHECK-LABEL: @test2(
2222 %A = alloca i8
2323 %B = alloca i8
2424
3232 }
3333
3434 define void @test3() {
35 ; CHECK: @test3
35 ; CHECK-LABEL: @test3(
3636 %A = alloca i8
3737 %B = alloca i8
3838
99 store i32 %DEAD, i32* %P
1010 store i32 0, i32* %P
1111 ret void
12 ; CHECK: @test1
12 ; CHECK-LABEL: @test1(
1313 ; CHECK-NEXT: store i32 0, i32* %P
1414 ; CHECK-NEXT: ret void
1515 }
2020 store i32 20, i32* %q, align 4
2121 store i32 30, i32* %p, align 4
2222 ret void
23 ; CHECK: @test2
23 ; CHECK-LABEL: @test2(
2424 ; CHECK-NEXT: store i32 20
2525 }
2626
2929 @g = global i32 1
3030
3131 define i32 @test3(i32* %g_addr) nounwind {
32 ; CHECK: @test3
32 ; CHECK-LABEL: @test3(
3333 ; CHECK: load i32* %g_addr
3434 %g_value = load i32* %g_addr, align 4
3535 store i32 -1, i32* @g, align 4
4343 %a = load i32* %Q
4444 store volatile i32 %a, i32* %Q
4545 ret void
46 ; CHECK: @test4
46 ; CHECK-LABEL: @test4(
4747 ; CHECK-NEXT: load i32
4848 ; CHECK-NEXT: store volatile
4949 ; CHECK-NEXT: ret void
5353 %a = load volatile i32* %Q
5454 store i32 %a, i32* %Q
5555 ret void
56 ; CHECK: @test5
56 ; CHECK-LABEL: @test5(
5757 ; CHECK-NEXT: load volatile
5858 ; CHECK-NEXT: ret void
5959 }
6565 call void @llvm.memset.p0i8.i64(i8* %q, i8 42, i64 900, i32 1, i1 false)
6666 store i32 30, i32* %p, align 4
6767 ret void
68 ; CHECK: @test6
68 ; CHECK-LABEL: @test6(
6969 ; CHECK-NEXT: call void @llvm.memset
7070 }
7171
7676 call void @llvm.memcpy.p0i8.p0i8.i64(i8* %q, i8* %r, i64 900, i32 1, i1 false)
7777 store i32 30, i32* %p, align 4
7878 ret void
79 ; CHECK: @test7
79 ; CHECK-LABEL: @test7(
8080 ; CHECK-NEXT: call void @llvm.memcpy
8181 }
8282
8989 %X = load i32* %V
9090 ret i32 %X
9191
92 ; CHECK: @test8
92 ; CHECK-LABEL: @test8(
9393 ; CHECK: store i32 1234567
9494 }
9595
100100 %tmp2 = getelementptr %struct.x* %a, i32 0, i32 0
101101 store i32 1, i32* %tmp2, align 4
102102 ret void
103 ; CHECK: @test9
103 ; CHECK-LABEL: @test9(
104104 ; CHECK-NEXT: ret void
105105 }
106106
110110 store i8* %X, i8** %X_addr
111111 %tmp.0 = va_arg i8** %X_addr, double
112112 ret double %tmp.0
113 ; CHECK: @test10
113 ; CHECK-LABEL: @test10(
114114 ; CHECK: store
115115 }
116116
118118 ; DSE should delete the dead trampoline.
119119 declare void @test11f()
120120 define void @test11() {
121 ; CHECK: @test11
121 ; CHECK-LABEL: @test11(
122122 %storage = alloca [10 x i8], align 16 ; <[10 x i8]*> [#uses=1]
123123 ; CHECK-NOT: alloca
124124 %cast = getelementptr [10 x i8]* %storage, i32 0, i32 0 ; [#uses=1]
139139 store i32 %tmp5, i32* %tmp4, align 4
140140 store i32 %tmp17, i32* %tmp7, align 4
141141 ret void
142 ; CHECK: @test12
142 ; CHECK-LABEL: @test12(
143143 ; CHECK-NOT: tmp5
144144 ; CHECK: ret void
145145 }
172172 store i32 %DEAD, i32* %P
173173 ret void
174174
175 ; CHECK: @test14
175 ; CHECK-LABEL: @test14(
176176 ; CHECK-NEXT: ret void
177177 }
178178
184184 tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %P, i8* %Q, i64 12, i32 1, i1 false)
185185 tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %P, i8* %Q, i64 12, i32 1, i1 false)
186186 ret void
187 ; CHECK: @test15
187 ; CHECK-LABEL: @test15(
188188 ; CHECK-NEXT: call void @llvm.memcpy
189189 ; CHECK-NEXT: ret
190190 }
194194 tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %P, i8* %Q, i64 8, i32 1, i1 false)
195195 tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %P, i8* %Q, i64 12, i32 1, i1 false)
196196 ret void
197 ; CHECK: @test16
197 ; CHECK-LABEL: @test16(
198198 ; CHECK-NEXT: call void @llvm.memcpy
199199 ; CHECK-NEXT: ret
200200 }
204204 tail call void @llvm.memset.p0i8.i64(i8* %P, i8 42, i64 8, i32 1, i1 false)
205205 tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %P, i8* %Q, i64 12, i32 1, i1 false)
206206 ret void
207 ; CHECK: @test17
207 ; CHECK-LABEL: @test17(
208208 ; CHECK-NEXT: call void @llvm.memcpy
209209 ; CHECK-NEXT: ret
210210 }
214214 tail call void @llvm.memset.p0i8.i64(i8* %P, i8 42, i64 8, i32 1, i1 true)
215215 tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %P, i8* %Q, i64 12, i32 1, i1 false)
216216 ret void
217 ; CHECK: @test17v
217 ; CHECK-LABEL: @test17v(
218218 ; CHECK-NEXT: call void @llvm.memset
219219 ; CHECK-NEXT: call void @llvm.memcpy
220220 ; CHECK-NEXT: ret
228228 tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %P, i8* %Q, i64 12, i32 1, i1 false)
229229 tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %P, i8* %R, i64 12, i32 1, i1 false)
230230 ret void
231 ; CHECK: @test18
231 ; CHECK-LABEL: @test18(
232232 ; CHECK-NEXT: call void @llvm.memcpy
233233 ; CHECK-NEXT: call void @llvm.memcpy
234234 ; CHECK-NEXT: ret
245245 call void @test19f({i32}* byval align 4 %arg5)
246246 ret void
247247
248 ; CHECK: @test19(
248 ; CHECK-LABEL: @test19(
249249 ; CHECK: store i32 912
250250 ; CHECK: call void @test19f
251251 }
255255 store i8 0, i8* %m
256256 ret void
257257 }
258 ; CHECK: @test20
259 ; CHECK-NEXT: ret void
260
261 ; CHECK: @test21
258 ; CHECK-LABEL: @test20(
259 ; CHECK-NEXT: ret void
260
261 ; CHECK-LABEL: @test21(
262262 define void @test21() {
263263 %m = call i8* @calloc(i32 9, i32 7)
264264 store i8 0, i8* %m
266266 ret void
267267 }
268268
269 ; CHECK: @test22(
269 ; CHECK-LABEL: @test22(
270270 define void @test22(i1 %i, i32 %k, i32 %m) nounwind {
271271 %k.addr = alloca i32
272272 %m.addr = alloca i32
277277 }
278278
279279 ; PR13547
280 ; CHECK: @test23
280 ; CHECK-LABEL: @test23(
281281 ; CHECK: store i8 97
282282 ; CHECK: store i8 0
283283 declare noalias i8* @strdup(i8* nocapture) nounwind
292292 }
293293
294294 ; Make sure same sized store to later element is deleted
295 ; CHECK: @test24
295 ; CHECK-LABEL: @test24(
296296 ; CHECK-NOT: store i32 0
297297 ; CHECK-NOT: store i32 0
298298 ; CHECK: store i32 %b
311311 }
312312
313313 ; Check another case like PR13547 where strdup is not like malloc.
314 ; CHECK: @test25
314 ; CHECK-LABEL: @test25(
315315 ; CHECK: load i8
316316 ; CHECK: store i8 0
317317 ; CHECK: store i8 %tmp
0 ; RUN: opt < %s -S -early-cse | FileCheck %s
11
22
3 ; CHECK: @test1
3 ; CHECK-LABEL: @test1(
44 define void @test1(i8 %V, i32 *%P) {
55 %A = bitcast i64 42 to double ;; dead
66 %B = add i32 4, 19 ;; constant folds
3232
3333
3434 ;; Simple load value numbering.
35 ; CHECK: @test2
35 ; CHECK-LABEL: @test2(
3636 define i32 @test2(i32 *%P) {
3737 %V1 = load i32* %P
3838 %V2 = load i32* %P
4242 }
4343
4444 ;; Cross block load value numbering.
45 ; CHECK: @test3
45 ; CHECK-LABEL: @test3(
4646 define i32 @test3(i32 *%P, i1 %Cond) {
4747 %V1 = load i32* %P
4848 br i1 %Cond, label %T, label %F
5858 }
5959
6060 ;; Cross block load value numbering stops when stores happen.
61 ; CHECK: @test4
61 ; CHECK-LABEL: @test4(
6262 define i32 @test4(i32 *%P, i1 %Cond) {
6363 %V1 = load i32* %P
6464 br i1 %Cond, label %T, label %F
7878 declare i32 @func(i32 *%P) readonly
7979
8080 ;; Simple call CSE'ing.
81 ; CHECK: @test5
81 ; CHECK-LABEL: @test5(
8282 define i32 @test5(i32 *%P) {
8383 %V1 = call i32 @func(i32* %P)
8484 %V2 = call i32 @func(i32* %P)
8888 }
8989
9090 ;; Trivial Store->load forwarding
91 ; CHECK: @test6
91 ; CHECK-LABEL: @test6(
9292 define i32 @test6(i32 *%P) {
9393 store i32 42, i32* %P
9494 %V1 = load i32* %P
9797 }
9898
9999 ;; Trivial dead store elimination.
100 ; CHECK: @test7
100 ; CHECK-LABEL: @test7(
101101 define void @test7(i32 *%P) {
102102 store i32 42, i32* %P
103103 store i32 45, i32* %P
107107 }
108108
109109 ;; Readnone functions aren't invalidated by stores.
110 ; CHECK: @test8
110 ; CHECK-LABEL: @test8(
111111 define i32 @test8(i32 *%P) {
112112 %V1 = call i32 @func(i32* %P) readnone
113113 store i32 4, i32* %P
0 ; RUN: opt < %s -S -early-cse | FileCheck %s
11
2 ; CHECK: @test1
2 ; CHECK-LABEL: @test1(
33 define void @test1(float %A, float %B, float* %PA, float* %PB) {
44 ; CHECK-NEXT: fadd
55 ; CHECK-NEXT: store
1212 ret void
1313 }
1414
15 ; CHECK: @test2
15 ; CHECK-LABEL: @test2(
1616 define void @test2(float %A, float %B, i1* %PA, i1* %PB) {
1717 ; CHECK-NEXT: fcmp
1818 ; CHECK-NEXT: store
2525 ret void
2626 }
2727
28 ; CHECK: @test3
28 ; CHECK-LABEL: @test3(
2929 define void @test3(float %A, float %B, i1* %PA, i1* %PB) {
3030 ; CHECK-NEXT: fcmp
3131 ; CHECK-NEXT: store
3838 ret void
3939 }
4040
41 ; CHECK: @test4
41 ; CHECK-LABEL: @test4(
4242 define void @test4(i32 %A, i32 %B, i1* %PA, i1* %PB) {
4343 ; CHECK-NEXT: icmp
4444 ; CHECK-NEXT: store
5151 ret void
5252 }
5353
54 ; CHECK: @test5
54 ; CHECK-LABEL: @test5(
5555 define void @test5(i32 %A, i32 %B, i1* %PA, i1* %PB) {
5656 ; CHECK-NEXT: icmp
5757 ; CHECK-NEXT: store
66 while.body:
77 br label %while.body
88 }
9 ;CHECK: @main
9 ;CHECK-LABEL: @main(
1010 ;CHECK: endless_loop
1111 ;CHECK: ret
1212 define i32 @main() noreturn nounwind ssp uwtable {
22 declare i32 @foo(i32) readnone
33
44 define i1 @bar() {
5 ; CHECK: @bar
5 ; CHECK-LABEL: @bar(
66 %a = call i32 @foo (i32 0) readnone
77 %b = call i32 @foo (i32 0) readnone
88 %c = and i32 %a, %b
66 target triple = "x86_64-apple-macosx10.7.0"
77
88 define i1 @rb_intern() nounwind ssp {
9 ; CHECK: @rb_intern
9 ; CHECK-LABEL: @rb_intern(
1010
1111 bb:
1212 %tmp = alloca i8*, align 8
1010 ret i64 %add1
1111 }
1212
13 ; CHECK: @test1
13 ; CHECK-LABEL: @test1(
1414 ; CHECK-NOT: add1
1515 ; CHECK: ret
1616
2222 ret i64 %sub1
2323 }
2424
25 ; CHECK: @test2
25 ; CHECK-LABEL: @test2(
2626 ; CHECK-NOT: sub1
2727 ; CHECK: ret
2828
3434 ret i64 %mul1
3535 }
3636
37 ; CHECK: @test3
37 ; CHECK-LABEL: @test3(
3838 ; CHECK-NOT: mul1
3939 ; CHECK: ret
4040
4646 ret i64 %add1
4747 }
4848
49 ; CHECK: @test4
49 ; CHECK-LABEL: @test4(
5050 ; CHECK-NOT: add1
5151 ; CHECK: ret
5252
5858 ret i64 %sub1
5959 }
6060
61 ; CHECK: @test5
61 ; CHECK-LABEL: @test5(
6262 ; CHECK-NOT: sub1
6363 ; CHECK: ret
6464
7070 ret i64 %mul1
7171 }
7272
73 ; CHECK: @test6
73 ; CHECK-LABEL: @test6(
7474 ; CHECK-NOT: mul1
7575 ; CHECK: ret
7676
22 declare void @use(i32, i32)
33
44 define void @foo(i32 %x, i32 %y) {
5 ; CHECK: @foo
5 ; CHECK-LABEL: @foo(
66 %add1 = add i32 %x, %y
77 %add2 = add i32 %y, %x
88 call void @use(i32 %add1, i32 %add2)
1313 declare void @vse(i1, i1)
1414
1515 define void @bar(i32 %x, i32 %y) {
16 ; CHECK: @bar
16 ; CHECK-LABEL: @bar(
1717 %cmp1 = icmp ult i32 %x, %y
1818 %cmp2 = icmp ugt i32 %y, %x
1919 call void @vse(i1 %cmp1, i1 %cmp2)
11
22 @a = external global i32 ; [#uses=7]
33
4 ; CHECK: @test1
4 ; CHECK-LABEL: @test1(
55 define i32 @test1() nounwind {
66 entry:
77 %0 = load i32* @a, align 4
5656 declare void @foo(i1)
5757 declare void @bar(i32)
5858
59 ; CHECK: @test3
59 ; CHECK-LABEL: @test3(
6060 define void @test3(i32 %x, i32 %y) {
6161 %xz = icmp eq i32 %x, 0
6262 %yz = icmp eq i32 %y, 0
7878 ret void
7979 }
8080
81 ; CHECK: @test4
81 ; CHECK-LABEL: @test4(
8282 define void @test4(i1 %b, i32 %x) {
8383 br i1 %b, label %sw, label %case3
8484 sw:
111111 ret void
112112 }
113113
114 ; CHECK: @test5
114 ; CHECK-LABEL: @test5(
115115 define i1 @test5(i32 %x, i32 %y) {
116116 %cmp = icmp eq i32 %x, %y
117117 br i1 %cmp, label %same, label %different
127127 ret i1 %cmp3
128128 }
129129
130 ; CHECK: @test6
130 ; CHECK-LABEL: @test6(
131131 define i1 @test6(i32 %x, i32 %y) {
132132 %cmp2 = icmp ne i32 %x, %y
133133 %cmp = icmp eq i32 %x, %y
143143 ret i1 %cmp3
144144 }
145145
146 ; CHECK: @test7
146 ; CHECK-LABEL: @test7(
147147 define i1 @test7(i32 %x, i32 %y) {
148148 %cmp = icmp sgt i32 %x, %y
149149 br i1 %cmp, label %same, label %different
159159 ret i1 %cmp3
160160 }
161161
162 ; CHECK: @test8
162 ; CHECK-LABEL: @test8(
163163 define i1 @test8(i32 %x, i32 %y) {
164164 %cmp2 = icmp sle i32 %x, %y
165165 %cmp = icmp sgt i32 %x, %y
176176 }
177177
178178 ; PR1768
179 ; CHECK: @test9
179 ; CHECK-LABEL: @test9(
180180 define i32 @test9(i32 %i, i32 %j) {
181181 %cmp = icmp eq i32 %i, %j
182182 br i1 %cmp, label %cond_true, label %ret
192192 }
193193
194194 ; PR1768
195 ; CHECK: @test10
195 ; CHECK-LABEL: @test10(
196196 define i32 @test10(i32 %j, i32 %i) {
197197 %cmp = icmp eq i32 %i, %j
198198 br i1 %cmp, label %cond_true, label %ret
209209
210210 declare i32 @yogibar()
211211
212 ; CHECK: @test11
212 ; CHECK-LABEL: @test11(
213213 define i32 @test11(i32 %x) {
214214 %v0 = call i32 @yogibar()
215215 %v1 = call i32 @yogibar()
232232 ret i32 0
233233 }
234234
235 ; CHECK: @test12
235 ; CHECK-LABEL: @test12(
236236 define i32 @test12(i32 %x) {
237237 %cmp = icmp eq i32 %x, 0
238238 br i1 %cmp, label %cond_true, label %cond_false
44 @p = external global i32
55
66 define i32 @test(i32 %n) nounwind {
7 ; CHECK: @test
7 ; CHECK-LABEL: @test(
88 entry:
99 br label %for.cond
1010
2020 if.end: ; preds = %if.then, %entry
2121 ret i8* %call
2222
23 ; CHECK: @test
23 ; CHECK-LABEL: @test(
2424 ; CHECK-NOT: load
2525 ; CHECK-NOT: icmp
2626
27 ; CHECK_NO_LIBCALLS: @test
27 ; CHECK_NO_LIBCALLS-LABEL: @test(
2828 ; CHECK_NO_LIBCALLS: load
2929 ; CHECK_NO_LIBCALLS: icmp
3030 }
44 ; GVN should ignore the store to p[1] to see that the load from p[0] is
55 ; fully redundant.
66
7 ; CHECK: @yes
7 ; CHECK-LABEL: @yes(
88 ; CHECK: if.then:
99 ; CHECK-NEXT: store i32 0, i32* %q
1010 ; CHECK-NEXT: ret void
2929 ; fully redundant. However, the second load is larger, so it's not a simple
3030 ; redundancy.
3131
32 ; CHECK: @watch_out_for_size_change
32 ; CHECK-LABEL: @watch_out_for_size_change(
3333 ; CHECK: if.then:
3434 ; CHECK-NEXT: store i32 0, i32* %q
3535 ; CHECK-NEXT: ret void
11
22 target datalayout = "e-p:64:64:64"
33
4 ; CHECK: @foo
4 ; CHECK-LABEL: @foo(
55 ; CHECK: entry.end_crit_edge:
66 ; CHECK: %n.pre = load i32* %q.phi.trans.insert
77 ; CHECK: then:
99 store <2 x i8*> %v3, <2 x i8*>* %v4
1010 %v5 = load <2 x i32>* %v1
1111 ret <2 x i32> %v5
12 ; CHECK: @test1
12 ; CHECK-LABEL: @test1(
1313 ; CHECK: %v1 = alloca <2 x i32>
1414 ; CHECK: call void @anything(<2 x i32>* %v1)
1515 ; CHECK: %v2 = load <2 x i32>* %v1
11 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
22
33 define i32 @test1(i32* %p, i1 %C) {
4 ; CHECK: @test1
4 ; CHECK-LABEL: @test1(
55 block1:
66 br i1 %C, label %block2, label %block3
77
2424
2525 ; This is a simple phi translation case.
2626 define i32 @test2(i32* %p, i32* %q, i1 %C) {
27 ; CHECK: @test2
27 ; CHECK-LABEL: @test2(
2828 block1:
2929 br i1 %C, label %block2, label %block3
3030
4949
5050 ; This is a PRE case that requires phi translation through a GEP.
5151 define i32 @test3(i32* %p, i32* %q, i32** %Hack, i1 %C) {
52 ; CHECK: @test3
52 ; CHECK-LABEL: @test3(
5353 block1:
5454 %B = getelementptr i32* %q, i32 1
5555 store i32* %B, i32** %Hack
7979 ;; Here the loaded address is available, but the computation is in 'block3'
8080 ;; which does not dominate 'block2'.
8181 define i32 @test4(i32* %p, i32* %q, i32** %Hack, i1 %C) {
82 ; CHECK: @test4
82 ; CHECK-LABEL: @test4(
8383 block1:
8484 br i1 %C, label %block2, label %block3
8585
115115 ;}
116116
117117 define void @test5(i32 %N, double* nocapture %G) nounwind ssp {
118 ; CHECK: @test5
118 ; CHECK-LABEL: @test5(
119119 entry:
120120 %0 = add i32 %N, -1
121121 %1 = icmp sgt i32 %0, 0
158158 ;}
159159
160160 define void @test6(i32 %N, double* nocapture %G) nounwind ssp {
161 ; CHECK: @test6
161 ; CHECK-LABEL: @test6(
162162 entry:
163163 %0 = add i32 %N, -1
164164 %1 = icmp sgt i32 %0, 0
241241 ;; Here the loaded address isn't available in 'block2' at all, requiring a new
242242 ;; GEP to be inserted into it.
243243 define i32 @test8(i32* %p, i32* %q, i32** %Hack, i1 %C) {
244 ; CHECK: @test8
244 ; CHECK-LABEL: @test8(
245245 block1:
246246 br i1 %C, label %block2, label %block3
247247
364364
365365 ; Test critical edge splitting.
366366 define i32 @test11(i32* %p, i1 %C, i32 %N) {
367 ; CHECK: @test11
367 ; CHECK-LABEL: @test11(
368368 block1:
369369 br i1 %C, label %block2, label %block3
370370
33
44 ; GVN should preserve the TBAA tag on loads when doing PRE.
55
6 ; CHECK: @test
6 ; CHECK-LABEL: @test(
77 ; CHECK: %tmp33.pre = load i16* %P, align 2, !tbaa !0
88 ; CHECK: br label %for.body
99 define void @test(i16 *%P, i16* %Q) nounwind {
33 target triple = "i386-apple-darwin7"
44
55 define i32 @test1(i32* %b, i32* %c) nounwind {
6 ; CHECK: @test1
6 ; CHECK-LABEL: @test1(
77 entry:
88 %g = alloca i32
99 %t1 = icmp eq i32* %b, null
3535 }
3636
3737 define i8 @test2(i1 %cond, i32* %b, i32* %c) nounwind {
38 ; CHECK: @test2
38 ; CHECK-LABEL: @test2(
3939 entry:
4040 br i1 %cond, label %bb, label %bb1
4141
6060 }
6161
6262 define i32 @test3(i1 %cond, i32* %b, i32* %c) nounwind {
63 ; CHECK: @test3
63 ; CHECK-LABEL: @test3(
6464 entry:
6565 br i1 %cond, label %bb, label %bb1
6666
8787
8888 ; PR5313
8989 define i32 @test4(i1 %cond, i32* %b, i32* %c) nounwind {
90 ; CHECK: @test4
90 ; CHECK-LABEL: @test4(
9191 entry:
9292 br i1 %cond, label %bb, label %bb1
9393
120120 ;
121121 ; Should compile into one load in the loop.
122122 define void @test5(i32 %N, double* nocapture %G) nounwind ssp {
123 ; CHECK: @test5
123 ; CHECK-LABEL: @test5(
124124 bb.nph:
125125 br label %for.body
126126
66
77 %A = load i32* %P
88 ret i32 %A
9 ; CHECK: @test0
9 ; CHECK-LABEL: @test0(
1010 ; CHECK: ret i32 %V
1111 }
1212
4646
4747 %A = load float* %P2
4848 ret float %A
49 ; CHECK: @coerce_mustalias1
49 ; CHECK-LABEL: @coerce_mustalias1(
5050 ; CHECK-NOT: load
5151 ; CHECK: ret float
5252 }
5959
6060 %A = load float* %P2
6161 ret float %A
62 ; CHECK: @coerce_mustalias2
62 ; CHECK-LABEL: @coerce_mustalias2(
6363 ; CHECK-NOT: load
6464 ; CHECK: ret float
6565 }
7272
7373 %A = load i32** %P2
7474 ret i32* %A
75 ; CHECK: @coerce_mustalias3
75 ; CHECK-LABEL: @coerce_mustalias3(
7676 ; CHECK-NOT: load
7777 ; CHECK: ret i32*
7878 }
9191 %X = bitcast i32 %A to float
9292 ret float %X
9393
94 ; CHECK: @coerce_mustalias4
94 ; CHECK-LABEL: @coerce_mustalias4(
9595 ; CHECK: %A = load i32* %P
9696 ; CHECK-NOT: load
9797 ; CHECK: ret float
106106
107107 %A = load i8* %P2
108108 ret i8 %A
109 ; CHECK: @coerce_mustalias5
109 ; CHECK-LABEL: @coerce_mustalias5(
110110 ; CHECK-NOT: load
111111 ; CHECK: ret i8
112112 }
119119
120120 %A = load float* %P2
121121 ret float %A
122 ; CHECK: @coerce_mustalias6
122 ; CHECK-LABEL: @coerce_mustalias6(
123123 ; CHECK-NOT: load
124124 ; CHECK: ret float
125125 }
132132
133133 %A = load i8** %P2
134134 ret i8* %A
135 ; CHECK: @coerce_mustalias7
135 ; CHECK-LABEL: @coerce_mustalias7(
136136 ; CHECK-NOT: load
137137 ; CHECK: ret i8*
138138 }
145145 %arrayidx = getelementptr inbounds i16* %A, i64 42
146146 %tmp2 = load i16* %arrayidx
147147 ret i16 %tmp2
148 ; CHECK: @memset_to_i16_local
148 ; CHECK-LABEL: @memset_to_i16_local(
149149 ; CHECK-NOT: load
150150 ; CHECK: ret i16 257
151151 }
158158 %arrayidx = getelementptr inbounds float* %A, i64 42 ; [#uses=1]
159159 %tmp2 = load float* %arrayidx ; [#uses=1]
160160 ret float %tmp2
161 ; CHECK: @memset_to_float_local
161 ; CHECK-LABEL: @memset_to_float_local(
162162 ; CHECK-NOT: load
163163 ; CHECK: zext
164164 ; CHECK-NEXT: shl
186186 %A = load i16* %P2
187187 ret i16 %A
188188
189 ; CHECK: @memset_to_i16_nonlocal0
189 ; CHECK-LABEL: @memset_to_i16_nonlocal0(
190190 ; CHECK: Cont:
191191 ; CHECK-NEXT: %A = phi i16 [ 514, %F ], [ 257, %T ]
192192 ; CHECK-NOT: load
203203 %arrayidx = getelementptr inbounds float* %A, i64 1 ; [#uses=1]
204204 %tmp2 = load float* %arrayidx ; [#uses=1]
205205 ret float %tmp2
206 ; CHECK: @memcpy_to_float_local
206 ; CHECK-LABEL: @memcpy_to_float_local(
207207 ; CHECK-NOT: load
208208 ; CHECK: ret float 1.400000e+01
209209 }
227227 %A = load i8* %P3
228228 ret i8 %A
229229
230 ; CHECK: @coerce_mustalias_nonlocal0
230 ; CHECK-LABEL: @coerce_mustalias_nonlocal0(
231231 ; CHECK: Cont:
232232 ; CHECK: %A = phi i8 [
233233 ; CHECK-NOT: load
253253 %A = load i8* %P3
254254 ret i8 %A
255255
256 ; CHECK: @coerce_mustalias_nonlocal1
256 ; CHECK-LABEL: @coerce_mustalias_nonlocal1(
257257 ; CHECK: Cont:
258258 ; CHECK: %A = phi i8 [
259259 ; CHECK-NOT: load
276276 %A = load i8* %P3
277277 ret i8 %A
278278
279 ; CHECK: @coerce_mustalias_pre0
279 ; CHECK-LABEL: @coerce_mustalias_pre0(
280280 ; CHECK: F:
281281 ; CHECK: load i8* %P3
282282 ; CHECK: Cont:
300300
301301 %A = load i8* %P3
302302 ret i8 %A
303 ; CHECK: @coerce_offset0
303 ; CHECK-LABEL: @coerce_offset0(
304304 ; CHECK-NOT: load
305305 ; CHECK: ret i8
306306 }
323323 %A = load i8* %P4
324324 ret i8 %A
325325
326 ; CHECK: @coerce_offset_nonlocal0
326 ; CHECK-LABEL: @coerce_offset_nonlocal0(
327327 ; CHECK: Cont:
328328 ; CHECK: %A = phi i8 [
329329 ; CHECK-NOT: load
347347 %A = load i8* %P4
348348 ret i8 %A
349349
350 ; CHECK: @coerce_offset_pre0
350 ; CHECK-LABEL: @coerce_offset_pre0(
351351 ; CHECK: F:
352352 ; CHECK: load i8* %P4
353353 ; CHECK: Cont:
377377 %d = load i32* %c
378378 ret i32 %d
379379
380 ; CHECK: @chained_load
380 ; CHECK-LABEL: @chained_load(
381381 ; CHECK: %z = load i32** %p
382382 ; CHECK-NOT: load
383383 ; CHECK: %d = load i32* %z
389389 declare i1 @cond2() readonly
390390
391391 define i32 @phi_trans2() {
392 ; CHECK: @phi_trans2
392 ; CHECK-LABEL: @phi_trans2(
393393 entry:
394394 %P = alloca i32, i32 400
395395 br label %F1
427427 }
428428
429429 define i32 @phi_trans3(i32* %p) {
430 ; CHECK: @phi_trans3
430 ; CHECK-LABEL: @phi_trans3(
431431 block1:
432432 br i1 true, label %block2, label %block3
433433
468468 }
469469
470470 define i8 @phi_trans4(i8* %p) {
471 ; CHECK: @phi_trans4
471 ; CHECK-LABEL: @phi_trans4(
472472 entry:
473473 %X3 = getelementptr i8* %p, i32 192
474474 store i8 192, i8* %X3
498498 }
499499
500500 define i8 @phi_trans5(i8* %p) {
501 ; CHECK: @phi_trans5
501 ; CHECK-LABEL: @phi_trans5(
502502 entry:
503503
504504 %X4 = getelementptr i8* %p, i32 2
541541 %arraydecay = getelementptr inbounds [256 x i32]* %x, i32 0, i32 0 ;
542542 %tmp1 = load i32* %arraydecay ; [#uses=1]
543543 ret i32 %tmp1
544 ; CHECK: @memset_to_load
544 ; CHECK-LABEL: @memset_to_load(
545545 ; CHECK: ret i32 0
546546 }
547547
560560 %add = add nsw i32 %tmp2, %conv
561561 ret i32 %add
562562
563 ; TEMPORARILYDISABLED: @load_load_partial_alias
563 ; TEMPORARILYDISABLED-LABEL: @load_load_partial_alias(
564564 ; TEMPORARILYDISABLED: load i32*
565565 ; TEMPORARILYDISABLED-NOT: load
566566 ; TEMPORARILYDISABLED: lshr i32 {{.*}}, 8
587587
588588 if.end:
589589 ret i32 52
590 ; TEMPORARILY_DISABLED: @load_load_partial_alias_cross_block
590 ; TEMPORARILY_DISABLED-LABEL: @load_load_partial_alias_cross_block(
591591 ; TEMPORARILY_DISABLED: land.lhs.true:
592592 ; TEMPORARILY_DISABLED-NOT: load i8
593593 ; TEMPORARILY_DISABLED: ret i32 %conv6
610610 %conv2 = zext i8 %tmp1 to i32
611611 %add = add nsw i32 %conv, %conv2
612612 ret i32 %add
613 ; CHECK: @test_widening1
613 ; CHECK-LABEL: @test_widening1(
614614 ; CHECK-NOT: load
615615 ; CHECK: load i16*
616616 ; CHECK-NOT: load
634634 %add3 = add nsw i32 %add2, %conv3
635635
636636 ret i32 %add3
637 ; CHECK: @test_widening2
637 ; CHECK-LABEL: @test_widening2(
638638 ; CHECK-NOT: load
639639 ; CHECK: load i32*
640640 ; CHECK-NOT: load
0 ; RUN: opt < %s -globalopt -S | FileCheck %s
11
22 define internal void @f() {
3 ; CHECK-NOT: @f
3 ; CHECK-NOT-LABEL: @f(
44 ; CHECK: define void @a
55 ret void
66 }
22 @x = internal global i8* zeroinitializer
33
44 define void @f() {
5 ; CHECK: @f
5 ; CHECK-LABEL: @f(
66
77 ; Check that we don't hit an assert in Constant::IsThreadDependent()
88 ; when storing this blockaddress into a global.
1212 }
1313
1414 define void @g() {
15 ; CHECK: @g
15 ; CHECK-LABEL: @g(
1616
1717 here:
1818 ret void
22 @glbl = internal global i8* null
33
44 define void @test1a() {
5 ; CHECK: @test1a
5 ; CHECK-LABEL: @test1a(
66 ; CHECK-NOT: store
77 ; CHECK-NEXT: ret void
88 store i8* null, i8** @glbl
1010 }
1111
1212 define void @test1b(i8* %p) {
13 ; CHECK: @test1b
13 ; CHECK-LABEL: @test1b(
1414 ; CHECK-NEXT: store
1515 ; CHECK-NEXT: ret void
1616 store i8* %p, i8** @glbl
1818 }
1919
2020 define void @test2() {
21 ; CHECK: @test2
21 ; CHECK-LABEL: @test2(
2222 ; CHECK: alloca i8
2323 %txt = alloca i8
2424 call void @foo2(i8* %txt)
3030 declare void @foo2(i8*)
3131
3232 define void @test3() uwtable {
33 ; CHECK: @test3
33 ; CHECK-LABEL: @test3(
3434 ; CHECK-NOT: bb1:
3535 ; CHECK-NOT: bb2:
3636 ; CHECK: invoke
1919 store i32* inttoptr (i64 sdiv (i64 ptrtoint (i32* @G to i64), i64 ptrtoint (i32* @H to i64)) to i32*), i32** %tmp, align 8
2020 ret void
2121 }
22 ; CHECK: @init1
22 ; CHECK-LABEL: @init1(
2323 ; CHECK: store i32*
2424
2525 ; PR11705 - ptrtoint isn't safe in general in global initializers.
2929 store i128 ptrtoint (i32* @G to i128), i128* %tmp, align 16
3030 ret void
3131 }
32 ; CHECK: @init2
32 ; CHECK-LABEL: @init2(
3333 ; CHECK: store i128
1818 }
1919
2020 define i1 @get() {
21 ; CHECK: @get
21 ; CHECK-LABEL: @get(
2222 %A = load i32 addrspace(1) * @G
2323 %C = icmp slt i32 %A, 2
2424 ret i1 %C
66 %V = load i32* @G ; [#uses=1]
77 store i32 %V, i32* @G
88 ret void
9 ; CHECK: @foo
9 ; CHECK-LABEL: @foo(
1010 ; CHECK-NEXT: ret void
1111 }
1212
1313 define i32 @bar() {
1414 %X = load i32* @G ; [#uses=1]
1515 ret i32 %X
16 ; CHECK: @bar
16 ; CHECK-LABEL: @bar(
1717 ; CHECK-NEXT: ret i32 17
1818 }
1919
3030 store i64* inttoptr (i64 1 to i64*), i64** @a, align 8
3131 %l = load i64** @a, align 8
3232 ret void
33 ; CHECK: @qux
33 ; CHECK-LABEL: @qux(
3434 ; CHECK-NOT: store
3535 ; CHECK-NOT: load
3636 }
55 @G = internal global i8** null
66
77 define i32 @main(i32 %argc, i8** %argv) {
8 ; CHECK: @main
8 ; CHECK-LABEL: @main(
99 ; CHECK: %G = alloca
1010 store i8** %argv, i8*** @G
1111 ret i32 0
2828 %1 = load i32* %0, align 4
2929 ret i32 %1
3030
31 ; CHECK: @f
31 ; CHECK-LABEL: @f(
3232 ; Make sure that the load from @ip hasn't been removed.
3333 ; CHECK: load i32** @ip
3434 ; CHECK: ret
4545 tail call void @signal() nounwind
4646 ret void
4747
48 ; CHECK: @g
48 ; CHECK-LABEL: @g(
4949 ; Make sure that the store to @ip hasn't been removed.
5050 ; CHECK: store {{.*}} @ip
5151 ; CHECK: ret
55 %arrayidx = getelementptr inbounds [10 x i32]* @zero, i64 0, i64 %idx
66 %l = load i32* %arrayidx
77 ret i32 %l
8 ; CHECK: @test1
8 ; CHECK-LABEL: @test1(
99 ; CHECK: ret i32 0
1010 }
33 target datalayout = "e-p:32:32:32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:32:64-v128:32:128-a0:0:32-n32-S32"
44 target triple = "thumbv7-apple-darwin"
55
6 ; CHECK: @test
6 ; CHECK-LABEL: @test(
77 ; CHECK: if.end.i126:
88 ; CHECK: %exitcond = icmp ne i8* %incdec.ptr.i, getelementptr (i8* null, i32 undef)
99 define void @test() nounwind {
88 ; SCEV. Since it's an i8*, it has unit stride so we never adjust the
99 ; SCEV expression in a way that would convert it to an integer type.
1010
11 ; CHECK: @testnullptrptr
11 ; CHECK-LABEL: @testnullptrptr(
1212 ; CHECK: loop:
1313 ; CHECK: icmp ne
1414 define i8 @testnullptrptr(i8* %buf, i8* %end) nounwind {
3333 ret i8 %snext
3434 }
3535
36 ; CHECK: @testptrptr
36 ; CHECK-LABEL: @testptrptr(
3737 ; CHECK: loop:
3838 ; CHECK: icmp ne
3939 define i8 @testptrptr(i8* %buf, i8* %end) nounwind {
5858 ret i8 %snext
5959 }
6060
61 ; CHECK: @testnullptrint
61 ; CHECK-LABEL: @testnullptrint(
6262 ; CHECK: loop:
6363 ; CHECK: icmp ne
6464 define i8 @testnullptrint(i8* %buf, i8* %end) nounwind {
8888 ret i8 %snext
8989 }
9090
91 ; CHECK: @testptrint
91 ; CHECK-LABEL: @testptrint(
9292 ; CHECK: loop:
9393 ; CHECK: icmp ne
9494 define i8 @testptrint(i8* %buf, i8* %end) nounwind {
0 ; RUN: opt < %s -indvars -S | FileCheck %s
11 ; PR11350: Check that SimplifyIndvar handles a cycle of useless self-phis.
22
3 ; CHECK: @test
3 ; CHECK-LABEL: @test(
44 ; CHECK-NOT: lcssa = phi
55 define void @test() nounwind {
66 entry:
11 ; PR13371: indvars pass incorrectly substitutes 'undef' values
22 ;
33 ; LFTR should not user %undef as the loop counter.
4 ; CHECK: @test
4 ; CHECK-LABEL: @test(
55 ; CHECK-NOT: icmp{{.*}}undef
66 @.str3 = private constant [6 x i8] c"%lld\0A\00", align 1
77 declare i32 @printf(i8* noalias nocapture, ...) nounwind
1818 for.end: ; preds = %for.body
1919 ret void
2020
21 ; CHECK: @test1
21 ; CHECK-LABEL: @test1(
2222 ; CHECK-NOT: phi i1
2323 ; CHECK: call void @aux(i1 false, i1 false)
2424 }
2020
2121 declare void @func(i32)
2222
23 ; CHECK: @test
23 ; CHECK-LABEL: @test(
2424 define void @test(i32 %m) nounwind uwtable {
2525 entry:
2626 br label %for.body
4444 ret void
4545 }
4646
47 ; CHECK: @test2
47 ; CHECK-LABEL: @test2(
4848 define i32 @test2(i32 %m) nounwind uwtable {
4949 entry:
5050 br label %for.body
66 ; Indvars should be able to simplify simple comparisons involving
77 ; induction variables.
88
9 ; CHECK: @foo
9 ; CHECK-LABEL: @foo(
1010 ; CHECK: %cond = and i1 %tobool.not, true
1111
1212 define void @foo(i64 %n, i32* nocapture %p) nounwind {
4141
4242 ; Don't eliminate an icmp that's contributing to the loop exit test though.
4343
44 ; CHECK: @_ZNK4llvm5APInt3ultERKS0_
44 ; CHECK-LABEL: @_ZNK4llvm5APInt3ultERKS0_(
4545 ; CHECK: %tmp99 = icmp sgt i32 %i, -1
4646
4747 define i32 @_ZNK4llvm5APInt3ultERKS0_(i32 %tmp2.i1, i64** %tmp65, i64** %tmp73, i64** %tmp82, i64** %tmp90) {
8484
8585 ; Indvars should eliminate the icmp here.
8686
87 ; CHECK: @func_10
87 ; CHECK-LABEL: @func_10(
8888 ; CHECK-NOT: icmp
8989 ; CHECK: ret void
9090
109109 ; PR14432
110110 ; Indvars should not turn the second loop into an infinite one.
111111
112 ; CHECK: @func_11
112 ; CHECK-LABEL: @func_11(
113113 ; CHECK: %tmp5 = icmp slt i32 %__key6.0, 10
114114 ; CHECK-NOT: br i1 true, label %noassert68, label %unrolledend
115115
161161 declare void @llvm.trap() noreturn nounwind
162162
163163 ; In this case the second loop only has a single iteration, fold the header away
164 ; CHECK: @func_12
164 ; CHECK-LABEL: @func_12(
165165 ; CHECK: %tmp5 = icmp slt i32 %__key6.0, 10
166166 ; CHECK: br i1 true, label %noassert68, label %unrolledend
167167 define i32 @func_12() nounwind uwtable {
22 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
33
44 ; Indvars should be able to eliminate this srem.
5 ; CHECK: @simple
5 ; CHECK-LABEL: @simple(
66 ; CHECK-NOT: rem
77 ; CHECK: ret
88
3131 }
3232
3333 ; Indvars should be able to eliminate the (i+1)%n.
34 ; CHECK: @f
34 ; CHECK-LABEL: @f(
3535 ; CHECK-NOT: rem
3636 ; CHECK: rem
3737 ; CHECK-NOT: rem
1111
1212 return: ; preds = %bb
1313 ret void
14 ; CHECK: @test1
14 ; CHECK-LABEL: @test1(
1515 ; CHECK: icmp
1616 }
1717
3030
3131 return: ; preds = %bb
3232 ret void
33 ; CHECK: @test2
33 ; CHECK-LABEL: @test2(
3434 ; CHECK: icmp
3535 }
3636
4848
4949 return:
5050 ret void
51 ; CHECK: @test3
51 ; CHECK-LABEL: @test3(
5252 ; CHECK: fcmp
5353 }
5454
6565
6666 return:
6767 ret void
68 ; CHECK: @test4
68 ; CHECK-LABEL: @test4(
6969 ; CHECK-NOT: cmp
7070 ; CHECK: br i1 false
7171 }
8585 exit:
8686 ret void
8787
88 ; CHECK: @test5
88 ; CHECK-LABEL: @test5(
8989 ; CHECK: icmp slt i32 {{.*}}, 0
9090 ; CHECK-NEXT: br i1
9191 }
33
44 ; Indvars should be able to fold IV increments into shr when low bits are zero.
55 ;
6 ; CHECK: @foldIncShr
6 ; CHECK-LABEL: @foldIncShr(
77 ; CHECK: shr.1 = lshr i32 %0, 5
88 define i32 @foldIncShr(i32* %bitmap, i32 %bit_addr, i32 %nbits) nounwind {
99 entry:
3030 ; Invdars should not fold an increment into shr unless 2^shiftBits is
3131 ; a multiple of the recurrence step.
3232 ;
33 ; CHECK: @noFoldIncShr
33 ; CHECK-LABEL: @noFoldIncShr(
3434 ; CHECK: shr.1 = lshr i32 %inc.1, 5
3535 define i32 @noFoldIncShr(i32* %bitmap, i32 %bit_addr, i32 %nbits) nounwind {
3636 entry:
0 ;RUN: opt -S %s -indvars | FileCheck %s
11
2 ; CHECK-LABEL: @foo
2 ; CHECK-LABEL-LABEL: @foo(
33 ; CHECK-NOT: %lftr.wideiv = trunc i32 %indvars.iv.next to i16
44 ; CHECK: %exitcond = icmp ne i32 %indvars.iv.next, 512
55 define void @foo() #0 {
1919 }
2020
2121 ; Check that post-incrementing the backedge taken count does not overflow.
22 ; CHECK-LABEL: @postinc
22 ; CHECK-LABEL-LABEL: @postinc(
2323 ; CHECK: icmp eq i32 %indvars.iv.next, 256
2424 define i32 @postinc() #0 {
2525 entry:
164164 %lim = add i32 %x, %n
165165 %cmp.ph = icmp ult i32 %x, %lim
166166 br i1 %cmp.ph, label %loop, label %exit
167 ; CHECK: @geplftr
167 ; CHECK-LABEL: @geplftr(
168168 ; CHECK: loop:
169169 ; CHECK: phi i8*
170170 ; DISABLE-NOT: phi // This check is currently disabled
189189 define void @nevertaken() nounwind uwtable ssp {
190190 entry:
191191 br label %loop
192 ; CHECK: @nevertaken
192 ; CHECK-LABEL: @nevertaken(
193193 ; CHECK: loop:
194194 ; CHECK-NOT: phi
195195 ; CHECK-NOT: add
44 ; the exit value of the loop will be for some value, allowing us to substitute
55 ; it directly into users outside of the loop, making the loop dead.
66
7 ; CHECK: @linear_setne
7 ; CHECK-LABEL: @linear_setne(
88 ; CHECK: ret i32 100
99
1010 define i32 @linear_setne() {
2121 ret i32 %i
2222 }
2323
24 ; CHECK: @linear_setne_2
24 ; CHECK-LABEL: @linear_setne_2(
2525 ; CHECK: ret i32 100
2626
2727 define i32 @linear_setne_2() {
3838 ret i32 %i
3939 }
4040
41 ; CHECK: @linear_setne_overflow
41 ; CHECK-LABEL: @linear_setne_overflow(
4242 ; CHECK: ret i32 0
4343
4444 define i32 @linear_setne_overflow() {
5555 ret i32 %i
5656 }
5757
58 ; CHECK: @linear_setlt
58 ; CHECK-LABEL: @linear_setlt(
5959 ; CHECK: ret i32 100
6060
6161 define i32 @linear_setlt() {
7272 ret i32 %i
7373 }
7474
75 ; CHECK: @quadratic_setlt
75 ; CHECK-LABEL: @quadratic_setlt(
7676 ; CHECK: ret i32 34
7777
7878 define i32 @quadratic_setlt() {
9090 ret i32 %i
9191 }
9292
93 ; CHECK: @chained
93 ; CHECK-LABEL: @chained(
9494 ; CHECK: ret i32 200
9595
9696 define i32 @chained() {
116116 ret i32 %j
117117 }
118118
119 ; CHECK: @chained4
119 ; CHECK-LABEL: @chained4(
120120 ; CHECK: ret i32 400
121121
122122 define i32 @chained4() {
2626 ret i32 0
2727 }
2828
29 ; CHECK: @foo
29 ; CHECK-LABEL: @foo(
3030 ; CHECK: bb8:
3131 ; CHECK: udiv
77 ; Indvars shouldn't emit a udiv here, because there's no udiv in the
88 ; original code. This comes from SingleSource/Benchmarks/Shootout/sieve.c.
99
10 ; CHECK: @main
10 ; CHECK-LABEL: @main(
1111 ; CHECK-NOT: div
1212
1313 define i32 @main(i32 %argc, i8** nocapture %argv) nounwind {
129129 ; IndVars shouldn't be afraid to emit a udiv here, since there's a udiv in
130130 ; the original code.
131131
132 ; CHECK: @foo
132 ; CHECK-LABEL: @foo(
133133 ; CHECK: for.body.preheader:
134134 ; CHECK-NEXT: udiv
135135
2525 for.end: ; preds = %for.body, %entry
2626 ret void
2727
28 ; CHECK: @test1
28 ; CHECK-LABEL: @test1(
2929
3030 ; First check that we move the sub into the preheader, it doesn't have to be
3131 ; executed if %cmp4 == false
66 @glbl = external global i32
77
88 define void @outer1() {
9 ; CHECK: @outer1
9 ; CHECK-LABEL: @outer1(
1010 ; CHECK-NOT: call void @inner1
1111 %ptr = alloca i32
1212 call void @inner1(i32* %ptr)
2525 }
2626
2727 define void @outer2() {
28 ; CHECK: @outer2
28 ; CHECK-LABEL: @outer2(
2929 ; CHECK: call void @inner2
3030 %ptr = alloca i32
3131 call void @inner2(i32* %ptr)
4545 }
4646
4747 define void @outer3() {
48 ; CHECK: @outer3
48 ; CHECK-LABEL: @outer3(
4949 ; CHECK-NOT: call void @inner3
5050 %ptr = alloca i32
5151 call void @inner3(i32* %ptr, i1 undef)
8484 }
8585
8686 define void @outer4(i32 %A) {
87 ; CHECK: @outer4
87 ; CHECK-LABEL: @outer4(
8888 ; CHECK-NOT: call void @inner4
8989 %ptr = alloca i32
9090 call void @inner4(i32* %ptr, i32 %A)
125125 }
126126
127127 define void @outer5() {
128 ; CHECK: @outer5
128 ; CHECK-LABEL: @outer5(
129129 ; CHECK-NOT: call void @inner5
130130 %ptr = alloca i32
131131 call void @inner5(i1 false, i32* %ptr)
77 ret i32 1
88 }
99 define i32 @outer1() {
10 ; CHECK: @outer1
10 ; CHECK-LABEL: @outer1(
1111 ; CHECK-NOT: call
1212 ; CHECK: ret
1313
1616 }
1717
1818 ; The always inliner can't DCE internal functions. PR2945
19 ; CHECK: @pr2945
19 ; CHECK-LABEL: @pr2945(
2020 define internal i32 @pr2945() nounwind {
2121 ret i32 0
2222 }
3030 ; a function with a dynamic alloca into one without a dynamic alloca.
3131 ; rdar://6655932
3232 ;
33 ; CHECK: @outer2
33 ; CHECK-LABEL: @outer2(
3434 ; CHECK-NOT: call void @inner2
3535 ; CHECK-NOT: call void @inner2
3636 ; CHECK: ret void
5050 }
5151 define i32 @outer3() {
5252 entry:
53 ; CHECK: @outer3
53 ; CHECK-LABEL: @outer3(
5454 ; CHECK-NOT: call i32 @a
5555 ; CHECK: ret
5656
6868
6969 define i32 @outer4() {
7070 entry:
71 ; CHECK: @outer4
71 ; CHECK-LABEL: @outer4(
7272 ; CHECK: call i32 @b()
7373 ; CHECK: ret
7474
8888 ret i32 44
8989 }
9090 define i32 @outer5(i32 %x) {
91 ; CHECK: @outer5
91 ; CHECK-LABEL: @outer5(
9292 ; CHECK: call i32 @inner5
9393 ; CHECK: ret
9494
112112 ret void
113113 }
114114 define void @outer6() {
115 ; CHECK: @outer6
115 ; CHECK-LABEL: @outer6(
116116 ; CHECK: call void @inner6(i32 42)
117117 ; CHECK: ret
118118
88 %X = call i32 @test1f(i32 7)
99 %Y = add i32 %X, %W
1010 ret i32 %Y
11 ; CHECK: @test1(
11 ; CHECK-LABEL: @test1(
1212 ; CHECK-NEXT: %Y = add i32 7, %W
1313 ; CHECK-NEXT: ret i32 %Y
1414 }
1919
2020 %T = type { i32, i32 }
2121
22 ; CHECK-NOT: @test2f
22 ; CHECK-NOT-LABEL: @test2f(
2323 define internal %T* @test2f(i1 %cond, %T* %P) {
2424 br i1 %cond, label %T, label %F
2525
4040 %D = load i32* %C
4141 ret i32 %D
4242
43 ; CHECK: @test2(
43 ; CHECK-LABEL: @test2(
4444 ; CHECK-NOT: = alloca
4545 ; CHECK: ret i32
4646 }
7474 ;
7575 ; The call to @h *can* be inlined.
7676
77 ; CHECK: @test
77 ; CHECK-LABEL: @test(
7878 define i32 @test() {
7979 ; CHECK: call i32 @f()
8080 %a = call i32 @f()
3939 ret i32 %X
4040 }
4141
42 ; CHECK: @test2
42 ; CHECK-LABEL: @test2(
4343 ; CHECK-NEXT: ret i32 41
1313 %X = add i32 %call, 4
1414 ret i32 %X
1515
16 ; CHECK: @foo
16 ; CHECK-LABEL: @foo(
1717 ; CHECK-NEXT: entry:
1818 ; CHECK-NEXT: store
1919 ; CHECK-NEXT: store
1818 }
1919
2020 define void @foo(i32 %N) {
21 ; CHECK: @foo
21 ; CHECK-LABEL: @foo(
2222 ; CHECK: alloca i32, i32 %{{.*}}
2323 ; CHECK: call i8* @llvm.stacksave()
2424 ; CHECK: alloca i32, i32 %{{.*}}
1111 %call = tail call i32 %tmp3() nounwind ; [#uses=1]
1212 ret i32 %call
1313 }
14 ; CHECK: @foo
14 ; CHECK-LABEL: @foo(
1515 ; CHECK: ret i32 7
16 ; CHECK: @bar
16 ; CHECK-LABEL: @bar(
1717 ; CHECK: ret i32 7
1818
1919 define internal i32 @bar() nounwind readnone ssp {
2020 %call = call i32 @ray_sphere(%struct.sphere* %i, %struct.ray* byval align 8 %shadow_ray, %struct.spoint* null)
2121 ret i32 %call
2222
23 ; CHECK: @caller
23 ; CHECK-LABEL: @caller(
2424 ; CHECK-NOT: call i32 @ray_sphere
2525 ; CHECK: ret i32
2626 }
5151 declare void @ext(i32*)
5252
5353 define void @test() {
54 ; CHECK: @test
54 ; CHECK-LABEL: @test(
5555 ; CHECK-NOT: ret
5656 ;
5757 ; FIXME: This should be a CHECK-NOT, but currently we have a bug that causes us
201201 }
202202
203203 define void @crasher_outer() {
204 ; CHECK: @crasher_outer
204 ; CHECK-LABEL: @crasher_outer(
205205 ; CHECK-NOT: call
206206 ; CHECK: ret void
207207 ; CHECK-NOT: ret
2020 ; inline and be cheap. We should eventually do that and lower the threshold here
2121 ; to 1.
2222 ;
23 ; CHECK: @caller2
23 ; CHECK-LABEL: @caller2(
2424 ; CHECK-NOT: call void @callee2
2525 ; CHECK: ret
2626
6060 ; it doesn't count toward the inline cost when constant-prop proves those paths
6161 ; dead.
6262 ;
63 ; CHECK: @caller3
63 ; CHECK-LABEL: @caller3(
6464 ; CHECK-NOT: call
6565 ; CHECK: ret i32 6
6666
118118 ; as they are used heavily in standard library code and generic C++ code where
119119 ; the arguments are oftent constant but complete generality is required.
120120 ;
121 ; CHECK: @caller4
121 ; CHECK-LABEL: @caller4(
122122 ; CHECK-NOT: call
123123 ; CHECK: ret i8 -1
124124
152152 ; Check that we can round trip constants through various kinds of casts etc w/o
153153 ; losing track of the constant prop in the inline cost analysis.
154154 ;
155 ; CHECK: @caller5
155 ; CHECK-LABEL: @caller5(
156156 ; CHECK-NOT: call
157157 ; CHECK: ret i64 -1
158158
199199
200200 define i32 @fct3(i32 %c) nounwind uwtable ssp {
201201 entry:
202 ;CHECK: @fct3
202 ;CHECK-LABEL: @fct3(
203203 ;CHECK: call i32 @fct1
204204 ; The inline keyword gives a sufficient benefits to inline fct2
205205 ;CHECK-NOT: call i32 @fct2
215215
216216 define i32 @fct4(i32 %c) minsize nounwind uwtable ssp {
217217 entry:
218 ;CHECK: @fct4
218 ;CHECK-LABEL: @fct4(
219219 ;CHECK: call i32 @fct1
220220 ; With Oz (minsize attribute), the benefit of inlining fct2
221221 ; is the same as fct1, thus no inlining for fct2
99
1010 ; Size in llvm.lifetime.X should be -1 (unknown).
1111 define void @test() {
12 ; CHECK: @test
12 ; CHECK-LABEL: @test(
1313 ; CHECK-NOT: lifetime
1414 ; CHECK: llvm.lifetime.start(i64 -1
1515 ; CHECK-NOT: lifetime