| 1 |
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 6 |
| 2 |
// REQUIRES: aarch64-registered-target |
| 3 |
|
| 4 |
// RUN: %clang_cc1 -triple aarch64 -target-feature +sve -disable-O0-optnone -Werror -Wall -fclangir -emit-cir -o - %s | FileCheck %s --check-prefixes=ALL,CIR |
| 5 |
// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64 -target-feature +sve -disable-O0-optnone -Werror -Wall -fclangir -emit-cir -o - %s | FileCheck %s --check-prefixes=ALL,CIR |
| 6 |
|
| 7 |
// RUN: %clang_cc1 -triple aarch64 -target-feature +sve -disable-O0-optnone -Werror -Wall -fclangir -emit-llvm -o - %s | FileCheck %s --check-prefixes=ALL,LLVM_OGCG_CIR |
| 8 |
// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64 -target-feature +sve -disable-O0-optnone -Werror -Wall -fclangir -emit-llvm -o - %s | FileCheck %s --check-prefixes=ALL,LLVM_OGCG_CIR |
| 9 |
|
| 10 |
// RUN: %clang_cc1 -triple aarch64 -target-feature +sve -disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | FileCheck %s --check-prefixes=ALL,LLVM_OGCG_CIR |
| 11 |
// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64 -target-feature +sve -disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | FileCheck %s --check-prefixes=ALL,LLVM_OGCG_CIR |
| 12 |
|
| 13 |
#include <arm_sve.h> |
| 14 |
|
| 15 |
#if defined __ARM_FEATURE_SME |
| 16 |
#define MODE_ATTR __arm_streaming |
| 17 |
#else |
| 18 |
#define MODE_ATTR |
| 19 |
#endif |
| 20 |
|
| 21 |
#ifdef SVE_OVERLOADED_FORMS |
| 22 |
// A simple used,unused... macro, long enough to represent any SVE builtin. |
| 23 |
#define SVE_ACLE_FUNC(A1,A2_UNUSED,A3,A4_UNUSED) A1##A3 |
| 24 |
#else |
| 25 |
#define SVE_ACLE_FUNC(A1,A2,A3,A4) A1##A2##A3##A4 |
| 26 |
#endif |
| 27 |
|
| 28 |
// ALL-LABEL: @test_svlen_u8 |
| 29 |
uint64_t test_svlen_u8(svuint8_t op) MODE_ATTR |
| 30 |
{ |
| 31 |
// CIR: %[[VSCALE:.*]] = cir.call_llvm_intrinsic "vscale" : () -> !u64i |
| 32 |
// CIR: %[[C16:.*]] = cir.const #cir.int<16> : !u64i |
| 33 |
// CIR: %[[BINOP:.*]] = cir.binop(mul, %[[VSCALE]], %[[C16]]) nuw : !u64i |
| 34 |
|
| 35 |
// LLVM_OGCG_CIR: [[VSCALE:%.*]] = call i64 @llvm.vscale.i64() |
| 36 |
// LLVM_OGCG_CIR: [[RES:%.*]] = mul nuw i64 [[VSCALE]], 16 |
| 37 |
return SVE_ACLE_FUNC(svlen,_u8,,)(op); |
| 38 |
} |
| 39 |
|
| 40 |
// ALL-LABEL: @test_svlen_s8( |
| 41 |
uint64_t test_svlen_s8(svint8_t op) MODE_ATTR |
| 42 |
{ |
| 43 |
// CIR: %[[VSCALE:.*]] = cir.call_llvm_intrinsic "vscale" : () -> !u64i |
| 44 |
// CIR: %[[C16:.*]] = cir.const #cir.int<16> : !u64i |
| 45 |
// CIR: %[[BINOP:.*]] = cir.binop(mul, %[[VSCALE]], %[[C16]]) nuw : !u64i |
| 46 |
|
| 47 |
// LLVM_OGCG_CIR: [[VSCALE:%.*]] = call i64 @llvm.vscale.i64() |
| 48 |
// LLVM_OGCG_CIR: [[RES:%.*]] = mul nuw i64 [[VSCALE]], 16 |
| 49 |
return SVE_ACLE_FUNC(svlen,_s8,,)(op); |
| 50 |
} |
| 51 |
|
| 52 |
// ALL-LABEL: @test_svlen_u16( |
| 53 |
uint64_t test_svlen_u16(svuint16_t op) MODE_ATTR |
| 54 |
{ |
| 55 |
// CIR: %[[VSCALE:.*]] = cir.call_llvm_intrinsic "vscale" : () -> !u64i |
| 56 |
// CIR: %[[C8:.*]] = cir.const #cir.int<8> : !u64i |
| 57 |
// CIR: %[[BINOP:.*]] = cir.binop(mul, %[[VSCALE]], %[[C8]]) nuw : !u64i |
| 58 |
|
| 59 |
// LLVM_OGCG_CIR: [[VSCALE:%.*]] = call i64 @llvm.vscale.i64() |
| 60 |
// LLVM_OGCG_CIR: [[RES:%.*]] = mul nuw i64 [[VSCALE]], 8 |
| 61 |
return SVE_ACLE_FUNC(svlen,_u16,,)(op); |
| 62 |
} |
| 63 |
|
| 64 |
// ALL-LABEL: @test_svlen_s16( |
| 65 |
uint64_t test_svlen_s16(svint16_t op) MODE_ATTR |
| 66 |
{ |
| 67 |
// CIR: %[[VSCALE:.*]] = cir.call_llvm_intrinsic "vscale" : () -> !u64i |
| 68 |
// CIR: %[[C8:.*]] = cir.const #cir.int<8> : !u64i |
| 69 |
// CIR: %[[BINOP:.*]] = cir.binop(mul, %[[VSCALE]], %[[C8]]) nuw : !u64i |
| 70 |
|
| 71 |
// LLVM_OGCG_CIR: [[VSCALE:%.*]] = call i64 @llvm.vscale.i64() |
| 72 |
// LLVM_OGCG_CIR: [[RES:%.*]] = mul nuw i64 [[VSCALE]], 8 |
| 73 |
return SVE_ACLE_FUNC(svlen,_s16,,)(op); |
| 74 |
} |
| 75 |
|
| 76 |
// ALL-LABEL: @test_svlen_f16( |
| 77 |
uint64_t test_svlen_f16(svfloat16_t op) MODE_ATTR |
| 78 |
{ |
| 79 |
// CIR: %[[VSCALE:.*]] = cir.call_llvm_intrinsic "vscale" : () -> !u64i |
| 80 |
// CIR: %[[C8:.*]] = cir.const #cir.int<8> : !u64i |
| 81 |
// CIR: %[[BINOP:.*]] = cir.binop(mul, %[[VSCALE]], %[[C8]]) nuw : !u64i |
| 82 |
|
| 83 |
// LLVM_OGCG_CIR: [[VSCALE:%.*]] = call i64 @llvm.vscale.i64() |
| 84 |
// LLVM_OGCG_CIR: [[RES:%.*]] = mul nuw i64 [[VSCALE]], 8 |
| 85 |
return SVE_ACLE_FUNC(svlen,_f16,,)(op); |
| 86 |
} |
| 87 |
|
| 88 |
// ALL-LABEL: @test_svlen_bf16( |
| 89 |
uint64_t test_svlen_bf16(svbfloat16_t op) MODE_ATTR |
| 90 |
{ |
| 91 |
// CIR: %[[VSCALE:.*]] = cir.call_llvm_intrinsic "vscale" : () -> !u64i |
| 92 |
// CIR: %[[C8:.*]] = cir.const #cir.int<8> : !u64i |
| 93 |
// CIR: %[[BINOP:.*]] = cir.binop(mul, %[[VSCALE]], %[[C8]]) nuw : !u64i |
| 94 |
|
| 95 |
// LLVM_OGCG_CIR: [[VSCALE:%.*]] = call i64 @llvm.vscale.i64() |
| 96 |
// LLVM_OGCG_CIR: [[RES:%.*]] = mul nuw i64 [[VSCALE]], 8 |
| 97 |
return SVE_ACLE_FUNC(svlen,_bf16,,)(op); |
| 98 |
} |
| 99 |
|
| 100 |
// ALL-LABEL: @test_svlen_u32( |
| 101 |
uint64_t test_svlen_u32(svuint32_t op) MODE_ATTR |
| 102 |
{ |
| 103 |
// CIR: %[[VSCALE:.*]] = cir.call_llvm_intrinsic "vscale" : () -> !u64i |
| 104 |
// CIR: %[[C4:.*]] = cir.const #cir.int<4> : !u64i |
| 105 |
// CIR: %[[BINOP:.*]] = cir.binop(mul, %[[VSCALE]], %[[C4]]) nuw : !u64i |
| 106 |
|
| 107 |
// LLVM_OGCG_CIR: [[VSCALE:%.*]] = call i64 @llvm.vscale.i64() |
| 108 |
// LLVM_OGCG_CIR: [[RES:%.*]] = mul nuw i64 [[VSCALE]], 4 |
| 109 |
return SVE_ACLE_FUNC(svlen,_u32,,)(op); |
| 110 |
} |
| 111 |
|
| 112 |
// ALL-LABEL: @test_svlen_s32( |
| 113 |
uint64_t test_svlen_s32(svint32_t op) MODE_ATTR |
| 114 |
{ |
| 115 |
// CIR: %[[VSCALE:.*]] = cir.call_llvm_intrinsic "vscale" : () -> !u64i |
| 116 |
// CIR: %[[C4:.*]] = cir.const #cir.int<4> : !u64i |
| 117 |
// CIR: %[[BINOP:.*]] = cir.binop(mul, %[[VSCALE]], %[[C4]]) nuw : !u64i |
| 118 |
|
| 119 |
// LLVM_OGCG_CIR: [[VSCALE:%.*]] = call i64 @llvm.vscale.i64() |
| 120 |
// LLVM_OGCG_CIR: [[RES:%.*]] = mul nuw i64 [[VSCALE]], 4 |
| 121 |
return SVE_ACLE_FUNC(svlen,_s32,,)(op); |
| 122 |
} |
| 123 |
|
| 124 |
// ALL-LABEL: @test_svlen_f32( |
| 125 |
uint64_t test_svlen_f32(svfloat32_t op) MODE_ATTR |
| 126 |
{ |
| 127 |
// CIR: %[[VSCALE:.*]] = cir.call_llvm_intrinsic "vscale" : () -> !u64i |
| 128 |
// CIR: %[[C4:.*]] = cir.const #cir.int<4> : !u64i |
| 129 |
// CIR: %[[BINOP:.*]] = cir.binop(mul, %[[VSCALE]], %[[C4]]) nuw : !u64i |
| 130 |
|
| 131 |
// LLVM_OGCG_CIR: [[VSCALE:%.*]] = call i64 @llvm.vscale.i64() |
| 132 |
// LLVM_OGCG_CIR: [[RES:%.*]] = mul nuw i64 [[VSCALE]], 4 |
| 133 |
return SVE_ACLE_FUNC(svlen,_f32,,)(op); |
| 134 |
} |
| 135 |
|
| 136 |
// ALL-LABEL: @test_svlen_u64( |
| 137 |
uint64_t test_svlen_u64(svuint64_t op) MODE_ATTR |
| 138 |
{ |
| 139 |
// CIR: %[[VSCALE:.*]] = cir.call_llvm_intrinsic "vscale" : () -> !u64i |
| 140 |
// CIR: %[[C2:.*]] = cir.const #cir.int<2> : !u64i |
| 141 |
// CIR: %[[BINOP:.*]] = cir.binop(mul, %[[VSCALE]], %[[C2]]) nuw : !u64i |
| 142 |
|
| 143 |
// LLVM_OGCG_CIR: [[VSCALE:%.*]] = call i64 @llvm.vscale.i64() |
| 144 |
// LLVM_OGCG_CIR: [[RES:%.*]] = mul nuw i64 [[VSCALE]], 2 |
| 145 |
return SVE_ACLE_FUNC(svlen,_u64,,)(op); |
| 146 |
} |
| 147 |
|
| 148 |
// ALL-LABEL: @test_svlen_s64 |
| 149 |
uint64_t test_svlen_s64(svint64_t op) MODE_ATTR |
| 150 |
{ |
| 151 |
// CIR: %[[VSCALE:.*]] = cir.call_llvm_intrinsic "vscale" : () -> !u64i |
| 152 |
// CIR: %[[C2:.*]] = cir.const #cir.int<2> : !u64i |
| 153 |
// CIR: %[[BINOP:.*]] = cir.binop(mul, %[[VSCALE]], %[[C2]]) nuw : !u64i |
| 154 |
|
| 155 |
// LLVM_OGCG_CIR: [[VSCALE:%.*]] = call i64 @llvm.vscale.i64() |
| 156 |
// LLVM_OGCG_CIR: [[RES:%.*]] = mul nuw i64 [[VSCALE]], 2 |
| 157 |
return SVE_ACLE_FUNC(svlen,_s64,,)(op); |
| 158 |
} |
| 159 |
|
| 160 |
// ALL-LABEL: @test_svlen_f64 |
| 161 |
uint64_t test_svlen_f64(svfloat64_t op) MODE_ATTR |
| 162 |
{ |
| 163 |
// CIR: %[[VSCALE:.*]] = cir.call_llvm_intrinsic "vscale" : () -> !u64i |
| 164 |
// CIR: %[[C2:.*]] = cir.const #cir.int<2> : !u64i |
| 165 |
// CIR: %[[BINOP:.*]] = cir.binop(mul, %[[VSCALE]], %[[C2]]) nuw : !u64i |
| 166 |
|
| 167 |
// LLVM_OGCG_CIR: [[VSCALE:%.*]] = call i64 @llvm.vscale.i64() |
| 168 |
// LLVM_OGCG_CIR: [[RES:%.*]] = mul nuw i64 [[VSCALE]], 2 |
| 169 |
return SVE_ACLE_FUNC(svlen,_f64,,)(op); |
| 170 |
} |