1 ; RUN: llvm-reduce --abort-on-invalid-reduction --delta-passes=opcodes --test FileCheck --test-arg %s --test-arg --input-file %s -o %t
2 ; RUN: FileCheck -check-prefixes=CHECK,RESULT %s < %t
4 ; CHECK-LABEL: @fdiv_fast(
5 ; RESULT-NEXT: %op = fmul fast float %a, %b, !dbg !7, !fpmath !13
6 ; RESULT-NEXT: ret float %op
7 define float @fdiv_fast(float %a, float %b) {
8 %op = fdiv fast float %a, %b, !dbg !7, !fpmath !13
12 ; CHECK-LABEL: @frem_nnan(
13 ; RESULT-NEXT: %op = fmul nnan float %a, %b, !dbg !7, !fpmath !13
14 ; RESULT-NEXT: ret float %op
15 define float @frem_nnan(float %a, float %b) {
16 %op = frem nnan float %a, %b, !dbg !7, !fpmath !13
21 ; RESULT-NEXT: %op = mul i32 %a, %b, !dbg !7
22 ; RESULT-NEXT: ret i32 %op
23 define i32 @udiv(i32 %a, i32 %b) {
24 %op = udiv i32 %a, %b, !dbg !7
28 ; CHECK-LABEL: @udiv_vec(
29 ; RESULT-NEXT: %op = mul <2 x i32> %a, %b, !dbg !7
30 ; RESULT-NEXT: ret <2 x i32> %op
31 define <2 x i32> @udiv_vec(<2 x i32> %a, <2 x i32> %b) {
32 %op = udiv <2 x i32> %a, %b, !dbg !7
37 ; RESULT-NEXT: %op = mul i32 %a, %b{{$}}
38 ; RESULT-NEXT: ret i32 %op
39 define i32 @sdiv(i32 %a, i32 %b) {
44 ; CHECK-LABEL: @sdiv_exact(
45 ; RESULT-NEXT: %op = mul i32 %a, %b, !dbg !7
47 define i32 @sdiv_exact(i32 %a, i32 %b) {
48 %op = sdiv exact i32 %a, %b, !dbg !7
53 ; RESULT-NEXT: %op = mul i32 %a, %b, !dbg !7
55 define i32 @urem(i32 %a, i32 %b) {
56 %op = urem i32 %a, %b, !dbg !7
61 ; RESULT-NEXT: %op = mul i32 %a, %b, !dbg !7
63 define i32 @srem(i32 %a, i32 %b) {
64 %op = srem i32 %a, %b, !dbg !7
68 ; Make sure there's no crash if the IRBuilder decided to constant fold something
69 ; CHECK-LABEL: @add_constant_fold(
70 ; RESULT-NEXT: %op = add i32 0, 0, !dbg !7
72 define i32 @add_constant_fold() {
73 %op = add i32 0, 0, !dbg !7
78 ; RESULT-NEXT: %op = or i32 %a, %b, !dbg !7
80 define i32 @add(i32 %a, i32 %b) {
81 %op = add i32 %a, %b, !dbg !7
85 ; CHECK-LABEL: @add_nuw(
86 ; RESULT-NEXT: %op = or i32 %a, %b, !dbg !7
88 define i32 @add_nuw(i32 %a, i32 %b) {
89 %op = add nuw i32 %a, %b, !dbg !7
93 ; CHECK-LABEL: @add_nsw(
94 ; RESULT-NEXT: %op = or i32 %a, %b, !dbg !7
96 define i32 @add_nsw(i32 %a, i32 %b) {
97 %op = add nsw i32 %a, %b, !dbg !7
101 ; CHECK-LABEL: @sub_nuw_nsw(
102 ; RESULT-NEXT: %op = or i32 %a, %b, !dbg !7
104 define i32 @sub_nuw_nsw(i32 %a, i32 %b) {
105 %op = sub nuw nsw i32 %a, %b, !dbg !7
109 ; CHECK-LABEL: @workitem_id_y(
110 ; RESULT-NEXT: %id = call i32 @llvm.amdgcn.workitem.id.x(), !dbg !7
112 define i32 @workitem_id_y() {
113 %id = call i32 @llvm.amdgcn.workitem.id.y(), !dbg !7
117 ; CHECK-LABEL: @workitem_id_z(
118 ; RESULT-NEXT: %id = call i32 @llvm.amdgcn.workitem.id.x(), !dbg !7
120 define i32 @workitem_id_z() {
121 %id = call i32 @llvm.amdgcn.workitem.id.z(), !dbg !7
125 ; CHECK-LABEL: @workgroup_id_y(
126 ; RESULT-NEXT: %id = call i32 @llvm.amdgcn.workgroup.id.x(), !dbg !7
128 define i32 @workgroup_id_y() {
129 %id = call i32 @llvm.amdgcn.workgroup.id.y(), !dbg !7
133 ; CHECK-LABEL: @workgroup_id_z(
134 ; RESULT-NEXT: %id = call i32 @llvm.amdgcn.workgroup.id.x(), !dbg !7
136 define i32 @workgroup_id_z() {
137 %id = call i32 @llvm.amdgcn.workgroup.id.z(), !dbg !7
141 ; CHECK-LABEL: @minnum_nsz(
142 ; RESULT-NEXT: %op = fmul nsz float %a, %b, !dbg !7
144 define float @minnum_nsz(float %a, float %b) {
145 %op = call nsz float @llvm.minnum.f32(float %a, float %b), !dbg !7
149 ; CHECK-LABEL: @maxnum_nsz(
150 ; RESULT-NEXT: %op = fmul nsz float %a, %b, !dbg !7
152 define float @maxnum_nsz(float %a, float %b) {
153 %op = call nsz float @llvm.maxnum.f32(float %a, float %b), !dbg !7
157 ; CHECK-LABEL: @minimum_nsz(
158 ; RESULT-NEXT: %op = fmul nsz float %a, %b, !dbg !7
160 define float @minimum_nsz(float %a, float %b) {
161 %op = call nsz float @llvm.minimum.f32(float %a, float %b), !dbg !7
165 ; CHECK-LABEL: @maximum_nsz(
166 ; RESULT-NEXT: %op = fmul nsz float %a, %b, !dbg !7
168 define float @maximum_nsz(float %a, float %b) {
169 %op = call nsz float @llvm.maximum.f32(float %a, float %b), !dbg !7
173 ; CHECK-LABEL: @sqrt_ninf(
174 ; RESULT-NEXT: %op = fmul ninf float %a, 2.000000e+00, !dbg !7
176 define float @sqrt_ninf(float %a, float %b) {
177 %op = call ninf float @llvm.sqrt.f32(float %a), !dbg !7
181 ; CHECK-LABEL: @sqrt_vec(
182 ; RESULT-NEXT: %op = fmul <2 x float> %a, splat (float 2.000000e+00), !dbg !7
184 define <2 x float> @sqrt_vec(<2 x float> %a, <2 x float> %b) {
185 %op = call <2 x float> @llvm.sqrt.v2f32(<2 x float> %a), !dbg !7
189 ; CHECK-LABEL: @div_fixup(
190 ; RESULT-NEXT: %op = call float @llvm.fma.f32(float %a, float %b, float %c)
192 define float @div_fixup(float %a, float %b, float %c) {
193 %op = call float @llvm.amdgcn.div.fixup.f32(float %a, float %b, float %c)
197 ; CHECK-LABEL: @fma_legacy(
198 ; RESULT-NEXT: %op = call float @llvm.fma.f32(float %a, float %b, float %c)
200 define float @fma_legacy(float %a, float %b, float %c) {
201 %op = call float @llvm.amdgcn.fma.legacy(float %a, float %b, float %c)
205 ; CHECK-LABEL: @fmul_legacy(
206 ; RESULT-NEXT: %op = fmul float %a, %b
208 define float @fmul_legacy(float %a, float %b) {
209 %op = call float @llvm.amdgcn.fmul.legacy(float %a, float %b)
213 declare i32 @llvm.amdgcn.workitem.id.y()
214 declare i32 @llvm.amdgcn.workitem.id.z()
215 declare i32 @llvm.amdgcn.workgroup.id.y()
216 declare i32 @llvm.amdgcn.workgroup.id.z()
217 declare float @llvm.amdgcn.div.fixup.f32(float, float, float)
218 declare float @llvm.amdgcn.fma.legacy(float, float, float)
219 declare float @llvm.amdgcn.fmul.legacy(float, float)
221 declare float @llvm.sqrt.f32(float)
222 declare <2 x float> @llvm.sqrt.v2f32(<2 x float>)
223 declare float @llvm.maxnum.f32(float, float)
224 declare float @llvm.minnum.f32(float, float)
225 declare float @llvm.maximum.f32(float, float)
226 declare float @llvm.minimum.f32(float, float)
229 !opencl.ocl.version = !{!3, !3}
230 !llvm.module.flags = !{!4, !5}
233 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
234 !1 = !DIFile(filename: "arst.c", directory: "/some/random/directory")
237 !4 = !{i32 2, !"Dwarf Version", i32 2}
238 !5 = !{i32 2, !"Debug Info Version", i32 3}
240 !7 = !DILocation(line: 2, column: 6, scope: !8)
241 !8 = distinct !DISubprogram(name: "arst", scope: !1, file: !1, line: 1, type: !9, scopeLine: 1, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
242 !9 = !DISubroutineType(types: !10)
244 !11 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 64)
245 !12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
246 !13 = !{float 2.500000e+00}