File: unary.ll

package info (click to toggle)
intel-graphics-compiler2 2.16.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 106,644 kB
  • sloc: cpp: 805,640; lisp: 287,672; ansic: 16,414; python: 3,952; yacc: 2,588; lex: 1,666; pascal: 313; sh: 186; makefile: 35
file content (118 lines) | stat: -rw-r--r-- 3,929 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
;=========================== begin_copyright_notice ============================
;
; Copyright (C) 2024 Intel Corporation
;
; SPDX-License-Identifier: MIT
;
;============================ end_copyright_notice =============================
; due to bfloat ty
; REQUIRES: llvm-14-plus
;
; RUN: igc_opt -igc-legalization -S < %s | FileCheck %s
; ------------------------------------------------
; Legalization: Unary instructions
; ------------------------------------------------
;
; Pass checks that unary operations have intermediate step(conversion to float)
; when operating on bfloat

define i32 @test_convert_to_int(bfloat %src1) {
; CHECK-LABEL: define i32 @test_convert_to_int(
; CHECK-SAME: bfloat [[SRC1:%.*]]) {
; CHECK:    [[TMP1:%.*]] = fpext bfloat [[SRC1]] to float
; CHECK:    [[TMP2:%.*]] = fptosi float [[TMP1]] to i32
; CHECK:    ret i32 [[TMP2]]
;
  %1 = fptosi bfloat %src1 to i32
  ret i32 %1
}

define i32 @test_convert_to_uint(bfloat %src1) {
; CHECK-LABEL: define i32 @test_convert_to_uint(
; CHECK-SAME: bfloat [[SRC1:%.*]]) {
; CHECK:    [[TMP1:%.*]] = fpext bfloat [[SRC1]] to float
; CHECK:    [[TMP2:%.*]] = fptoui float [[TMP1]] to i32
; CHECK:    ret i32 [[TMP2]]
;
  %1 = fptoui bfloat %src1 to i32
  ret i32 %1
}

define bfloat @test_convert_from_int(i32 %src1) {
; CHECK-LABEL: define bfloat @test_convert_from_int(
; CHECK-SAME: i32 [[SRC1:%.*]]) {
; CHECK:    [[TMP1:%.*]] = sitofp i32 [[SRC1]] to float
; CHECK:    [[TMP2:%.*]] = fptrunc float [[TMP1]] to bfloat
; CHECK:    ret bfloat [[TMP2]]
;
  %1 = sitofp i32 %src1 to bfloat
  ret bfloat %1
}

define bfloat @test_convert_from_uint(i32 %src1) {
; CHECK-LABEL: define bfloat @test_convert_from_uint(
; CHECK-SAME: i32 [[SRC1:%.*]]) {
; CHECK:    [[TMP1:%.*]] = uitofp i32 [[SRC1]] to float
; CHECK:    [[TMP2:%.*]] = fptrunc float [[TMP1]] to bfloat
; CHECK:    ret bfloat [[TMP2]]
;
  %1 = uitofp i32 %src1 to bfloat
  ret bfloat %1
}

define double @test_fpext_from_bf_to_double(bfloat %src1) {
; CHECK-LABEL: define double @test_fpext_from_bf_to_double(
; CHECK-SAME: bfloat [[SRC1:%.*]]) {
; CHECK:    [[TMP1:%.*]] = fpext bfloat [[SRC1]] to float
; CHECK:    [[TMP2:%.*]] = fpext float [[TMP1]] to double
; CHECK:    ret double [[TMP2]]
;
  %1 = fpext bfloat %src1 to double
  ret double %1
}

define bfloat @test_fptrunc_from_double_to_bf(double %src1) {
; CHECK-LABEL: define bfloat @test_fptrunc_from_double_to_bf(
; CHECK-SAME: double [[SRC1:%.*]]) {
; CHECK:    [[TMP1:%.*]] = fptrunc double [[SRC1]] to float
; CHECK:    [[TMP2:%.*]] = fptrunc float [[TMP1]] to bfloat
; CHECK:    ret bfloat [[TMP2]]
;
  %1 = fptrunc double %src1 to bfloat
  ret bfloat %1
}

define bfloat @test_fneg(bfloat %src1) {
; CHECK-LABEL: define bfloat @test_fneg(
; CHECK-SAME: bfloat [[SRC1:%.*]]) {
; CHECK:    [[TMP1:%.*]] = fpext bfloat [[SRC1]] to float
; CHECK:    [[TMP2:%.*]] = fneg float [[TMP1]]
; CHECK:    [[TMP3:%.*]] = fptrunc float [[TMP2]] to bfloat
; CHECK:    ret bfloat [[TMP3]]
;
  %1 = fneg bfloat %src1
  ret bfloat %1
}

define <4 x bfloat> @test_vector(<4 x bfloat> %src1) {
; CHECK-LABEL: define <4 x bfloat> @test_vector(
; CHECK-SAME: <4 x bfloat> [[SRC1:%.*]]) {
; CHECK:    [[TMP1:%.*]] = fpext <4 x bfloat> [[SRC1]] to <4 x float>
; CHECK:    [[TMP2:%.*]] = fneg <4 x float> [[TMP1]]
; CHECK:    [[TMP3:%.*]] = fptrunc <4 x float> [[TMP2]] to <4 x bfloat>
; CHECK:    ret <4 x bfloat> [[TMP3]]
;
  %1 = fneg <4 x bfloat> %src1
  ret <4 x bfloat> %1
}

!igc.functions = !{!0, !1, !2, !3, !4, !5, !6, !7}
!0 = !{i32 (bfloat)* @test_convert_to_int, !8}
!1 = !{i32 (bfloat)* @test_convert_to_uint, !8}
!2 = !{bfloat (i32)* @test_convert_from_int, !8}
!3 = !{bfloat (i32)* @test_convert_from_uint, !8}
!4 = !{double (bfloat)* @test_fpext_from_bf_to_double, !8}
!5 = !{bfloat (double)* @test_fptrunc_from_double_to_bf, !8}
!6 = !{bfloat (bfloat)* @test_fneg, !8}
!7 = !{<4 x bfloat> (<4 x bfloat>)* @test_vector, !8}
!8 = !{}