| 1 |
; RUN: llvm-as %s -o %t.bc |
| 2 |
; RUN: llvm-spirv %t.bc --spirv-ext=+SPV_INTEL_function_pointers -o %t.spv |
| 3 |
; RUN: llvm-spirv %t.spv -to-text -o %t.spt |
| 4 |
; RUN: FileCheck < %t.spt %s --check-prefix=CHECK-SPIRV |
| 5 |
; RUN: llvm-spirv -r -emit-opaque-pointers %t.spv -o %t.r.bc |
| 6 |
; RUN: llvm-dis %t.r.bc -o %t.r.ll |
| 7 |
; RUN: FileCheck < %t.r.ll %s --check-prefix=CHECK-LLVM |
| 8 |
|
| 9 |
; CHECK-SPIRV: Name [[#F:]] "_Z3runiiPi" |
| 10 |
|
| 11 |
; 117 is OpConvertPtrToU opcode |
| 12 |
; CHECK-SPIRV: SpecConstantOp [[#]] [[#SpecConst0:]] 117 [[#F1Ptr:]] |
| 13 |
; CHECK-SPIRV: SpecConstantOp [[#]] [[#SpecConst1:]] 117 [[#F2Ptr:]] |
| 14 |
; CHECK-SPIRV: ConstantComposite [[#]] [[#Compos0:]] [[#SpecConst0]] [[#SpecConst0]] |
| 15 |
; CHECK-SPIRV: ConstantComposite [[#]] [[#Compos1:]] [[#SpecConst0]] [[#SpecConst1]] |
| 16 |
|
| 17 |
; CHECK-SPIRV: Function [[#]] [[#F]] [[#]] [[#]] |
| 18 |
; CHECK-SPIRV: Label [[#L1:]] |
| 19 |
; CHECK-SPIRV: BranchConditional [[#]] [[#L2:]] [[#L3:]] |
| 20 |
; CHECK-SPIRV: Label [[#L2]] |
| 21 |
; CHECK-SPIRV: Branch [[#L3]] |
| 22 |
; CHECK-SPIRV: Label [[#L3]] |
| 23 |
; CHECK-NEXT-SPIRV: Phi [[#]] [[#]] |
| 24 |
; CHECK-SAME-SPIRV: [[#Compos0]] [[#L1]] |
| 25 |
; CHECK-SAME-SPIRV: [[#Compos1]] [[#L2]] |
| 26 |
|
| 27 |
; CHECK-LLVM: br label %[[#L:]] |
| 28 |
; CHECK-LLVM: [[#L]]: |
| 29 |
; CHECK-NEXT-LLVM: %[[#]] = phi <2 x i64> [ %[[#]], %[[#]] ], [ %[[#]], %[[#]] ] |
| 30 |
|
| 31 |
|
| 32 |
target triple = "spir-unknown-unknown" |
| 33 |
|
| 34 |
define dso_local i32 @_Z2f1i(i32 %0) { |
| 35 |
%2 = add nsw i32 %0, 1 |
| 36 |
ret i32 %2 |
| 37 |
} |
| 38 |
|
| 39 |
define dso_local i32 @_Z2f2i(i32 %0) { |
| 40 |
%2 = add nsw i32 %0, 2 |
| 41 |
ret i32 %2 |
| 42 |
} |
| 43 |
|
| 44 |
define dso_local i64 @_Z3runiiPi(i32 %0, i32 %1, i32* nocapture %2) local_unnamed_addr { |
| 45 |
%4 = icmp slt i32 %0, 10 |
| 46 |
br i1 %4, label %5, label %7 |
| 47 |
|
| 48 |
5: |
| 49 |
%6 = add nsw i32 %1, 2 |
| 50 |
store i32 %6, i32* %2, align 4 |
| 51 |
br label %7 |
| 52 |
|
| 53 |
7: |
| 54 |
%8 = phi <2 x i64> [ <i64 ptrtoint (i32 (i32)* @_Z2f2i to i64), i64 ptrtoint (i32 (i32)* @_Z2f2i to i64)>, %5 ], [ <i64 ptrtoint (i32 (i32)* @_Z2f2i to i64), i64 ptrtoint (i32 (i32)* @_Z2f1i to i64)>, %3 ] |
| 55 |
%9 = extractelement <2 x i64> %8, i64 0 |
| 56 |
%10 = extractelement <2 x i64> %8, i64 1 |
| 57 |
%11 = add nsw i64 %9, %10 |
| 58 |
ret i64 %11 |
| 59 |
} |