Skip to content

Commit 491b33f

Browse files
authored
Addition of lshr-constexpr.ll and opaque-pointers.ll (#3326)
Added test files for lshr constexpr and opaque pointers
1 parent 4796d25 commit 491b33f

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed

test/lshr-constexpr.ll

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
; RUN: llvm-as < %s -o %t.bc
2+
; RUN: llvm-spirv %t.bc -o %t.spv
3+
; RUN: spirv-val %t.spv
4+
; RUN: llvm-spirv -to-text %t.spv -o - | FileCheck %s
5+
; RUN: llvm-spirv -r %t.spv -o %t.rev.bc
6+
; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM
7+
8+
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64"
9+
target triple = "spir64-unknown-unknown"
10+
11+
; CHECK: TypeInt [[#Int64Ty:]] 64 0
12+
; CHECK: TypeInt [[#Int32Ty:]] 32 0
13+
; CHECK: Constant [[#Int32Ty]] [[#One32:]] 1
14+
; CHECK: Constant [[#Int64Ty]] [[#ShiftAmt:]] 32 0
15+
; CHECK: TypeVector [[#Vec2Int32Ty:]] [[#Int32Ty]] 2
16+
; CHECK: ConstantComposite [[#Vec2Int32Ty]] [[#VecConst:]] [[#One32]] [[#One32]]
17+
; CHECK: Bitcast [[#Int64Ty]] [[#BitcastedVal:]] [[#VecConst]]
18+
; CHECK: ShiftRightLogical [[#Int64Ty]] [[#Shifted:]] [[#BitcastedVal]] [[#ShiftAmt]]
19+
20+
; CHECK-LLVM: define spir_func void @foo(ptr [[arg:%.*]])
21+
; CHECK-LLVM: [[bc:%.*]] = bitcast <2 x i32> splat (i32 1) to i64
22+
; CHECK-LLVM: [[shr:%.*]] = lshr i64 [[bc]], 32
23+
; CHECK-LLVM: store i64 [[shr]], ptr [[arg]], align 8
24+
25+
define void @foo(ptr %arg) {
26+
entry:
27+
%0 = lshr i64 bitcast (<2 x i32> <i32 1, i32 1> to i64), 32
28+
store i64 %0, i64* %arg
29+
ret void
30+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
; RUN: llvm-as < %s -o %t.bc
2+
; RUN: llvm-spirv %t.bc -o %t.spv
3+
; RUN: spirv-val %t.spv
4+
; RUN: llvm-spirv -to-text %t.spv -o - | FileCheck %s
5+
; RUN: llvm-spirv -r %t.spv -o %t.rev.bc
6+
; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM
7+
8+
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64"
9+
target triple = "spir64-unknown-unknown"
10+
11+
; CHECK: TypeInt [[#Int64Ty:]] 64 0
12+
; CHECK: TypeInt [[#Int32Ty:]] 32 0
13+
; CHECK: Constant [[#Int32Ty]] [[#ZeroConst:]] 0
14+
; CHECK: TypePointer [[#PtrInt32Ty:]] 7 [[#Int32Ty]]
15+
; CHECK: TypeFunction [[#FTy:]] [[#Int64Ty]] [[#PtrInt32Ty]]
16+
; CHECK: TypePointer [[#PtrInt64Ty:]] 7 [[#Int64Ty]]
17+
18+
; CHECK: Function [[#Int64Ty]] [[#FuncId:]] 0 [[#FTy]]
19+
; CHECK: FunctionParameter [[#PtrInt32Ty]] [[#ParamId:]]
20+
; CHECK: Store [[#ParamId]] [[#ZeroConst]] 2 4
21+
; CHECK: Bitcast [[#PtrInt64Ty]] [[#CastId:]] [[#ParamId]]
22+
; CHECK: Load [[#Int64Ty]] [[#ResultId:]] [[#CastId]] 2 4
23+
; CHECK: ReturnValue [[#ResultId]]
24+
25+
; CHECK-LLVM: define spir_func i64 @test(ptr [[p:%.*]])
26+
; CHECK-LLVM: store i32 0, ptr [[p]], align 4
27+
; CHECK-LLVM: [[bc:%.*]] = bitcast ptr [[p]] to ptr
28+
; CHECK-LLVM: [[v:%.*]] = load i64, ptr [[bc]], align 4
29+
30+
define i64 @test(ptr %p) {
31+
store i32 0, ptr %p, align 4
32+
%v = load i64, ptr %p, align 4
33+
ret i64 %v
34+
}

0 commit comments

Comments
 (0)