File: basic-typed-pointers.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 (61 lines) | stat: -rw-r--r-- 1,906 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
;=========================== begin_copyright_notice ============================
;
; Copyright (C) 2023 Intel Corporation
;
; SPDX-License-Identifier: MIT
;
;============================ end_copyright_notice =============================
;
; RUN: igc_opt --cap-loop-iterations-pass -S < %s | FileCheck %s
; ------------------------------------------------
; CapLoopIterations
; ------------------------------------------------

; Test checks that force loop exit on count of MAX_UINT is added.

declare void @use_int(i32)

define void @test_func(i32 %a, i32 addrspace(1)* %ptr) {
; CHECK:  entry:
; CHECK:    [[ID:%.*]] = add i32 [[A:%.*]], 1
; CHECK:    br label %[[LOOP:.*]]
; CHECK:  [[LOOP]]:
; CHECK:    [[INDVAR:%.*]] = phi i32 [ [[ID]], [[ENTRY:%.*]] ], [ [[NEXTINDVAR:%.*]], %[[LOOP]] ]
;
; Add new iteration counter
;
; CHECK:    [[COUNTERPHI:%.*]] = phi i32 [ 0, [[ENTRY]] ], [ [[COUNTER:%.*]], %[[LOOP]] ]
; CHECK:    [[COUNTER]] = add i32 [[COUNTERPHI]], 1
;
; Limit possible iterations to MAX_UINT
;
; CHECK:    [[FORCELOOPEXIT:%.*]] = icmp eq i32 [[COUNTER]], -1
;
; CHECK:    [[CMP:%.*]] = icmp sle i32 [[INDVAR]], 0
; CHECK:    [[SEL:%.*]] = select i1 [[CMP]], i32 10, i32 20
; CHECK:    [[NEXTINDVAR]] = sub i32 [[SEL]], [[INDVAR]]
; CHECK:    [[COND:%.*]] = icmp ult i32 [[NEXTINDVAR]], [[ID]]
;
; Merge with original condition
;
; CHECK:    [[TMP0:%.*]] = xor i1 [[FORCELOOPEXIT]], true
; CHECK:    [[TMP1:%.*]] = and i1 [[TMP0]], [[COND]]
; CHECK:    br i1 [[TMP1]], label %[[LOOP]], label %[[LOOP_END:.*]]
; CHECK:  [[LOOP_END]]:
; CHECK:    ret void
;
entry:
  %id = add i32 %a, 1
  br label %loop

loop:
  %indvar = phi i32 [ %id, %entry ], [ %nextindvar, %loop ]
  %cmp = icmp sle i32 %indvar, 0
  %sel = select i1 %cmp, i32 10, i32 20
  %nextindvar = sub i32 %sel, %indvar
  %cond = icmp ult i32 %nextindvar, %id
  br i1 %cond, label %loop, label %loop_end

loop_end:
  ret void
}