xref: /llvm-project/llvm/test/Transforms/GVN/target-type.ll (revision e6b02214c68df2c9f826e02310c9352ac652e456)
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt -S -passes=gvn < %s | FileCheck %s
3
4; Check that GVN can work with target extension types correctly.
5
6target datalayout = "e-p:64:64:64-p1:16:16:16-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-n8:16:32:64"
7
8define target("spirv.DeviceEvent") @basic_alloc(target("spirv.DeviceEvent") %arg) {
9; CHECK-LABEL: @basic_alloc(
10; CHECK-NEXT:    [[VAL:%.*]] = alloca target("spirv.DeviceEvent"), align 8
11; CHECK-NEXT:    store target("spirv.DeviceEvent") [[ARG:%.*]], ptr [[VAL]], align 8
12; CHECK-NEXT:    ret target("spirv.DeviceEvent") [[ARG]]
13;
14  %val = alloca target("spirv.DeviceEvent")
15  store target("spirv.DeviceEvent") %arg, ptr %val
16  %ret = load target("spirv.DeviceEvent"), ptr %val
17  ret target("spirv.DeviceEvent") %ret
18}
19
20define target("spirv.DeviceEvent") @nobitcast(ptr %arg) {
21; CHECK-LABEL: @nobitcast(
22; CHECK-NEXT:    [[VAL:%.*]] = alloca target("spirv.DeviceEvent"), align 8
23; CHECK-NEXT:    store ptr [[ARG:%.*]], ptr [[VAL]], align 8
24; CHECK-NEXT:    [[RET:%.*]] = load target("spirv.DeviceEvent"), ptr [[VAL]], align 8
25; CHECK-NEXT:    ret target("spirv.DeviceEvent") [[RET]]
26;
27  %val = alloca target("spirv.DeviceEvent")
28  store ptr %arg, ptr %val
29  %ret = load target("spirv.DeviceEvent"), ptr %val
30  ret target("spirv.DeviceEvent") %ret
31}
32
33define target("spirv.DeviceEvent") @viai64(target("spirv.DeviceEvent") %arg) {
34; CHECK-LABEL: @viai64(
35; CHECK-NEXT:    [[VAL:%.*]] = alloca target("spirv.DeviceEvent"), align 8
36; CHECK-NEXT:    [[BAR:%.*]] = alloca target("spirv.DeviceEvent"), align 8
37; CHECK-NEXT:    store target("spirv.DeviceEvent") [[ARG:%.*]], ptr [[VAL]], align 8
38; CHECK-NEXT:    [[IMEMCPY:%.*]] = load i64, ptr [[VAL]], align 4
39; CHECK-NEXT:    store i64 [[IMEMCPY]], ptr [[BAR]], align 4
40; CHECK-NEXT:    [[RET:%.*]] = load target("spirv.DeviceEvent"), ptr [[BAR]], align 8
41; CHECK-NEXT:    ret target("spirv.DeviceEvent") [[RET]]
42;
43  %val = alloca target("spirv.DeviceEvent")
44  %bar = alloca target("spirv.DeviceEvent")
45  store target("spirv.DeviceEvent") %arg, ptr %val
46  %imemcpy = load i64, ptr %val
47  store i64 %imemcpy, ptr %bar
48  %ret = load target("spirv.DeviceEvent"), ptr %bar
49  ret target("spirv.DeviceEvent") %ret
50}
51
52declare void @llvm.memcpy.p0.p0.i64(ptr, ptr, i64, i1)
53