[LLVM][IR] Use splat syntax when printing ConstantExpr based splats. (#116856)
[llvm-project.git] / clang / test / CodeGen / X86 / bfloat16-convert-half.c
blob55451dc6f092cd8df1c778745a2e09f1627ae591
1 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -disable-O0-optnone -emit-llvm \
2 // RUN: %s -o - | opt -S -passes=mem2reg | FileCheck %s
4 // CHECK-LABEL: define dso_local half @test_convert_from_bf16_to_fp16(
5 // CHECK-SAME: bfloat noundef [[A:%.*]]) #[[ATTR0:[0-9]+]] {
6 // CHECK-NEXT: entry:
7 // CHECK-NEXT: [[FPEXT:%.*]] = fpext bfloat [[A]] to float
8 // CHECK-NEXT: [[FPTRUNC:%.*]] = fptrunc float [[FPEXT]] to half
9 // CHECK-NEXT: ret half [[FPTRUNC]]
11 _Float16 test_convert_from_bf16_to_fp16(__bf16 a) {
12 return (_Float16)a;
15 // CHECK-LABEL: define dso_local bfloat @test_convert_from_fp16_to_bf16(
16 // CHECK-SAME: half noundef [[A:%.*]]) #[[ATTR0]] {
17 // CHECK-NEXT: entry:
18 // CHECK-NEXT: [[FPEXT:%.*]] = fpext half [[A]] to float
19 // CHECK-NEXT: [[FPTRUNC:%.*]] = fptrunc float [[FPEXT]] to bfloat
20 // CHECK-NEXT: ret bfloat [[FPTRUNC]]
22 __bf16 test_convert_from_fp16_to_bf16(_Float16 a) {
23 return (__bf16)a;