1 ; RUN: llc -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV
3 ; CHECK-SPIRV: OpName %[[#FuncNameInt16:]] "spirv.llvm_bswap_i16"
4 ; CHECK-SPIRV: OpName %[[#FuncNameInt32:]] "spirv.llvm_bswap_i32"
5 ; CHECK-SPIRV: OpName %[[#FuncNameInt64:]] "spirv.llvm_bswap_i64"
7 ; CHECK-SPIRV: %[[#TypeInt32:]] = OpTypeInt 32 0
8 ; CHECK-SPIRV: %[[#TypeInt16:]] = OpTypeInt 16 0
9 ; CHECK-SPIRV: %[[#TypeInt64:]] = OpTypeInt 64 0
11 ; CHECK-SPIRV: %[[#FuncNameInt16]] = OpFunction %[[#TypeInt16]]
12 ; CHECK-SPIRV: %[[#FuncParameter:]] = OpFunctionParameter %[[#TypeInt16]]
13 ; CHECK-SPIRV: %[[#]] = OpShiftLeftLogical %[[#TypeInt16]] %[[#FuncParameter]]
14 ; CHECK-SPIRV: %[[#]] = OpShiftRightLogical %[[#TypeInt16]] %[[#FuncParameter]]
15 ; CHECK-SPIRV: %[[#RetVal:]] = OpBitwiseOr %[[#TypeInt16]]
16 ; CHECK-SPIRV: OpReturnValue %[[#RetVal]]
17 ; CHECK-SPIRV: OpFunctionEnd
19 ; CHECK-SPIRV: %[[#FuncNameInt32]] = OpFunction %[[#TypeInt32]]
20 ; CHECK-SPIRV: %[[#FuncParameter:]] = OpFunctionParameter %[[#TypeInt32]]
21 ; CHECK-SPIRV-COUNT-2: %[[#]] = OpShiftLeftLogical %[[#TypeInt32]] %[[#FuncParameter]]
22 ; CHECK-SPIRV-COUNT-2: %[[#]] = OpShiftRightLogical %[[#TypeInt32]] %[[#FuncParameter]]
23 ; CHECK-SPIRV-COUNT-2: OpBitwiseAnd %[[#TypeInt32]]
24 ; CHECK-SPIRV-COUNT-2: OpBitwiseOr %[[#TypeInt32]]
25 ; CHECK-SPIRV: %[[#RetVal:]] = OpBitwiseOr %[[#TypeInt32]]
26 ; CHECK-SPIRV: OpReturnValue %[[#RetVal:]]
27 ; CHECK-SPIRV: OpFunctionEnd
29 ; CHECK-SPIRV: %[[#FuncNameInt64]] = OpFunction %[[#TypeInt64]]
30 ; CHECK-SPIRV: %[[#FuncParameter:]] = OpFunctionParameter %[[#TypeInt64]]
31 ; CHECK-SPIRV-COUNT-4: %[[#]] = OpShiftLeftLogical %[[#TypeInt64]] %[[#FuncParameter]] %[[#]]
32 ; CHECK-SPIRV-COUNT-4: %[[#]] = OpShiftRightLogical %[[#TypeInt64]] %[[#FuncParameter]] %[[#]]
33 ; CHECK-SPIRV-COUNT-6: OpBitwiseAnd %[[#TypeInt64]]
34 ; CHECK-SPIRV-COUNT-6: OpBitwiseOr %[[#TypeInt64]]
35 ; CHECK-SPIRV: %[[#RetVal:]] = OpBitwiseOr %[[#TypeInt64]]
36 ; CHECK-SPIRV: OpReturnValue %[[#RetVal]]
37 ; CHECK-SPIRV: OpFunctionEnd
39 define dso_local i32 @main() {
41 %retval = alloca i32, align 4
42 %a = alloca i16, align 2
43 %b = alloca i16, align 2
44 %h = alloca i16, align 2
45 %i = alloca i16, align 2
46 %c = alloca i32, align 4
47 %d = alloca i32, align 4
48 %e = alloca i64, align 8
49 %f = alloca i64, align 8
50 store i32 0, i32* %retval, align 4
51 store i16 258, i16* %a, align 2
52 %0 = load i16, i16* %a, align 2
53 %1 = call i16 @llvm.bswap.i16(i16 %0)
54 store i16 %1, i16* %b, align 2
55 store i16 234, i16* %h, align 2
56 %2 = load i16, i16* %h, align 2
57 %3 = call i16 @llvm.bswap.i16(i16 %2)
58 store i16 %3, i16* %i, align 2
59 store i32 566, i32* %c, align 4
60 %4 = load i32, i32* %c, align 4
61 %5 = call i32 @llvm.bswap.i32(i32 %4)
62 store i32 %5, i32* %d, align 4
63 store i64 12587, i64* %e, align 8
64 %6 = load i64, i64* %e, align 8
65 %7 = call i64 @llvm.bswap.i64(i64 %6)
66 store i64 %7, i64* %f, align 8
70 declare i16 @llvm.bswap.i16(i16)
72 declare i32 @llvm.bswap.i32(i32)
74 declare i64 @llvm.bswap.i64(i64)