================ @@ -0,0 +1,194 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 4 +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -target-feature +fullbf16 -S -emit-llvm %s -o - | FileCheck %s +// CHECK-LABEL: define dso_local half @test_convert_from_bf16_to_fp16( +// CHECK-SAME: bfloat noundef [[A:%.*]]) #[[ATTR0:[0-9]+]] { +// CHECK-NEXT: entry: +// CHECK-NEXT: [[A_ADDR:%.*]] = alloca bfloat, align 2 +// CHECK-NEXT: store bfloat [[A]], ptr [[A_ADDR]], align 2 +// CHECK-NEXT: [[TMP0:%.*]] = load bfloat, ptr [[A_ADDR]], align 2 +// CHECK-NEXT: [[CONV:%.*]] = fpext bfloat [[TMP0]] to float +// CHECK-NEXT: [[CONV1:%.*]] = fptrunc float [[CONV]] to half +// CHECK-NEXT: ret half [[CONV1]] +// +_Float16 test_convert_from_bf16_to_fp16(__bf16 a) { + return (_Float16)a; +} + +// CHECK-LABEL: define dso_local bfloat @test_convert_from_fp16_to_bf16( +// CHECK-SAME: half noundef [[A:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: entry: +// CHECK-NEXT: [[A_ADDR:%.*]] = alloca half, align 2 +// CHECK-NEXT: store half [[A]], ptr [[A_ADDR]], align 2 +// CHECK-NEXT: [[TMP0:%.*]] = load half, ptr [[A_ADDR]], align 2 +// CHECK-NEXT: [[CONV:%.*]] = fpext half [[TMP0]] to float +// CHECK-NEXT: [[CONV1:%.*]] = fptrunc float [[CONV]] to bfloat +// CHECK-NEXT: ret bfloat [[CONV1]] +// +__bf16 test_convert_from_fp16_to_bf16(_Float16 a) { + return (__bf16)a; +} + +typedef _Float16 half2 __attribute__((ext_vector_type(2))); +typedef _Float16 half4 __attribute__((ext_vector_type(4))); + +typedef __bf16 bfloat2 __attribute__((ext_vector_type(2))); +typedef __bf16 bfloat4 __attribute__((ext_vector_type(4))); + +// CHECK-LABEL: define dso_local i32 @test_cast_from_fp162_to_bf162( +// CHECK-SAME: i32 noundef [[IN_COERCE:%.*]]) #[[ATTR0]] { +// CHECK-NEXT: entry: +// CHECK-NEXT: [[RETVAL:%.*]] = alloca <2 x bfloat>, align 4 +// CHECK-NEXT: [[IN:%.*]] = alloca <2 x half>, align 4 +// CHECK-NEXT: [[IN_ADDR:%.*]] = alloca <2 x half>, align 4 +// CHECK-NEXT: store i32 [[IN_COERCE]], ptr [[IN]], align 4 +// CHECK-NEXT: [[IN1:%.*]] = load <2 x half>, ptr [[IN]], align 4 +// CHECK-NEXT: store <2 x half> [[IN1]], ptr [[IN_ADDR]], align 4 +// CHECK-NEXT: [[TMP0:%.*]] = load <2 x half>, ptr [[IN_ADDR]], align 4 +// CHECK-NEXT: [[TMP1:%.*]] = bitcast <2 x half> [[TMP0]] to <2 x bfloat> ---------------- efriedma-quic wrote:
The CastKind in the AST is BitCast. This is inherited from old GNU vector_type semantics. Whether or not that's correct is orthogonal to this patch. https://github.com/llvm/llvm-project/pull/89051 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits