1946b3b2eSMichael Kuperstein; RUN:  llvm-dis < %s.bc| FileCheck %s
2946b3b2eSMichael Kuperstein
3946b3b2eSMichael Kuperstein; constantsTest.3.2.ll.bc was generated by passing this file to llvm-as-3.2.
4946b3b2eSMichael Kuperstein; The test checks that LLVM does not misread binary float instructions of
5946b3b2eSMichael Kuperstein; older bitcode files.
6946b3b2eSMichael Kuperstein
7946b3b2eSMichael Kuperstein;global variable address
8946b3b2eSMichael Kuperstein; CHECK: @X = global i32 0
9946b3b2eSMichael Kuperstein@X = global i32 0
10946b3b2eSMichael Kuperstein; CHECK: @Y = global i32 1
11946b3b2eSMichael Kuperstein@Y = global i32 1
12946b3b2eSMichael Kuperstein; CHECK: @Z = global [2 x i32*] [i32* @X, i32* @Y]
13946b3b2eSMichael Kuperstein@Z = global [2 x i32*] [i32* @X, i32* @Y]
14946b3b2eSMichael Kuperstein
15946b3b2eSMichael Kuperstein
16946b3b2eSMichael Kupersteindefine void @SimpleConstants(i32 %x) {
17946b3b2eSMichael Kupersteinentry:
18946b3b2eSMichael Kuperstein; null
19946b3b2eSMichael Kuperstein; CHECK: store i32 %x, i32* null
20946b3b2eSMichael Kuperstein  store i32 %x, i32* null
21946b3b2eSMichael Kuperstein
22946b3b2eSMichael Kuperstein; boolean
23946b3b2eSMichael Kuperstein; CHECK-NEXT: %res1 = fcmp true float 1.000000e+00, 1.000000e+00
24946b3b2eSMichael Kuperstein  %res1 = fcmp true float 1.0, 1.0
25946b3b2eSMichael Kuperstein; CHECK-NEXT: %res2 = fcmp false float 1.000000e+00, 1.000000e+00
26946b3b2eSMichael Kuperstein  %res2 = fcmp false float 1.0, 1.0
27946b3b2eSMichael Kuperstein
28946b3b2eSMichael Kuperstein;integer
29946b3b2eSMichael Kuperstein; CHECK-NEXT: %res3 = add i32 0, 0
30946b3b2eSMichael Kuperstein  %res3 = add i32 0, 0
31946b3b2eSMichael Kuperstein
32946b3b2eSMichael Kuperstein;float
33946b3b2eSMichael Kuperstein; CHECK-NEXT: %res4 = fadd float 0.000000e+00, 0.000000e+00
34946b3b2eSMichael Kuperstein  %res4 = fadd float 0.0, 0.0
35946b3b2eSMichael Kuperstein
36946b3b2eSMichael Kuperstein  ret void
37946b3b2eSMichael Kuperstein}
38946b3b2eSMichael Kuperstein
39946b3b2eSMichael Kupersteindefine void @ComplexConstants(<2 x i32> %x){
40946b3b2eSMichael Kupersteinentry:
41946b3b2eSMichael Kuperstein;constant structure
42946b3b2eSMichael Kuperstein; CHECK: %res1 = extractvalue { i32, float } { i32 1, float 2.000000e+00 }, 0
43946b3b2eSMichael Kuperstein  %res1 = extractvalue {i32, float} {i32 1, float 2.0}, 0
44946b3b2eSMichael Kuperstein
45946b3b2eSMichael Kuperstein;const array
46946b3b2eSMichael Kuperstein; CHECK-NEXT: %res2 = extractvalue [2 x i32] [i32 1, i32 2], 0
47946b3b2eSMichael Kuperstein  %res2 = extractvalue [2 x i32] [i32 1, i32 2], 0
48946b3b2eSMichael Kuperstein
49946b3b2eSMichael Kuperstein;const vector
50946b3b2eSMichael Kuperstein; CHECK-NEXT: %res3 = add <2 x i32> <i32 1, i32 1>, <i32 1, i32 1>
51946b3b2eSMichael Kuperstein  %res3 = add <2 x i32> <i32 1, i32 1>, <i32 1, i32 1>
52946b3b2eSMichael Kuperstein
53946b3b2eSMichael Kuperstein;zeroinitializer
54946b3b2eSMichael Kuperstein; CHECK-NEXT: %res4 = add <2 x i32> %x, zeroinitializer
55946b3b2eSMichael Kuperstein  %res4 = add <2 x i32> %x, zeroinitializer
56946b3b2eSMichael Kuperstein
57946b3b2eSMichael Kuperstein  ret void
58946b3b2eSMichael Kuperstein}
59946b3b2eSMichael Kuperstein
60946b3b2eSMichael Kupersteindefine void @OtherConstants(i32 %x, i8* %Addr){
61946b3b2eSMichael Kupersteinentry:
62946b3b2eSMichael Kuperstein  ;undef
63946b3b2eSMichael Kuperstein  ; CHECK: %res1 = add i32 %x, undef
64946b3b2eSMichael Kuperstein  %res1 = add i32 %x, undef
65946b3b2eSMichael Kuperstein
66946b3b2eSMichael Kuperstein  ;poison
67946b3b2eSMichael Kuperstein  ; CHECK-NEXT: %poison = sub nuw i32 0, 1
68946b3b2eSMichael Kuperstein  %poison = sub nuw i32 0, 1
69946b3b2eSMichael Kuperstein
70946b3b2eSMichael Kuperstein  ;address of basic block
71946b3b2eSMichael Kuperstein  ; CHECK-NEXT: %res2 = icmp eq i8* blockaddress(@OtherConstants, %Next), null
72946b3b2eSMichael Kuperstein  %res2 = icmp eq i8* blockaddress(@OtherConstants, %Next), null
73946b3b2eSMichael Kuperstein  br label %Next
74946b3b2eSMichael Kuperstein  Next:
75946b3b2eSMichael Kuperstein  ret void
76946b3b2eSMichael Kuperstein}
77946b3b2eSMichael Kuperstein
78946b3b2eSMichael Kupersteindefine void @OtherConstants2(){
79946b3b2eSMichael Kupersteinentry:
80946b3b2eSMichael Kuperstein  ; CHECK: trunc i32 1 to i8
81946b3b2eSMichael Kuperstein  trunc i32 1 to i8
82946b3b2eSMichael Kuperstein  ; CHECK-NEXT: zext i8 1 to i32
83946b3b2eSMichael Kuperstein  zext i8 1 to i32
84946b3b2eSMichael Kuperstein  ; CHECK-NEXT: sext i8 1 to i32
85946b3b2eSMichael Kuperstein  sext i8 1 to i32
86946b3b2eSMichael Kuperstein  ; CHECK-NEXT: fptrunc double 1.000000e+00 to float
87946b3b2eSMichael Kuperstein  fptrunc double 1.0 to float
88946b3b2eSMichael Kuperstein  ; CHECK-NEXT: fpext float 1.000000e+00 to double
89946b3b2eSMichael Kuperstein  fpext float 1.0 to double
90946b3b2eSMichael Kuperstein  ; CHECK-NEXT: fptosi float 1.000000e+00 to i32
91946b3b2eSMichael Kuperstein  fptosi float 1.0 to i32
92946b3b2eSMichael Kuperstein  ; CHECK-NEXT: uitofp i32 1 to float
93946b3b2eSMichael Kuperstein  uitofp i32 1 to float
94946b3b2eSMichael Kuperstein  ; CHECK-NEXT: sitofp i32 -1 to float
95946b3b2eSMichael Kuperstein  sitofp i32 -1 to float
96946b3b2eSMichael Kuperstein  ; CHECK-NEXT: ptrtoint i32* @X to i32
97946b3b2eSMichael Kuperstein  ptrtoint i32* @X to i32
98946b3b2eSMichael Kuperstein  ; CHECK-NEXT: inttoptr i8 1 to i8*
99946b3b2eSMichael Kuperstein  inttoptr i8 1 to i8*
100946b3b2eSMichael Kuperstein  ; CHECK-NEXT: bitcast i32 1 to <2 x i16>
101946b3b2eSMichael Kuperstein  bitcast i32 1 to <2 x i16>
102*79e6c749SDavid Blaikie  ; CHECK-NEXT: getelementptr i32, i32* @X, i32 0
103*79e6c749SDavid Blaikie  getelementptr i32, i32* @X, i32 0
104*79e6c749SDavid Blaikie  ; CHECK-NEXT: getelementptr inbounds i32, i32* @X, i32 0
105*79e6c749SDavid Blaikie  getelementptr inbounds i32, i32* @X, i32 0
106946b3b2eSMichael Kuperstein  ; CHECK: select i1 true, i32 1, i32 0
107946b3b2eSMichael Kuperstein  select i1 true ,i32 1, i32 0
108946b3b2eSMichael Kuperstein  ; CHECK-NEXT: icmp eq i32 1, 0
109946b3b2eSMichael Kuperstein  icmp eq i32 1, 0
110946b3b2eSMichael Kuperstein  ; CHECK-NEXT: fcmp oeq float 1.000000e+00, 0.000000e+00
111946b3b2eSMichael Kuperstein  fcmp oeq float 1.0, 0.0
112946b3b2eSMichael Kuperstein  ; CHECK-NEXT: extractelement <2 x i32> <i32 1, i32 1>, i32 1
113946b3b2eSMichael Kuperstein  extractelement <2 x i32> <i32 1, i32 1>, i32 1
114946b3b2eSMichael Kuperstein  ; CHECK-NEXT: insertelement <2 x i32> <i32 1, i32 1>, i32 0, i32 1
115946b3b2eSMichael Kuperstein  insertelement <2 x i32> <i32 1, i32 1>, i32 0, i32 1
116946b3b2eSMichael Kuperstein  ; CHECK-NEXT: shufflevector <2 x i32> <i32 1, i32 1>, <2 x i32> zeroinitializer, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
117946b3b2eSMichael Kuperstein  shufflevector <2 x i32> <i32 1, i32 1>, <2 x i32> zeroinitializer, <4 x i32> <i32 0, i32 2, i32 1, i32 3>
118946b3b2eSMichael Kuperstein  ; CHECK-NEXT: extractvalue { i32, float } { i32 1, float 2.000000e+00 }, 0
119946b3b2eSMichael Kuperstein  extractvalue { i32, float } { i32 1, float 2.0 }, 0
120946b3b2eSMichael Kuperstein  ; CHECK-NEXT: insertvalue { i32, float } { i32 1, float 2.000000e+00 }, i32 0, 0
121946b3b2eSMichael Kuperstein  insertvalue { i32, float } { i32 1, float 2.0 }, i32 0, 0
122946b3b2eSMichael Kuperstein
123946b3b2eSMichael Kuperstein  ret void
124946b3b2eSMichael Kuperstein}