File: mask.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 (87 lines) | stat: -rw-r--r-- 3,402 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
;=========================== begin_copyright_notice ============================
;
; Copyright (C) 2024 Intel Corporation
;
; SPDX-License-Identifier: MIT
;
;============================ end_copyright_notice =============================

; RUN: igc_opt --typed-pointers -debugify --igc-int-type-legalizer -check-debugify -S < %s 2>&1 | FileCheck %s --check-prefixes=CHECK

; Debug-info related check
; CHECK: CheckModuleDebugify: PASS

; Tests for masks done via combination of trunc/ext instructions.

target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v16:16:16-v24:32:32-v32:32:32-v48:64:64-v64:64:64-v96:128:128-v128:128:128-v192:256:256-v256:256:256-v512:512:512-v1024:1024:1024-n8:16:32"
target triple = "spir64-unknown-unknown"

define spir_kernel void @test_i32_to_i32(i32 %input, i32 addrspace(1)* %dst) {
entry:
; CHECK-LABEL: entry:
; CHECK:         %0 = and i32 %input, 7
; CHECK:         store i32 %0, i32 addrspace(1)* %dst
; CHECK:         ret void
  %0 = trunc i32 %input to i3
  %1 = zext i3 %0 to i32
  store i32 %1, i32 addrspace(1)* %dst
  ret void
}

define spir_kernel void @test_i32_to_i16(i32 %input, i16 addrspace(1)* %dst) {
entry:
; CHECK-LABEL: entry:
; CHECK:         %0 = and i32 %input, 7
; CHECK:         %1 = trunc i32 %0 to i16
; CHECK:         store i16 %1, i16 addrspace(1)* %dst
; CHECK:         ret void
  %0 = trunc i32 %input to i3
  %1 = zext i3 %0 to i16
  store i16 %1, i16 addrspace(1)* %dst
  ret void
}

define spir_kernel void @test_i64_to_i64(i64 %input, i64 addrspace(1)* %dst) {
entry:
; CHECK-LABEL:       entry:
; CHECK:               [[CASTVEC:%.*]] = bitcast i64 %input to <2 x i32>
; CHECK:               [[IDX0_BEFORE:%.*]] = extractelement <2 x i32> [[CASTVEC]], i64 0
; COM: Mask & 0xFFFFFFFF might be optimized out
; CHECK-PRE-LLVM-14:   [[VEC0:%.*]] = insertelement <2 x i32> undef, i32 [[IDX0_BEFORE]], i64 0
; CHECK:  [[IDX0_AFTER:%.*]] = and i32 [[IDX0_BEFORE]], -1
; CHECK:  [[VEC0:%.*]] = insertelement <2 x i32> undef, i32 [[IDX0_AFTER]], i64 0
; CHECK:               [[IDX1_BEFORE:%.*]] = extractelement <2 x i32> [[CASTVEC]], i64 1
; CHECK:               [[IDX1_AFTER:%.*]] = and i32 [[IDX1_BEFORE]], 31
; CHECK:               [[VEC1:%.*]] = insertelement <2 x i32> [[VEC0]], i32 [[IDX1_AFTER]], i64 1
; CHECK:               [[RESULT:%.*]] = bitcast <2 x i32> [[VEC1]] to i64
; CHECK:               store i64 [[RESULT]], i64 addrspace(1)* %dst
; CHECK:               ret void
  %0 = trunc i64 %input to i37
  %1 = zext i37 %0 to i64
  store i64 %1, i64 addrspace(1)* %dst
  ret void
}

define spir_kernel void @test_i64_to_i8(i64 %input, i8 addrspace(1)* %dst) {
entry:
; CHECK-LABEL: entry:
; CHECK:         %0 = bitcast i64 %input to <2 x i32>
; CHECK:         %1 = extractelement <2 x i32> %0, i32 0
; CHECK:         %2 = and i32 %1, 7
; CHECK:         %3 = trunc i32 %2 to i8
; CHECK:         store i8 %3, i8 addrspace(1)* %dst
; CHECK:         ret void
  %0 = trunc i64 %input to i3
  %1 = zext i3 %0 to i8
  store i8 %1, i8 addrspace(1)* %dst
  ret void
}

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

!0 = !{void (i32, i32 addrspace(1)*)* @test_i32_to_i32, !100}
!1 = !{void (i32, i16 addrspace(1)*)* @test_i32_to_i16, !100}
!2 = !{void (i64, i64 addrspace(1)*)* @test_i64_to_i64, !100}
!3 = !{void (i64, i8 addrspace(1)*)* @test_i64_to_i8, !100}
!100 = !{!101}
!101 = !{!"function_type", i32 0}