File: addrspacecast-null-typed-pointers.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 (69 lines) | stat: -rw-r--r-- 2,304 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
;=========================== begin_copyright_notice ============================
;
; Copyright (C) 2024 Intel Corporation
;
; SPDX-License-Identifier: MIT
;
;============================ end_copyright_notice =============================
;
; RUN: igc_opt --typed-pointers -igc-legalization -S -dce < %s | FileCheck %s
; ------------------------------------------------
; Legalization: addrspacecast
; ------------------------------------------------

; Checks legalization of addrspacecast from local addrspace
; 1) for non-generic - nullify it (except for private AS)
; 2) for cast null to generic addrspace - nullify

define i32 @test_addrcast_p0(i32 addrspace(3)* %p1) {
; CHECK-LABEL: define i32 @test_addrcast_p0(
; CHECK-SAME: i32 addrspace(3)* [[P1:%.*]]) {
; CHECK:    [[TMP1:%.*]] = addrspacecast i32 addrspace(3)* [[P1]] to i32*
; CHECK:    [[TMP2:%.*]] = load i32, i32* [[TMP1]]
; CHECK:    ret i32 [[TMP2]]
;
  %1 = addrspacecast i32 addrspace(3)* %p1 to i32 addrspace(0)*
  %2 = load i32, i32 addrspace(0)* %1
  ret i32 %2
}

define i32 @test_addrcast_p1(i32 addrspace(3)* %p1) {
; CHECK-LABEL: define i32 @test_addrcast_p1(
; CHECK-SAME: i32 addrspace(3)* [[P1:%.*]]) {
; CHECK:    [[TMP1:%.*]] = load i32, i32 addrspace(1)* null
; CHECK:    ret i32 [[TMP1]]
;
  %1 = addrspacecast i32 addrspace(3)* %p1 to i32 addrspace(1)*
  %2 = load i32, i32 addrspace(1)* %1
  ret i32 %2
}

define i32 @test_addrcast_p2(i32 addrspace(3)* %p1) {
; CHECK-LABEL: define i32 @test_addrcast_p2(
; CHECK-SAME: i32 addrspace(3)* [[P1:%.*]]) {
; CHECK:    [[TMP1:%.*]] = load i32, i32 addrspace(2)* null
; CHECK:    ret i32 [[TMP1]]
;
  %1 = addrspacecast i32 addrspace(3)* %p1 to i32 addrspace(2)*
  %2 = load i32, i32 addrspace(2)* %1
  ret i32 %2
}

define i32 @test_addrcast_null_p4() {
; CHECK-LABEL: define i32 @test_addrcast_null_p4() {
; CHECK:    [[TMP1:%.*]] = load i32, i32 addrspace(4)* null
; CHECK:    ret i32 [[TMP1]]
;
  %1 = addrspacecast i32 addrspace(3)* null to i32 addrspace(4)*
  %2 = load i32, i32 addrspace(4)* %1
  ret i32 %2
}

!igc.functions = !{!0,!1,!2,!3}

!0 = !{i32 (i32 addrspace(3)*)* @test_addrcast_p0, !10}
!1 = !{i32 (i32 addrspace(3)*)* @test_addrcast_p1, !10}
!2 = !{i32 (i32 addrspace(3)*)* @test_addrcast_p2, !10}
!3 = !{i32 ()* @test_addrcast_null_p4, !10}
!10 = !{}