@@ -12,6 +12,7 @@ typedef unsigned int uvi4 __attribute__((vector_size(16)));
1212typedef float vf4 __attribute__ ((vector_size(16 )));
1313typedef double vd2 __attribute__ ((vector_size(16 )));
1414typedef long long vll2 __attribute__ ((vector_size(16 )));
15+ typedef _Float16 vh4 __attribute__ ((vector_size(8 )));
1516
1617vi4 vec_a;
1718// CIR: cir.global external @[[VEC_A:.*]] = #cir.zero : !cir.vector<4 x !s32i>
@@ -1259,6 +1260,45 @@ void foo25() {
12591260// OGCG: %[[RESULT:.*]] = sext <4 x i1> %[[VEC_OR]] to <4 x i32>
12601261// OGCG: store <4 x i32> %[[RESULT]], ptr %[[C_ADDR]], align 16
12611262
1263+ void foo27 () {
1264+ vh4 a;
1265+ vh4 b;
1266+ vh4 c = a + b;
1267+ }
1268+
1269+ // CIR: %[[A_ADDR:.*]] = cir.alloca !cir.vector<4 x !cir.f16>, !cir.ptr<!cir.vector<4 x !cir.f16>>, ["a"]
1270+ // CIR: %[[B_ADDR:.*]] = cir.alloca !cir.vector<4 x !cir.f16>, !cir.ptr<!cir.vector<4 x !cir.f16>>, ["b"]
1271+ // CIR: %[[C_ADDR:.*]] = cir.alloca !cir.vector<4 x !cir.f16>, !cir.ptr<!cir.vector<4 x !cir.f16>>, ["c", init]
1272+ // CIR: %[[TMP_A:.*]] = cir.load{{.*}} %[[A_ADDR]] : !cir.ptr<!cir.vector<4 x !cir.f16>>, !cir.vector<4 x !cir.f16>
1273+ // CIR: %[[TMP_A_F16:.*]] = cir.cast(floating, %[[TMP_A]] : !cir.vector<4 x !cir.f16>), !cir.vector<4 x !cir.float>
1274+ // CIR: %[[TMP_B:.*]] = cir.load{{.*}} %[[B_ADDR]] : !cir.ptr<!cir.vector<4 x !cir.f16>>, !cir.vector<4 x !cir.f16>
1275+ // CIR: %[[TMP_B_F16:.*]] = cir.cast(floating, %[[TMP_B]] : !cir.vector<4 x !cir.f16>), !cir.vector<4 x !cir.float>
1276+ // CIR: %[[RESULT:.*]] = cir.binop(add, %[[TMP_A_F16]], %[[TMP_B_F16]]) : !cir.vector<4 x !cir.float>
1277+ // CIR: %[[RESULT_VF16:.*]] = cir.cast(floating, %[[RESULT]] : !cir.vector<4 x !cir.float>), !cir.vector<4 x !cir.f16>
1278+ // CIR: cir.store{{.*}} %[[RESULT_VF16]], %[[C_ADDR]] : !cir.vector<4 x !cir.f16>, !cir.ptr<!cir.vector<4 x !cir.f16>>
1279+
1280+ // LLVM: %[[A_ADDR:.*]] = alloca <4 x half>, i64 1, align 8
1281+ // LLVM: %[[B_ADDR:.*]] = alloca <4 x half>, i64 1, align 8
1282+ // LLVM: %[[C_ADDR:.*]] = alloca <4 x half>, i64 1, align 8
1283+ // LLVM: %[[TMP_A:.*]] = load <4 x half>, ptr %[[A_ADDR]], align 8
1284+ // LLVM: %[[TMP_A_F16:.*]] = fpext <4 x half> %[[TMP_A]] to <4 x float>
1285+ // LLVM: %[[TMP_B:.*]] = load <4 x half>, ptr %[[B_ADDR]], align 8
1286+ // LLVM: %[[TMP_B_F16:.*]] = fpext <4 x half> %[[TMP_B]] to <4 x float>
1287+ // LLVM: %[[RESULT:.*]] = fadd <4 x float> %[[TMP_A_F16]], %[[TMP_B_F16]]
1288+ // LLVM: %[[RESULT_VF16:.*]] = fptrunc <4 x float> %[[RESULT]] to <4 x half>
1289+ // LLVM: store <4 x half> %[[RESULT_VF16]], ptr %[[C_ADDR]], align 8
1290+
1291+ // OGCG: %[[A_ADDR:.*]] = alloca <4 x half>, align 8
1292+ // OGCG: %[[B_ADDR:.*]] = alloca <4 x half>, align 8
1293+ // OGCG: %[[C_ADDR:.*]] = alloca <4 x half>, align 8
1294+ // OGCG: %[[TMP_A:.*]] = load <4 x half>, ptr %[[A_ADDR]], align 8
1295+ // OGCG: %[[TMP_A_F16:.*]] = fpext <4 x half> %[[TMP_A]] to <4 x float>
1296+ // OGCG: %[[TMP_B:.*]] = load <4 x half>, ptr %[[B_ADDR]], align 8
1297+ // OGCG: %[[TMP_B_F16:.*]] = fpext <4 x half> %[[TMP_B]] to <4 x float>
1298+ // OGCG: %[[RESULT:.*]] = fadd <4 x float> %[[TMP_A_F16]], %[[TMP_B_F16]]
1299+ // OGCG: %[[RESULT_VF16:.*]] = fptrunc <4 x float> %[[RESULT]] to <4 x half>
1300+ // OGCG: store <4 x half> %[[RESULT_VF16]], ptr %[[C_ADDR]], align 8
1301+
12621302void foo26 () {
12631303 vi4 a;
12641304 vi4 b;
@@ -1297,4 +1337,4 @@ void foo26() {
12971337// OGCG: %[[NE_B_ZERO:.*]] = icmp ne <4 x i32> %[[TMP_B]], zeroinitializer
12981338// OGCG: %[[VEC_OR:.*]] = and <4 x i1> %[[NE_A_ZERO]], %[[NE_B_ZERO]]
12991339// OGCG: %[[RESULT:.*]] = sext <4 x i1> %[[VEC_OR]] to <4 x i32>
1300- // OGCG: store <4 x i32> %[[RESULT]], ptr %[[C_ADDR]], align 16
1340+ // OGCG: store <4 x i32> %[[RESULT]], ptr %[[C_ADDR]], align 16
0 commit comments