File: basic.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 (128 lines) | stat: -rw-r--r-- 3,352 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
119
120
121
122
123
124
125
126
127
128
;=========================== begin_copyright_notice ============================
;
; Copyright (C) 2025 Intel Corporation
;
; SPDX-License-Identifier: MIT
;
;============================ end_copyright_notice =============================

; RUN: igc_opt --enable-debugify --igc-hoist-conv-op-to-dom --platformbmg -S < %s 2>&1 | FileCheck %s

; This test checks that the HoistConvOpToDom pass hoists identical conversion operations to their common dominator
; and removes redundant conversions and PHIs.

; Debug-info related check
; 5 warnings are related to deleted instructions
; CHECK-COUNT-5: WARNING
; CHECK: CheckModuleDebugify: PASS

; CHECK-LABEL: @test_hoist_simple
; CHECK: entry:
; CHECK:   %conv1 = fptosi float %a to i32
; CHECK:   br i1 %cond, label %then, label %else
; CHECK: then:
; CHECK:   %use1 = add i32 %conv1, 1
; CHECK:   br label %merge
; CHECK: else:
; CHECK:   %use2 = add i32 %conv1, 1
; CHECK:   br label %merge
; CHECK: merge:
; CHECK:   ret i32 %conv1

define i32 @test_hoist_simple(float %a, i1 %cond) {
entry:
  br i1 %cond, label %then, label %else
then:
  %conv1 = fptosi float %a to i32
  %use1 = add i32 %conv1, 1
  br label %merge
else:
  %conv2 = fptosi float %a to i32
  %use2 = add i32 %conv2, 1
  br label %merge
merge:
  %phi = phi i32 [%conv1, %then], [%conv2, %else]
  ret i32 %phi
}

; CHECK-LABEL: @test_no_hoist_different_ops
; CHECK: %conv1 = fptosi float %a to i32
; CHECK: %conv2 = fptoui float %a to i32
; CHECK: %phi = phi i32
; CHECK: ret i32 %phi

define i32 @test_no_hoist_different_ops(float %a, i1 %cond) {
entry:
  br i1 %cond, label %then, label %else
then:
  %conv1 = fptosi float %a to i32
  %use1 = add i32 %conv1, 1
  br label %merge
else:
  %conv2 = fptoui float %a to i32
  %use2 = add i32 %conv2, 1
  br label %merge
merge:
  %phi = phi i32 [%conv1, %then], [%conv2, %else]
  ret i32 %phi
}

; CHECK-LABEL: @test_no_hoist_different_src
; CHECK: %conv1 = fptosi float %a to i32
; CHECK: %conv2 = fptosi float %b to i32
; CHECK: %phi = phi i32
; CHECK: ret i32 %phi

define i32 @test_no_hoist_different_src(float %a, float %b, i1 %cond) {
entry:
  br i1 %cond, label %then, label %else
then:
  %conv1 = fptosi float %a to i32
  br label %merge
else:
  %conv2 = fptosi float %b to i32
  br label %merge
merge:
  %phi = phi i32 [%conv1, %then], [%conv2, %else]
  ret i32 %phi
}

; CHECK-LABEL: @test_hoist_multiple
; CHECK: entry:
; CHECK:   %conv1 = fptosi float %a to i32
; CHECK:   br i1 %cond1, label %then, label %else
; CHECK: then:
; CHECK:   br i1 %cond2, label %then2, label %else2
; CHECK: then2:
; CHECK:   %use1 = add i32 %conv1, 1
; CHECK:   br label %merge
; CHECK: else2:
; CHECK:   %use2 = add i32 %conv1, 1
; CHECK:   br label %merge
; CHECK: else:
; CHECK:   %use3 = add i32 %conv1, 1
; CHECK:   br label %merge
; CHECK: merge:
; CHECK:   ret i32 %conv1

define i32 @test_hoist_multiple(float %a, i1 %cond1, i1 %cond2) {
entry:
  br i1 %cond1, label %then, label %else
then:
  br i1 %cond2, label %then2, label %else2
then2:
  %conv1 = fptosi float %a to i32
  %use1 = add i32 %conv1, 1
  br label %merge
else2:
  %conv2 = fptosi float %a to i32
  %use2 = add i32 %conv2, 1
  br label %merge
else:
  %conv3 = fptosi float %a to i32
  %use3 = add i32 %conv3, 1
  br label %merge
merge:
  %phi = phi i32 [%conv1, %then2], [%conv2, %else2], [%conv3, %else]
  ret i32 %phi
}