Debian Codegraph @

clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/rvv-tuple-type.c

raw
1 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2
2 // REQUIRES: riscv-registered-target
3 // RUN: %clang_cc1 -triple riscv64 -target-feature +zve32x -O0 \
4 // RUN: -emit-llvm %s -o - | FileCheck %s --check-prefix=O0
5 // RUN: %clang_cc1 -triple riscv64 -target-feature +zve32x -disable-O0-optnone \
6 // RUN: -emit-llvm %s -o - | opt -S -passes=mem2reg | FileCheck %s --check-prefix=AFTER_MEM2REG
7
8 // This test case tests the lowering of RVV tuple types into LLVM IR.
9
10 #include <riscv_vector.h>
11
12 // Declare local variable
13 // O0-LABEL: define dso_local void @foo
14 // O0-SAME: () #[[ATTR0:[0-9]+]] {
15 // O0-NEXT: entry:
16 // O0-NEXT: [[V_TUPLE:%.*]] = alloca target("riscv.vector.tuple", <vscale x 8 x i8>, 2), align 4
17 // O0-NEXT: ret void
18 //
19 // AFTER_MEM2REG-LABEL: define dso_local void @foo
20 // AFTER_MEM2REG-SAME: () #[[ATTR0:[0-9]+]] {
21 // AFTER_MEM2REG-NEXT: entry:
22 // AFTER_MEM2REG-NEXT: ret void
23 //
24 void foo() {
25 __rvv_int32m1x2_t v_tuple;
26 }
27
28 // Declare local variable and return
29 // O0-LABEL: define dso_local target("riscv.vector.tuple", <vscale x 8 x i8>, 2) @bar
30 // O0-SAME: () #[[ATTR0]] {
31 // O0-NEXT: entry:
32 // O0-NEXT: [[V_TUPLE:%.*]] = alloca target("riscv.vector.tuple", <vscale x 8 x i8>, 2), align 4
33 // O0-NEXT: [[TMP0:%.*]] = load target("riscv.vector.tuple", <vscale x 8 x i8>, 2), ptr [[V_TUPLE]], align 4
34 // O0-NEXT: ret target("riscv.vector.tuple", <vscale x 8 x i8>, 2) [[TMP0]]
35 //
36 // AFTER_MEM2REG-LABEL: define dso_local target("riscv.vector.tuple", <vscale x 8 x i8>, 2) @bar
37 // AFTER_MEM2REG-SAME: () #[[ATTR0]] {
38 // AFTER_MEM2REG-NEXT: entry:
39 // AFTER_MEM2REG-NEXT: ret target("riscv.vector.tuple", <vscale x 8 x i8>, 2) undef
40 //
41 __rvv_int32m1x2_t bar() {
42 __rvv_int32m1x2_t v_tuple;
43 return v_tuple;
44 }
45
46 // Pass as function parameter
47 // O0-LABEL: define dso_local void @baz
48 // O0-SAME: (target("riscv.vector.tuple", <vscale x 8 x i8>, 2) [[V_TUPLE:%.*]]) #[[ATTR0]] {
49 // O0-NEXT: entry:
50 // O0-NEXT: [[V_TUPLE_ADDR:%.*]] = alloca target("riscv.vector.tuple", <vscale x 8 x i8>, 2), align 4
51 // O0-NEXT: store target("riscv.vector.tuple", <vscale x 8 x i8>, 2) [[V_TUPLE]], ptr [[V_TUPLE_ADDR]], align 4
52 // O0-NEXT: ret void
53 //
54 // AFTER_MEM2REG-LABEL: define dso_local void @baz
55 // AFTER_MEM2REG-SAME: (target("riscv.vector.tuple", <vscale x 8 x i8>, 2) [[V_TUPLE:%.*]]) #[[ATTR0]] {
56 // AFTER_MEM2REG-NEXT: entry:
57 // AFTER_MEM2REG-NEXT: ret void
58 //
59 void baz(__rvv_int32m1x2_t v_tuple) {
60 }
61
62 // Pass as function parameter and return
63 // O0-LABEL: define dso_local target("riscv.vector.tuple", <vscale x 8 x i8>, 2) @qux
64 // O0-SAME: (target("riscv.vector.tuple", <vscale x 8 x i8>, 2) [[V_TUPLE:%.*]]) #[[ATTR0]] {
65 // O0-NEXT: entry:
66 // O0-NEXT: [[V_TUPLE_ADDR:%.*]] = alloca target("riscv.vector.tuple", <vscale x 8 x i8>, 2), align 4
67 // O0-NEXT: store target("riscv.vector.tuple", <vscale x 8 x i8>, 2) [[V_TUPLE]], ptr [[V_TUPLE_ADDR]], align 4
68 // O0-NEXT: [[TMP0:%.*]] = load target("riscv.vector.tuple", <vscale x 8 x i8>, 2), ptr [[V_TUPLE_ADDR]], align 4
69 // O0-NEXT: ret target("riscv.vector.tuple", <vscale x 8 x i8>, 2) [[TMP0]]
70 //
71 // AFTER_MEM2REG-LABEL: define dso_local target("riscv.vector.tuple", <vscale x 8 x i8>, 2) @qux
72 // AFTER_MEM2REG-SAME: (target("riscv.vector.tuple", <vscale x 8 x i8>, 2) [[V_TUPLE:%.*]]) #[[ATTR0]] {
73 // AFTER_MEM2REG-NEXT: entry:
74 // AFTER_MEM2REG-NEXT: ret target("riscv.vector.tuple", <vscale x 8 x i8>, 2) [[V_TUPLE]]
75 //
76 __rvv_int32m1x2_t qux(__rvv_int32m1x2_t v_tuple) {
77 return v_tuple;
78 }
79
80 // O0-LABEL: define dso_local target("riscv.vector.tuple", <vscale x 8 x i8>, 2) @quux
81 // O0-SAME: (target("riscv.vector.tuple", <vscale x 8 x i8>, 2) [[V_TUPLE:%.*]]) #[[ATTR0]] {
82 // O0-NEXT: entry:
83 // O0-NEXT: [[V_TUPLE_ADDR:%.*]] = alloca target("riscv.vector.tuple", <vscale x 8 x i8>, 2), align 4
84 // O0-NEXT: store target("riscv.vector.tuple", <vscale x 8 x i8>, 2) [[V_TUPLE]], ptr [[V_TUPLE_ADDR]], align 4
85 // O0-NEXT: [[TMP0:%.*]] = load target("riscv.vector.tuple", <vscale x 8 x i8>, 2), ptr [[V_TUPLE_ADDR]], align 4
86 // O0-NEXT: [[CALL:%.*]] = call target("riscv.vector.tuple", <vscale x 8 x i8>, 2) @qux(target("riscv.vector.tuple", <vscale x 8 x i8>, 2) [[TMP0]])
87 // O0-NEXT: ret target("riscv.vector.tuple", <vscale x 8 x i8>, 2) [[CALL]]
88 //
89 // AFTER_MEM2REG-LABEL: define dso_local target("riscv.vector.tuple", <vscale x 8 x i8>, 2) @quux
90 // AFTER_MEM2REG-SAME: (target("riscv.vector.tuple", <vscale x 8 x i8>, 2) [[V_TUPLE:%.*]]) #[[ATTR0]] {
91 // AFTER_MEM2REG-NEXT: entry:
92 // AFTER_MEM2REG-NEXT: [[CALL:%.*]] = call target("riscv.vector.tuple", <vscale x 8 x i8>, 2) @qux(target("riscv.vector.tuple", <vscale x 8 x i8>, 2) [[V_TUPLE]])
93 // AFTER_MEM2REG-NEXT: ret target("riscv.vector.tuple", <vscale x 8 x i8>, 2) [[CALL]]
94 //
95 __rvv_int32m1x2_t quux(__rvv_int32m1x2_t v_tuple) {
96 return qux(v_tuple);
97 }