File: select-phi.ll

package info (click to toggle)
llvm-toolchain-20 1%3A20.1.6-1~exp1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 2,111,304 kB
  • sloc: cpp: 7,438,677; ansic: 1,393,822; asm: 1,012,926; python: 241,650; f90: 86,635; objc: 75,479; lisp: 42,144; pascal: 17,286; sh: 10,027; ml: 5,082; perl: 4,730; awk: 3,523; makefile: 3,349; javascript: 2,251; xml: 892; fortran: 672
file content (64 lines) | stat: -rw-r--r-- 3,019 bytes parent folder | download | duplicates (6)
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
; This test case checks how phi-nodes with different operand types select
; a result type. Majority of operands makes it i8* in this case.

; RUN: llc -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s
; RUN: llc -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s

; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv32-unknown-unknown --translator-compatibility-mode %s -o - -filetype=obj | spirv-val %}
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv32-unknown-unknown %s -o - -filetype=obj | spirv-val %}
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown --translator-compatibility-mode %s -o - -filetype=obj | spirv-val %}
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %}

; CHECK-DAG: %[[Char:.*]] = OpTypeInt 8 0
; CHECK-DAG: %[[Long:.*]] = OpTypeInt 32 0
; CHECK-DAG: %[[Array:.*]] = OpTypeArray %[[Long]] %[[#]]
; CHECK-DAG: %[[Struct:.*]] = OpTypeStruct %[[Array]]
; CHECK-DAG: %[[StructPtr:.*]] = OpTypePointer Function %[[Struct]]
; CHECK-DAG: %[[CharPtr:.*]] = OpTypePointer Function %[[Char]]

; CHECK: %[[Branch1:.*]] = OpLabel
; CHECK: %[[Res1:.*]] = OpVariable %[[StructPtr]] Function
; CHECK: %[[Res1Casted:.*]] = OpBitcast %[[CharPtr]] %[[Res1]]
; CHECK: OpBranchConditional %[[#]] %[[#]] %[[Branch2:.*]]
; CHECK: %[[Res2:.*]] = OpInBoundsPtrAccessChain %[[CharPtr]] %[[#]] %[[#]]
; CHECK: OpBranchConditional %[[#]] %[[#]] %[[BranchSelect:.*]]
; CHECK: %[[SelectRes:.*]] = OpSelect %[[CharPtr]] %[[#]] %[[#]] %[[#]]
; CHECK: OpLabel
; CHECK: OpPhi %[[CharPtr]] %[[Res1Casted]] %[[Branch1]] %[[Res2]] %[[Branch2]] %[[SelectRes]] %[[BranchSelect]]

%struct = type { %array }
%array = type { [1 x i64] }
%array3 = type { [3 x i32] }

define spir_kernel void @foo(ptr addrspace(1) noundef align 1 %arg1, ptr noundef byval(%struct) align 8 %arg2, i1 noundef zeroext %expected) {
entry:
  %agg = alloca %array3, align 8
  %r0 = load i64, ptr %arg2, align 8
  %add.ptr = getelementptr inbounds i8, ptr %agg, i64 12
  %r1 = load i32, ptr %agg, align 4
  %tobool0 = icmp slt i32 %r1, 0
  br i1 %tobool0, label %exit, label %sw1

sw1:                            ; preds = %entry
  %incdec1 = getelementptr inbounds i8, ptr %agg, i64 4
  %r2 = load i32, ptr %incdec1, align 4
  %tobool1 = icmp slt i32 %r2, 0
  br i1 %tobool1, label %exit, label %sw2

sw2:                            ; preds = %sw1
  %incdec2 = getelementptr inbounds i8, ptr %agg, i64 8
  %r3 = load i32, ptr %incdec2, align 4
  %tobool2 = icmp slt i32 %r3, 0
  %spec.select = select i1 %tobool2, ptr %incdec2, ptr %add.ptr
  br label %exit

exit: ; preds = %sw2, %sw1, %entry
  %retval.0 = phi ptr [ %agg, %entry ], [ %incdec1, %sw1 ], [ %spec.select, %sw2 ]
  %add.ptr.i = getelementptr inbounds i8, ptr addrspace(1) %arg1, i64 %r0
  %r4 = icmp eq ptr %retval.0, %add.ptr
  %cmp = xor i1 %r4, %expected
  %frombool6.i = zext i1 %cmp to i8
  store i8 %frombool6.i, ptr addrspace(1) %add.ptr.i, align 1
  %r5 = icmp eq ptr %add.ptr, %retval.0
  ret void
}