File: constant-folding.ll

package info (click to toggle)
intel-graphics-compiler2 2.22.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 107,676 kB
  • sloc: cpp: 809,645; lisp: 288,070; ansic: 16,397; python: 4,010; yacc: 2,588; lex: 1,666; pascal: 314; sh: 186; makefile: 38
file content (62 lines) | stat: -rw-r--r-- 2,175 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
;=========================== begin_copyright_notice ============================
;
; Copyright (C) 2025 Intel Corporation
;
; SPDX-License-Identifier: MIT
;
;============================ end_copyright_notice =============================

; REQUIRES: regkeys, llvm-16-plus
;
; RUN: igc_opt --regkey "EnableOpaquePointersBackend=1" --igc-predefined-constant-resolve 2>&1 -S < %s | FileCheck %s
; ------------------------------------------------
; PredefinedConstantResolving
; ------------------------------------------------

; This test checks whether the PredefinedConstantResolving pass correctly folds constants with matching or not matching types

@global_int = internal addrspace(1) constant i32 1337, align 4
@global_i8s_arr = internal addrspace(1) constant [8 x i8] [i8 1, i8 2, i8 3, i8 4, i8 5, i8 6, i8 7, i8 8], align 8
@global_i64s_arr = internal addrspace(1) constant [3 x i64] [i64 16, i64 32, i64 64], align 8

; CHECK-LABEL: @test_i64_from_i64_array(
; CHECK: store i64 16,
; CHECK-NOT: load
define spir_kernel void @test_i64_from_i64_array(ptr addrspace(1) %out) {
entry:
  %local = load i64, ptr addrspace(1) @global_i64s_arr, align 8
  store i64 %local, ptr addrspace(1) %out, align 8
  ret void
}

; CHECK-LABEL: @test_direct_i32(
; CHECK: store i32 1337,
; CHECK-NOT: load
define spir_kernel void @test_direct_i32(ptr addrspace(1) %out) {
entry:
  %local = load i32, ptr addrspace(1) @global_int
  store i32 %local, ptr addrspace(1) %out, align 4
  ret void
}

; CHECK-LABEL: @test_i64_from_i8_array(
; CHECK: store i64 578437695752307201,
; CHECK-NOT: load
define spir_kernel void @test_i64_from_i8_array(ptr addrspace(1) %out) {
entry:
  %local = load i64, ptr addrspace(1) @global_i8s_arr, align 8
  store i64 %local, ptr addrspace(1) %out, align 8
  ret void
}

; CHECK-LABEL: @test_i8_from_i64_array(
; CHECK: store i8 16,
; CHECK-NOT: load
define spir_kernel void @test_i8_from_i64_array(ptr addrspace(1) %out) {
entry:
  %local = load i8, ptr addrspace(1) @global_i64s_arr, align 1
  store i8 %local, ptr addrspace(1) %out, align 1
  ret void
}

attributes #0 = { convergent noinline nounwind optnone "less-precise-fpmad"="true" "visaStackCall" }