File: f32tof16.ll

package info (click to toggle)
intel-graphics-compiler 1.0.17791.18-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 102,312 kB
  • sloc: cpp: 935,343; lisp: 286,143; ansic: 16,196; python: 3,279; yacc: 2,487; lex: 1,642; pascal: 300; sh: 174; makefile: 27
file content (77 lines) | stat: -rw-r--r-- 3,151 bytes parent folder | download | duplicates (2)
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
;=========================== begin_copyright_notice ============================
;
; Copyright (C) 2024 Intel Corporation
;
; SPDX-License-Identifier: MIT
;
;============================ end_copyright_notice =============================
;
; RUN: igc_opt -igc-custom-safe-opt -dce -S < %s | FileCheck %s
; ------------------------------------------------
; CustomSafeOptPass: GenISA.f32tof16.rtz
; ------------------------------------------------

; Test checks that 2 GenISA.f32tof16.rtz intrinsics moved to low and high part of i32
; are substitued with GenISA.ftof.rtz.f16.f32 with insertelements

define i32 @test_f32tof16_shl(float %src1, float %src2) {
; CHECK-LABEL: define i32 @test_f32tof16_shl(
; CHECK-SAME: float [[SRC1:%.*]], float [[SRC2:%.*]]) {
; CHECK:    [[TMP6:%.*]] = call half @llvm.genx.GenISA.ftof.rtz.f16.f32(float [[SRC2]])
; CHECK:    [[TMP7:%.*]] = call half @llvm.genx.GenISA.ftof.rtz.f16.f32(float [[SRC1]])
; CHECK:    [[TMP8:%.*]] = insertelement <2 x half> undef, half [[TMP6]], i32 0
; CHECK:    [[TMP9:%.*]] = insertelement <2 x half> [[TMP8]], half [[TMP7]], i32 1
; CHECK:    [[TMP10:%.*]] = bitcast <2 x half> [[TMP9]] to i32
; CHECK:    ret i32 [[TMP10]]
;
  %1 = call float @llvm.genx.GenISA.f32tof16.rtz(float %src1)
  %2 = call float @llvm.genx.GenISA.f32tof16.rtz(float %src2)
  %3 = bitcast float %1 to i32
  %4 = bitcast float %2 to i32
  %5 = shl i32 %3, 16
  %6 = add i32 %5, %4
  ret i32 %6
}

define i32 @test_f32tof16_mul(float %src1, float %src2) {
; CHECK-LABEL: define i32 @test_f32tof16_mul(
; CHECK-SAME: float [[SRC1:%.*]], float [[SRC2:%.*]]) {
; CHECK:    [[TMP6:%.*]] = call half @llvm.genx.GenISA.ftof.rtz.f16.f32(float [[SRC2]])
; CHECK:    [[TMP7:%.*]] = call half @llvm.genx.GenISA.ftof.rtz.f16.f32(float [[SRC1]])
; CHECK:    [[TMP8:%.*]] = insertelement <2 x half> undef, half [[TMP6]], i32 0
; CHECK:    [[TMP9:%.*]] = insertelement <2 x half> [[TMP8]], half [[TMP7]], i32 1
; CHECK:    [[TMP10:%.*]] = bitcast <2 x half> [[TMP9]] to i32
; CHECK:    ret i32 [[TMP10]]
;
  %1 = call float @llvm.genx.GenISA.f32tof16.rtz(float %src1)
  %2 = call float @llvm.genx.GenISA.f32tof16.rtz(float %src2)
  %3 = bitcast float %1 to i32
  %4 = bitcast float %2 to i32
  %5 = mul i32 %3, 65536
  %6 = add i32 %5, %4
  ret i32 %6
}

; If value was produced by fpext from half
; then trasformation discards conversion call

define i32 @test_f32tof16_half(half %src1, half %src2) {
; CHECK-LABEL: define i32 @test_f32tof16_half(
; CHECK-SAME: half [[SRC1:%.*]], half [[SRC2:%.*]]) {
; CHECK:    [[TMP8:%.*]] = insertelement <2 x half> undef, half [[SRC2]], i32 0
; CHECK:    [[TMP9:%.*]] = insertelement <2 x half> [[TMP8]], half [[SRC1]], i32 1
; CHECK:    [[TMP10:%.*]] = bitcast <2 x half> [[TMP9]] to i32
; CHECK:    ret i32 [[TMP10]]
;
  %1 = fpext half %src1 to float
  %2 = fpext half %src2 to float
  %3 = call float @llvm.genx.GenISA.f32tof16.rtz(float %1)
  %4 = call float @llvm.genx.GenISA.f32tof16.rtz(float %2)
  %5 = bitcast float %3 to i32
  %6 = bitcast float %4 to i32
  %7 = mul i32 %5, 65536
  %8 = add i32 %7, %6
  ret i32 %8
}

declare float @llvm.genx.GenISA.f32tof16.rtz(float)