| 1 |
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 6 |
| 2 |
// RUN: %clang_cc1 -triple riscv64-none-linux-gnu -target-feature +f -target-feature +d -target-feature +zve64d -mvscale-min=2 -mvscale-max=2 -O1 -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-128 |
| 3 |
|
| 4 |
// REQUIRES: riscv-registered-target |
| 5 |
|
| 6 |
#include <stdint.h> |
| 7 |
|
| 8 |
typedef __rvv_int8m1_t vint8m1_t; |
| 9 |
typedef __rvv_uint8m1_t vuint8m1_t; |
| 10 |
typedef __rvv_int16m1_t vint16m1_t; |
| 11 |
typedef __rvv_uint16m1_t vuint16m1_t; |
| 12 |
typedef __rvv_int32m1_t vint32m1_t; |
| 13 |
typedef __rvv_uint32m1_t vuint32m1_t; |
| 14 |
typedef __rvv_int64m1_t vint64m1_t; |
| 15 |
typedef __rvv_uint64m1_t vuint64m1_t; |
| 16 |
typedef __rvv_float32m1_t vfloat32m1_t; |
| 17 |
typedef __rvv_float64m1_t vfloat64m1_t; |
| 18 |
|
| 19 |
typedef __rvv_bool1_t vbool1_t; |
| 20 |
typedef __rvv_bool2_t vbool2_t; |
| 21 |
typedef __rvv_bool4_t vbool4_t; |
| 22 |
typedef __rvv_bool8_t vbool8_t; |
| 23 |
typedef __rvv_bool16_t vbool16_t; |
| 24 |
typedef __rvv_bool32_t vbool32_t; |
| 25 |
typedef __rvv_bool64_t vbool64_t; |
| 26 |
|
| 27 |
typedef vint64m1_t fixed_int64m1_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen))); |
| 28 |
typedef vfloat64m1_t fixed_float64m1_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen))); |
| 29 |
typedef vbool1_t fixed_bool1_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen))); |
| 30 |
typedef vbool2_t fixed_bool2_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 2))); |
| 31 |
typedef vbool4_t fixed_bool4_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 4))); |
| 32 |
typedef vbool8_t fixed_bool8_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 8))); |
| 33 |
typedef vbool16_t fixed_bool16_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 16))); |
| 34 |
typedef vbool32_t fixed_bool32_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 32))); |
| 35 |
typedef vbool64_t fixed_bool64_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 64))); |
| 36 |
|
| 37 |
#define DEFINE_STRUCT(ty) \ |
| 38 |
struct struct_##ty { \ |
| 39 |
fixed_##ty##_t x, y[3]; \ |
| 40 |
} struct_##ty; |
| 41 |
|
| 42 |
DEFINE_STRUCT(int64m1) |
| 43 |
DEFINE_STRUCT(float64m1) |
| 44 |
DEFINE_STRUCT(bool1) |
| 45 |
DEFINE_STRUCT(bool2) |
| 46 |
DEFINE_STRUCT(bool4) |
| 47 |
DEFINE_STRUCT(bool8) |
| 48 |
DEFINE_STRUCT(bool16) |
| 49 |
DEFINE_STRUCT(bool32) |
| 50 |
DEFINE_STRUCT(bool64) |
| 51 |
|
| 52 |
//===----------------------------------------------------------------------===// |
| 53 |
// bool |
| 54 |
//===----------------------------------------------------------------------===// |
| 55 |
|
| 56 |
// CHECK-128-LABEL: define dso_local <vscale x 2 x i1> @read_bool32( |
| 57 |
// CHECK-128-SAME: ptr noundef readonly captures(none) [[S:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] { |
| 58 |
// CHECK-128-NEXT: [[ENTRY:.*:]] |
| 59 |
// CHECK-128-NEXT: [[Y:%.*]] = getelementptr inbounds nuw i8, ptr [[S]], i64 1 |
| 60 |
// CHECK-128-NEXT: [[TMP0:%.*]] = load <1 x i8>, ptr [[Y]], align 1, !tbaa [[CHAR_TBAA10:![0-9]+]] |
| 61 |
// CHECK-128-NEXT: [[CAST_SCALABLE:%.*]] = tail call <vscale x 1 x i8> @llvm.vector.insert.nxv1i8.v1i8(<vscale x 1 x i8> poison, <1 x i8> [[TMP0]], i64 0) |
| 62 |
// CHECK-128-NEXT: [[TMP1:%.*]] = bitcast <vscale x 1 x i8> [[CAST_SCALABLE]] to <vscale x 8 x i1> |
| 63 |
// CHECK-128-NEXT: [[TMP2:%.*]] = tail call <vscale x 2 x i1> @llvm.vector.extract.nxv2i1.nxv8i1(<vscale x 8 x i1> [[TMP1]], i64 0) |
| 64 |
// CHECK-128-NEXT: ret <vscale x 2 x i1> [[TMP2]] |
| 65 |
// |
| 66 |
vbool32_t read_bool32(struct struct_bool32 *s) { |
| 67 |
return s->y[0]; |
| 68 |
} |
| 69 |
|
| 70 |
// CHECK-128-LABEL: define dso_local void @write_bool32( |
| 71 |
// CHECK-128-SAME: ptr noundef writeonly captures(none) initializes((1, 2)) [[S:%.*]], <vscale x 2 x i1> [[X:%.*]]) local_unnamed_addr #[[ATTR2:[0-9]+]] { |
| 72 |
// CHECK-128-NEXT: [[ENTRY:.*:]] |
| 73 |
// CHECK-128-NEXT: [[TMP0:%.*]] = tail call <vscale x 8 x i1> @llvm.vector.insert.nxv8i1.nxv2i1(<vscale x 8 x i1> zeroinitializer, <vscale x 2 x i1> [[X]], i64 0) |
| 74 |
// CHECK-128-NEXT: [[TMP1:%.*]] = bitcast <vscale x 8 x i1> [[TMP0]] to <vscale x 1 x i8> |
| 75 |
// CHECK-128-NEXT: [[CAST_FIXED:%.*]] = tail call <1 x i8> @llvm.vector.extract.v1i8.nxv1i8(<vscale x 1 x i8> [[TMP1]], i64 0) |
| 76 |
// CHECK-128-NEXT: [[Y:%.*]] = getelementptr inbounds nuw i8, ptr [[S]], i64 1 |
| 77 |
// CHECK-128-NEXT: store <1 x i8> [[CAST_FIXED]], ptr [[Y]], align 1, !tbaa [[CHAR_TBAA10]] |
| 78 |
// CHECK-128-NEXT: ret void |
| 79 |
// |
| 80 |
void write_bool32(struct struct_bool32 *s, vbool32_t x) { |
| 81 |
s->y[0] = x; |
| 82 |
} |
| 83 |
|
| 84 |
// CHECK-128-LABEL: define dso_local <vscale x 1 x i1> @read_bool64( |
| 85 |
// CHECK-128-SAME: ptr noundef readonly captures(none) [[S:%.*]]) local_unnamed_addr #[[ATTR0]] { |
| 86 |
// CHECK-128-NEXT: [[ENTRY:.*:]] |
| 87 |
// CHECK-128-NEXT: [[Y:%.*]] = getelementptr inbounds nuw i8, ptr [[S]], i64 1 |
| 88 |
// CHECK-128-NEXT: [[TMP0:%.*]] = load <1 x i8>, ptr [[Y]], align 1, !tbaa [[CHAR_TBAA10]] |
| 89 |
// CHECK-128-NEXT: [[CAST_SCALABLE:%.*]] = tail call <vscale x 1 x i8> @llvm.vector.insert.nxv1i8.v1i8(<vscale x 1 x i8> poison, <1 x i8> [[TMP0]], i64 0) |
| 90 |
// CHECK-128-NEXT: [[TMP1:%.*]] = bitcast <vscale x 1 x i8> [[CAST_SCALABLE]] to <vscale x 8 x i1> |
| 91 |
// CHECK-128-NEXT: [[TMP2:%.*]] = tail call <vscale x 1 x i1> @llvm.vector.extract.nxv1i1.nxv8i1(<vscale x 8 x i1> [[TMP1]], i64 0) |
| 92 |
// CHECK-128-NEXT: ret <vscale x 1 x i1> [[TMP2]] |
| 93 |
// |
| 94 |
vbool64_t read_bool64(struct struct_bool64 *s) { |
| 95 |
return s->y[0]; |
| 96 |
} |
| 97 |
|
| 98 |
// CHECK-128-LABEL: define dso_local void @write_bool64( |
| 99 |
// CHECK-128-SAME: ptr noundef writeonly captures(none) initializes((1, 2)) [[S:%.*]], <vscale x 1 x i1> [[X:%.*]]) local_unnamed_addr #[[ATTR2]] { |
| 100 |
// CHECK-128-NEXT: [[ENTRY:.*:]] |
| 101 |
// CHECK-128-NEXT: [[TMP0:%.*]] = tail call <vscale x 8 x i1> @llvm.vector.insert.nxv8i1.nxv1i1(<vscale x 8 x i1> zeroinitializer, <vscale x 1 x i1> [[X]], i64 0) |
| 102 |
// CHECK-128-NEXT: [[TMP1:%.*]] = bitcast <vscale x 8 x i1> [[TMP0]] to <vscale x 1 x i8> |
| 103 |
// CHECK-128-NEXT: [[CAST_FIXED:%.*]] = tail call <1 x i8> @llvm.vector.extract.v1i8.nxv1i8(<vscale x 1 x i8> [[TMP1]], i64 0) |
| 104 |
// CHECK-128-NEXT: [[Y:%.*]] = getelementptr inbounds nuw i8, ptr [[S]], i64 1 |
| 105 |
// CHECK-128-NEXT: store <1 x i8> [[CAST_FIXED]], ptr [[Y]], align 1, !tbaa [[CHAR_TBAA10]] |
| 106 |
// CHECK-128-NEXT: ret void |
| 107 |
// |
| 108 |
void write_bool64(struct struct_bool64 *s, vbool64_t x) { |
| 109 |
s->y[0] = x; |
| 110 |
} |
| 111 |
//. |
| 112 |
// CHECK-128: [[META8:![0-9]+]] = !{!"omnipotent char", [[META9:![0-9]+]], i64 0} |
| 113 |
// CHECK-128: [[META9]] = !{!"Simple C/C++ TBAA"} |
| 114 |
// CHECK-128: [[CHAR_TBAA10]] = !{[[META8]], [[META8]], i64 0} |
| 115 |
//. |