1; RUN: opt < %s -basicaa -gvn -S | FileCheck %s
2
3@g = global i32 0
4
5; CHECK:      @test
6; CHECK:      entry
7; CHECK:      %tmp0 = call i32 @TestConst(i32 5) [[READNONE:#[0-9]+]]
8; CHECK-NEXT: %tmp1 = call i32 @TestPure(i32 6) [[READONLY:#[0-9]+]]
9; CHECK-NEXT: %tmp2 = call i32 @TestNone(i32 7)
10; CHECK-NEXT: store i32 1, i32* @g
11; CHECK-NEXT: %tmp5 = call i32 @TestPure(i32 6) [[READONLY]]
12; CHECK-NEXT: %tmp7 = call i32 @TestNone(i32 7)
13; CHECK-NEXT: %tmp8 = call i32 @TestNone(i32 7)
14; CHECK-NEXT: %sum0 = add i32 %tmp0, %tmp1
15; CHECK-NEXT: %sum1 = add i32 %sum0, %tmp2
16; CHECK-NEXT: %sum2 = add i32 %sum1, %tmp0
17; CHECK-NEXT: %sum3 = add i32 %sum2, %tmp0
18; CHECK-NEXT: %sum4 = add i32 %sum3, %tmp5
19; CHECK-NEXT: %sum5 = add i32 %sum4, %tmp5
20; CHECK-NEXT: %sum6 = add i32 %sum5, %tmp7
21; CHECK-NEXT: %sum7 = add i32 %sum6, %tmp8
22; CHECK-NEXT: ret i32 %sum7
23
24define i32 @test() {
25entry:
26	%tmp0 = call i32 @TestConst( i32 5 ) readnone 		; <i32> [#uses=1]
27	%tmp1 = call i32 @TestPure( i32 6 ) readonly 		; <i32> [#uses=1]
28	%tmp2 = call i32 @TestNone( i32 7 )		; <i32> [#uses=1]
29	store i32 1, i32* @g
30	%tmp3 = call i32 @TestConst( i32 5 ) readnone 		; <i32> [#uses=1]
31	%tmp4 = call i32 @TestConst( i32 5 ) readnone 		; <i32> [#uses=1]
32	%tmp5 = call i32 @TestPure( i32 6 ) readonly 		; <i32> [#uses=1]
33	%tmp6 = call i32 @TestPure( i32 6 ) readonly 		; <i32> [#uses=1]
34	%tmp7 = call i32 @TestNone( i32 7 )		; <i32> [#uses=1]
35	%tmp8 = call i32 @TestNone( i32 7 )		; <i32> [#uses=1]
36	%sum0 = add i32 %tmp0, %tmp1		; <i32> [#uses=1]
37	%sum1 = add i32 %sum0, %tmp2		; <i32> [#uses=1]
38	%sum2 = add i32 %sum1, %tmp3		; <i32> [#uses=1]
39	%sum3 = add i32 %sum2, %tmp4		; <i32> [#uses=1]
40	%sum4 = add i32 %sum3, %tmp5		; <i32> [#uses=1]
41	%sum5 = add i32 %sum4, %tmp6		; <i32> [#uses=1]
42	%sum6 = add i32 %sum5, %tmp7		; <i32> [#uses=1]
43	%sum7 = add i32 %sum6, %tmp8		; <i32> [#uses=1]
44	ret i32 %sum7
45}
46
47declare i32 @TestConst(i32) readnone
48
49declare i32 @TestPure(i32) readonly
50
51declare i32 @TestNone(i32)
52
53; CHECK: attributes [[READNONE]] = { readnone }
54; CHECK: attributes [[READONLY]] = { readonly }
55