Files
clang-p2996/clang/test/CodeGen/X86/fexcess-precision-bfloat16.c
M. Zeeshan Siddiqui e621757365 [Clang][BFloat16] Upgrade __bf16 to arithmetic type, change mangling, and extend excess precision support
Pursuant to discussions at
https://discourse.llvm.org/t/rfc-c-23-p1467r9-extended-floating-point-types-and-standard-names/70033/22,
this commit enhances the handling of the __bf16 type in Clang.
- Firstly, it upgrades __bf16 from a storage-only type to an arithmetic
  type.
- Secondly, it changes the mangling of __bf16 to DF16b on all
  architectures except ARM. This change has been made in
  accordance with the finalization of the mangling for the
  std::bfloat16_t type, as discussed at
  https://github.com/itanium-cxx-abi/cxx-abi/pull/147.
- Finally, this commit extends the existing excess precision support to
  the __bf16 type. This applies to hardware architectures that do not
  natively support bfloat16 arithmetic.
Appropriate tests have been added to verify the effects of these
changes and ensure no regressions in other areas of the compiler.

Reviewed By: rjmccall, pengfei, zahiraam

Differential Revision: https://reviews.llvm.org/D150913
2023-05-27 13:33:50 +08:00

361 lines
20 KiB
C

// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2
// RUN: %clang_cc1 -triple x86_64-unknown-unknown \
// RUN: -fbfloat16-excess-precision=fast -emit-llvm -o - %s \
// RUN: | FileCheck -check-prefixes=CHECK-EXT %s
// RUN: %clang_cc1 -triple x86_64-unknown-unknown \
// RUN: -fbfloat16-excess-precision=fast -target-feature +fullbf16 \
// RUN: -emit-llvm -o - %s | FileCheck -check-prefixes=CHECK-NO-EXT %s
// RUN: %clang_cc1 -triple x86_64-unknown-unknown \
// RUN: -fbfloat16-excess-precision=standard -emit-llvm -o - %s \
// RUN: | FileCheck -check-prefixes=CHECK-EXT %s
// RUN: %clang_cc1 -triple x86_64-unknown-unknown \
// RUN: -fbfloat16-excess-precision=standard -target-feature +fullbf16 \
// RUN: -emit-llvm -o - %s | FileCheck -check-prefixes=CHECK-NO-EXT %s
// RUN: %clang_cc1 -triple x86_64-unknown-unknown \
// RUN: -fbfloat16-excess-precision=none -emit-llvm -o - %s \
// RUN: | FileCheck -check-prefixes=CHECK-NO-EXT %s
// RUN: %clang_cc1 -triple x86_64-unknown-unknown \
// RUN: -fbfloat16-excess-precision=none -target-feature +fullbf16 \
// RUN: -emit-llvm -o - %s \
// RUN: | FileCheck -check-prefixes=CHECK-NO-EXT %s
// RUN: %clang_cc1 -triple x86_64-unknown-unknown \
// RUN: -fbfloat16-excess-precision=fast \
// RUN: -emit-llvm -ffp-eval-method=source -o - %s \
// RUN: | FileCheck -check-prefixes=CHECK-EXT %s
// RUN: %clang_cc1 -triple x86_64-unknown-unknown \
// RUN: -fbfloat16-excess-precision=fast -target-feature +fullbf16 \
// RUN: -emit-llvm -ffp-eval-method=source -o - %s \
// RUN: | FileCheck -check-prefixes=CHECK-NO-EXT %s
// RUN: %clang_cc1 -triple x86_64-unknown-unknown \
// RUN: -fbfloat16-excess-precision=standard \
// RUN: -emit-llvm -ffp-eval-method=source -o - %s \
// RUN: | FileCheck -check-prefixes=CHECK-EXT %s
// RUN: %clang_cc1 -triple x86_64-unknown-unknown \
// RUN: -fbfloat16-excess-precision=standard -target-feature +fullbf16 \
// RUN: -emit-llvm -ffp-eval-method=source -o - %s \
// RUN: | FileCheck -check-prefixes=CHECK-NO-EXT %s
// RUN: %clang_cc1 -triple x86_64-unknown-unknown \
// RUN: -fbfloat16-excess-precision=none \
// RUN: -emit-llvm -ffp-eval-method=source -o - %s \
// RUN: | FileCheck -check-prefixes=CHECK-NO-EXT %s
// RUN: %clang_cc1 -triple x86_64-unknown-unknown \
// RUN: -fbfloat16-excess-precision=none -target-feature +fullbf16 \
// RUN: -emit-llvm -ffp-eval-method=source -o - %s \
// RUN: | FileCheck -check-prefixes=CHECK-NO-EXT %s
// RUN: %clang_cc1 -triple x86_64-unknown-unknown \
// RUN: -fbfloat16-excess-precision=fast \
// RUN: -emit-llvm -ffp-eval-method=double -o - %s \
// RUN: | FileCheck -check-prefixes=CHECK-EXT-DBL %s
// RUN: %clang_cc1 -triple x86_64-unknown-unknown \
// RUN: -fbfloat16-excess-precision=fast -target-feature +fullbf16 \
// RUN: -emit-llvm -ffp-eval-method=double -o - %s \
// RUN: | FileCheck -check-prefixes=CHECK-EXT-DBL %s
// RUN: %clang_cc1 -triple x86_64-unknown-unknown \
// RUN: -fbfloat16-excess-precision=standard \
// RUN: -emit-llvm -ffp-eval-method=double -o - %s \
// RUN: | FileCheck -check-prefixes=CHECK-EXT-DBL %s
// RUN: %clang_cc1 -triple x86_64-unknown-unknown \
// RUN: -fbfloat16-excess-precision=standard -target-feature +fullbf16 \
// RUN: -emit-llvm -ffp-eval-method=double -o - %s \
// RUN: | FileCheck -check-prefixes=CHECK-EXT-DBL %s
// RUN: %clang_cc1 -triple x86_64-unknown-unknown \
// RUN: -fbfloat16-excess-precision=none \
// RUN: -emit-llvm -ffp-eval-method=double -o - %s \
// RUN: | FileCheck -check-prefixes=CHECK-EXT-DBL %s
// RUN: %clang_cc1 -triple x86_64-unknown-unknown \
// RUN: -fbfloat16-excess-precision=none -target-feature +fullbf16 \
// RUN: -emit-llvm -ffp-eval-method=double -o - %s \
// RUN: | FileCheck -check-prefixes=CHECK-EXT-DBL %s
// RUN: %clang_cc1 -triple x86_64-unknown-unknown \
// RUN: -fbfloat16-excess-precision=fast \
// RUN: -emit-llvm -ffp-eval-method=extended -o - %s \
// RUN: | FileCheck -check-prefixes=CHECK-EXT-FP80 %s
// RUN: %clang_cc1 -triple x86_64-unknown-unknown \
// RUN: -fbfloat16-excess-precision=fast -target-feature +fullbf16 \
// RUN: -emit-llvm -ffp-eval-method=extended -o - %s \
// RUN: | FileCheck -check-prefixes=CHECK-EXT-FP80 %s
// RUN: %clang_cc1 -triple x86_64-unknown-unknown \
// RUN: -fbfloat16-excess-precision=standard \
// RUN: -emit-llvm -ffp-eval-method=extended -o - %s \
// RUN: | FileCheck -check-prefixes=CHECK-EXT-FP80 %s
// RUN: %clang_cc1 -triple x86_64-unknown-unknown \
// RUN: -fbfloat16-excess-precision=standard -target-feature +fullbf16 \
// RUN: -emit-llvm -ffp-eval-method=extended -o - %s \
// RUN: | FileCheck -check-prefixes=CHECK-EXT-FP80 %s
// RUN: %clang_cc1 -triple x86_64-unknown-unknown \
// RUN: -fbfloat16-excess-precision=none \
// RUN: -emit-llvm -ffp-eval-method=extended -o - %s \
// RUN: | FileCheck -check-prefixes=CHECK-EXT-FP80 %s
// RUN: %clang_cc1 -triple x86_64-unknown-unknown \
// RUN: -fbfloat16-excess-precision=none -target-feature +fullbf16 \
// RUN: -emit-llvm -ffp-eval-method=extended -o - %s \
// RUN: | FileCheck -check-prefixes=CHECK-EXT-FP80 %s
// RUN: %clang_cc1 -triple x86_64-unknown-unknown \
// RUN: -fbfloat16-excess-precision=none \
// RUN: -ffp-contract=on -emit-llvm -o - %s \
// RUN: | FileCheck -check-prefixes=CHECK-CONTRACT %s
// RUN: %clang_cc1 -triple x86_64-unknown-unknown \
// RUN: -fbfloat16-excess-precision=none -target-feature +fullbf16 \
// RUN: -ffp-contract=on -emit-llvm -o - %s \
// RUN: | FileCheck -check-prefixes=CHECK-CONTRACT %s
// RUN: %clang_cc1 -triple x86_64-unknown-unknown \
// RUN: -fbfloat16-excess-precision=none \
// RUN: -fmath-errno -ffp-contract=on -fno-rounding-math \
// RUN: -ffp-eval-method=source -emit-llvm -o - %s \
// RUN: | FileCheck -check-prefixes=CHECK-CONTRACT %s
// RUN: %clang_cc1 -triple x86_64-unknown-unknown \
// RUN: -fbfloat16-excess-precision=none -target-feature +fullbf16 \
// RUN: -fmath-errno -ffp-contract=on -fno-rounding-math \
// RUN: -ffp-eval-method=source -emit-llvm -o - %s \
// RUN: | FileCheck -check-prefixes=CHECK-CONTRACT %s
// RUN: %clang_cc1 -triple x86_64-unknown-unknown \
// RUN: -fbfloat16-excess-precision=none \
// RUN: -fmath-errno -ffp-contract=on -fno-rounding-math \
// RUN: -ffp-eval-method=double -emit-llvm -o - %s \
// RUN: | FileCheck -check-prefixes=CHECK-CONTRACT-DBL %s
// RUN: %clang_cc1 -triple x86_64-unknown-unknown \
// RUN: -fbfloat16-excess-precision=none -target-feature +fullbf16 \
// RUN: -fmath-errno -ffp-contract=on -fno-rounding-math \
// RUN: -ffp-eval-method=double -emit-llvm -o - %s \
// RUN: | FileCheck -check-prefixes=CHECK-CONTRACT-DBL %s
// RUN: %clang_cc1 -triple x86_64-unknown-unknown \
// RUN: -fbfloat16-excess-precision=none \
// RUN: -fmath-errno -ffp-contract=on -fno-rounding-math \
// RUN: -ffp-eval-method=extended -emit-llvm -o - %s \
// RUN: | FileCheck -check-prefixes=CHECK-CONTRACT-EXT %s
// RUN: %clang_cc1 -triple x86_64-unknown-unknown \
// RUN: -fbfloat16-excess-precision=none -target-feature +fullbf16 \
// RUN: -fmath-errno -ffp-contract=on -fno-rounding-math \
// RUN: -ffp-eval-method=extended -emit-llvm -o - %s \
// RUN: | FileCheck -check-prefixes=CHECK-CONTRACT-EXT %s
// RUN: %clang_cc1 -triple x86_64-unknown-unknown \
// RUN: -fbfloat16-excess-precision=none \
// RUN: -fapprox-func -fmath-errno -fno-signed-zeros -mreassociate \
// RUN: -freciprocal-math -ffp-contract=on -fno-rounding-math \
// RUN: -funsafe-math-optimizations -emit-llvm -o - %s \
// RUN: | FileCheck -check-prefixes=CHECK-UNSAFE %s
// RUN: %clang_cc1 -triple x86_64-unknown-unknown \
// RUN: -fbfloat16-excess-precision=none -target-feature +fullbf16 \
// RUN: -fapprox-func -fmath-errno -fno-signed-zeros -mreassociate \
// RUN: -freciprocal-math -ffp-contract=on -fno-rounding-math \
// RUN: -funsafe-math-optimizations -emit-llvm -o - %s \
// RUN: | FileCheck -check-prefixes=CHECK-UNSAFE %s
// CHECK-EXT-LABEL: define dso_local bfloat @f
// CHECK-EXT-SAME: (bfloat noundef [[A:%.*]], bfloat noundef [[B:%.*]], bfloat noundef [[C:%.*]], bfloat noundef [[D:%.*]]) #[[ATTR0:[0-9]+]] {
// CHECK-EXT-NEXT: entry:
// CHECK-EXT-NEXT: [[A_ADDR:%.*]] = alloca bfloat, align 2
// CHECK-EXT-NEXT: [[B_ADDR:%.*]] = alloca bfloat, align 2
// CHECK-EXT-NEXT: [[C_ADDR:%.*]] = alloca bfloat, align 2
// CHECK-EXT-NEXT: [[D_ADDR:%.*]] = alloca bfloat, align 2
// CHECK-EXT-NEXT: store bfloat [[A]], ptr [[A_ADDR]], align 2
// CHECK-EXT-NEXT: store bfloat [[B]], ptr [[B_ADDR]], align 2
// CHECK-EXT-NEXT: store bfloat [[C]], ptr [[C_ADDR]], align 2
// CHECK-EXT-NEXT: store bfloat [[D]], ptr [[D_ADDR]], align 2
// CHECK-EXT-NEXT: [[TMP0:%.*]] = load bfloat, ptr [[A_ADDR]], align 2
// CHECK-EXT-NEXT: [[EXT:%.*]] = fpext bfloat [[TMP0]] to float
// CHECK-EXT-NEXT: [[TMP1:%.*]] = load bfloat, ptr [[B_ADDR]], align 2
// CHECK-EXT-NEXT: [[EXT1:%.*]] = fpext bfloat [[TMP1]] to float
// CHECK-EXT-NEXT: [[MUL:%.*]] = fmul float [[EXT]], [[EXT1]]
// CHECK-EXT-NEXT: [[TMP2:%.*]] = load bfloat, ptr [[C_ADDR]], align 2
// CHECK-EXT-NEXT: [[EXT2:%.*]] = fpext bfloat [[TMP2]] to float
// CHECK-EXT-NEXT: [[TMP3:%.*]] = load bfloat, ptr [[D_ADDR]], align 2
// CHECK-EXT-NEXT: [[EXT3:%.*]] = fpext bfloat [[TMP3]] to float
// CHECK-EXT-NEXT: [[MUL4:%.*]] = fmul float [[EXT2]], [[EXT3]]
// CHECK-EXT-NEXT: [[ADD:%.*]] = fadd float [[MUL]], [[MUL4]]
// CHECK-EXT-NEXT: [[UNPROMOTION:%.*]] = fptrunc float [[ADD]] to bfloat
// CHECK-EXT-NEXT: ret bfloat [[UNPROMOTION]]
//
// CHECK-NO-EXT-LABEL: define dso_local bfloat @f
// CHECK-NO-EXT-SAME: (bfloat noundef [[A:%.*]], bfloat noundef [[B:%.*]], bfloat noundef [[C:%.*]], bfloat noundef [[D:%.*]]) #[[ATTR0:[0-9]+]] {
// CHECK-NO-EXT-NEXT: entry:
// CHECK-NO-EXT-NEXT: [[A_ADDR:%.*]] = alloca bfloat, align 2
// CHECK-NO-EXT-NEXT: [[B_ADDR:%.*]] = alloca bfloat, align 2
// CHECK-NO-EXT-NEXT: [[C_ADDR:%.*]] = alloca bfloat, align 2
// CHECK-NO-EXT-NEXT: [[D_ADDR:%.*]] = alloca bfloat, align 2
// CHECK-NO-EXT-NEXT: store bfloat [[A]], ptr [[A_ADDR]], align 2
// CHECK-NO-EXT-NEXT: store bfloat [[B]], ptr [[B_ADDR]], align 2
// CHECK-NO-EXT-NEXT: store bfloat [[C]], ptr [[C_ADDR]], align 2
// CHECK-NO-EXT-NEXT: store bfloat [[D]], ptr [[D_ADDR]], align 2
// CHECK-NO-EXT-NEXT: [[TMP0:%.*]] = load bfloat, ptr [[A_ADDR]], align 2
// CHECK-NO-EXT-NEXT: [[TMP1:%.*]] = load bfloat, ptr [[B_ADDR]], align 2
// CHECK-NO-EXT-NEXT: [[MUL:%.*]] = fmul bfloat [[TMP0]], [[TMP1]]
// CHECK-NO-EXT-NEXT: [[TMP2:%.*]] = load bfloat, ptr [[C_ADDR]], align 2
// CHECK-NO-EXT-NEXT: [[TMP3:%.*]] = load bfloat, ptr [[D_ADDR]], align 2
// CHECK-NO-EXT-NEXT: [[MUL1:%.*]] = fmul bfloat [[TMP2]], [[TMP3]]
// CHECK-NO-EXT-NEXT: [[ADD:%.*]] = fadd bfloat [[MUL]], [[MUL1]]
// CHECK-NO-EXT-NEXT: ret bfloat [[ADD]]
//
// CHECK-EXT-DBL-LABEL: define dso_local bfloat @f
// CHECK-EXT-DBL-SAME: (bfloat noundef [[A:%.*]], bfloat noundef [[B:%.*]], bfloat noundef [[C:%.*]], bfloat noundef [[D:%.*]]) #[[ATTR0:[0-9]+]] {
// CHECK-EXT-DBL-NEXT: entry:
// CHECK-EXT-DBL-NEXT: [[A_ADDR:%.*]] = alloca bfloat, align 2
// CHECK-EXT-DBL-NEXT: [[B_ADDR:%.*]] = alloca bfloat, align 2
// CHECK-EXT-DBL-NEXT: [[C_ADDR:%.*]] = alloca bfloat, align 2
// CHECK-EXT-DBL-NEXT: [[D_ADDR:%.*]] = alloca bfloat, align 2
// CHECK-EXT-DBL-NEXT: store bfloat [[A]], ptr [[A_ADDR]], align 2
// CHECK-EXT-DBL-NEXT: store bfloat [[B]], ptr [[B_ADDR]], align 2
// CHECK-EXT-DBL-NEXT: store bfloat [[C]], ptr [[C_ADDR]], align 2
// CHECK-EXT-DBL-NEXT: store bfloat [[D]], ptr [[D_ADDR]], align 2
// CHECK-EXT-DBL-NEXT: [[TMP0:%.*]] = load bfloat, ptr [[A_ADDR]], align 2
// CHECK-EXT-DBL-NEXT: [[CONV:%.*]] = fpext bfloat [[TMP0]] to double
// CHECK-EXT-DBL-NEXT: [[TMP1:%.*]] = load bfloat, ptr [[B_ADDR]], align 2
// CHECK-EXT-DBL-NEXT: [[CONV1:%.*]] = fpext bfloat [[TMP1]] to double
// CHECK-EXT-DBL-NEXT: [[MUL:%.*]] = fmul double [[CONV]], [[CONV1]]
// CHECK-EXT-DBL-NEXT: [[TMP2:%.*]] = load bfloat, ptr [[C_ADDR]], align 2
// CHECK-EXT-DBL-NEXT: [[CONV2:%.*]] = fpext bfloat [[TMP2]] to double
// CHECK-EXT-DBL-NEXT: [[TMP3:%.*]] = load bfloat, ptr [[D_ADDR]], align 2
// CHECK-EXT-DBL-NEXT: [[CONV3:%.*]] = fpext bfloat [[TMP3]] to double
// CHECK-EXT-DBL-NEXT: [[MUL4:%.*]] = fmul double [[CONV2]], [[CONV3]]
// CHECK-EXT-DBL-NEXT: [[ADD:%.*]] = fadd double [[MUL]], [[MUL4]]
// CHECK-EXT-DBL-NEXT: [[CONV5:%.*]] = fptrunc double [[ADD]] to bfloat
// CHECK-EXT-DBL-NEXT: ret bfloat [[CONV5]]
//
// CHECK-EXT-FP80-LABEL: define dso_local bfloat @f
// CHECK-EXT-FP80-SAME: (bfloat noundef [[A:%.*]], bfloat noundef [[B:%.*]], bfloat noundef [[C:%.*]], bfloat noundef [[D:%.*]]) #[[ATTR0:[0-9]+]] {
// CHECK-EXT-FP80-NEXT: entry:
// CHECK-EXT-FP80-NEXT: [[A_ADDR:%.*]] = alloca bfloat, align 2
// CHECK-EXT-FP80-NEXT: [[B_ADDR:%.*]] = alloca bfloat, align 2
// CHECK-EXT-FP80-NEXT: [[C_ADDR:%.*]] = alloca bfloat, align 2
// CHECK-EXT-FP80-NEXT: [[D_ADDR:%.*]] = alloca bfloat, align 2
// CHECK-EXT-FP80-NEXT: store bfloat [[A]], ptr [[A_ADDR]], align 2
// CHECK-EXT-FP80-NEXT: store bfloat [[B]], ptr [[B_ADDR]], align 2
// CHECK-EXT-FP80-NEXT: store bfloat [[C]], ptr [[C_ADDR]], align 2
// CHECK-EXT-FP80-NEXT: store bfloat [[D]], ptr [[D_ADDR]], align 2
// CHECK-EXT-FP80-NEXT: [[TMP0:%.*]] = load bfloat, ptr [[A_ADDR]], align 2
// CHECK-EXT-FP80-NEXT: [[CONV:%.*]] = fpext bfloat [[TMP0]] to x86_fp80
// CHECK-EXT-FP80-NEXT: [[TMP1:%.*]] = load bfloat, ptr [[B_ADDR]], align 2
// CHECK-EXT-FP80-NEXT: [[CONV1:%.*]] = fpext bfloat [[TMP1]] to x86_fp80
// CHECK-EXT-FP80-NEXT: [[MUL:%.*]] = fmul x86_fp80 [[CONV]], [[CONV1]]
// CHECK-EXT-FP80-NEXT: [[TMP2:%.*]] = load bfloat, ptr [[C_ADDR]], align 2
// CHECK-EXT-FP80-NEXT: [[CONV2:%.*]] = fpext bfloat [[TMP2]] to x86_fp80
// CHECK-EXT-FP80-NEXT: [[TMP3:%.*]] = load bfloat, ptr [[D_ADDR]], align 2
// CHECK-EXT-FP80-NEXT: [[CONV3:%.*]] = fpext bfloat [[TMP3]] to x86_fp80
// CHECK-EXT-FP80-NEXT: [[MUL4:%.*]] = fmul x86_fp80 [[CONV2]], [[CONV3]]
// CHECK-EXT-FP80-NEXT: [[ADD:%.*]] = fadd x86_fp80 [[MUL]], [[MUL4]]
// CHECK-EXT-FP80-NEXT: [[CONV5:%.*]] = fptrunc x86_fp80 [[ADD]] to bfloat
// CHECK-EXT-FP80-NEXT: ret bfloat [[CONV5]]
//
// CHECK-CONTRACT-LABEL: define dso_local bfloat @f
// CHECK-CONTRACT-SAME: (bfloat noundef [[A:%.*]], bfloat noundef [[B:%.*]], bfloat noundef [[C:%.*]], bfloat noundef [[D:%.*]]) #[[ATTR0:[0-9]+]] {
// CHECK-CONTRACT-NEXT: entry:
// CHECK-CONTRACT-NEXT: [[A_ADDR:%.*]] = alloca bfloat, align 2
// CHECK-CONTRACT-NEXT: [[B_ADDR:%.*]] = alloca bfloat, align 2
// CHECK-CONTRACT-NEXT: [[C_ADDR:%.*]] = alloca bfloat, align 2
// CHECK-CONTRACT-NEXT: [[D_ADDR:%.*]] = alloca bfloat, align 2
// CHECK-CONTRACT-NEXT: store bfloat [[A]], ptr [[A_ADDR]], align 2
// CHECK-CONTRACT-NEXT: store bfloat [[B]], ptr [[B_ADDR]], align 2
// CHECK-CONTRACT-NEXT: store bfloat [[C]], ptr [[C_ADDR]], align 2
// CHECK-CONTRACT-NEXT: store bfloat [[D]], ptr [[D_ADDR]], align 2
// CHECK-CONTRACT-NEXT: [[TMP0:%.*]] = load bfloat, ptr [[A_ADDR]], align 2
// CHECK-CONTRACT-NEXT: [[TMP1:%.*]] = load bfloat, ptr [[B_ADDR]], align 2
// CHECK-CONTRACT-NEXT: [[TMP2:%.*]] = load bfloat, ptr [[C_ADDR]], align 2
// CHECK-CONTRACT-NEXT: [[TMP3:%.*]] = load bfloat, ptr [[D_ADDR]], align 2
// CHECK-CONTRACT-NEXT: [[MUL1:%.*]] = fmul bfloat [[TMP2]], [[TMP3]]
// CHECK-CONTRACT-NEXT: [[TMP4:%.*]] = call bfloat @llvm.fmuladd.bf16(bfloat [[TMP0]], bfloat [[TMP1]], bfloat [[MUL1]])
// CHECK-CONTRACT-NEXT: ret bfloat [[TMP4]]
//
// CHECK-CONTRACT-DBL-LABEL: define dso_local bfloat @f
// CHECK-CONTRACT-DBL-SAME: (bfloat noundef [[A:%.*]], bfloat noundef [[B:%.*]], bfloat noundef [[C:%.*]], bfloat noundef [[D:%.*]]) #[[ATTR0:[0-9]+]] {
// CHECK-CONTRACT-DBL-NEXT: entry:
// CHECK-CONTRACT-DBL-NEXT: [[A_ADDR:%.*]] = alloca bfloat, align 2
// CHECK-CONTRACT-DBL-NEXT: [[B_ADDR:%.*]] = alloca bfloat, align 2
// CHECK-CONTRACT-DBL-NEXT: [[C_ADDR:%.*]] = alloca bfloat, align 2
// CHECK-CONTRACT-DBL-NEXT: [[D_ADDR:%.*]] = alloca bfloat, align 2
// CHECK-CONTRACT-DBL-NEXT: store bfloat [[A]], ptr [[A_ADDR]], align 2
// CHECK-CONTRACT-DBL-NEXT: store bfloat [[B]], ptr [[B_ADDR]], align 2
// CHECK-CONTRACT-DBL-NEXT: store bfloat [[C]], ptr [[C_ADDR]], align 2
// CHECK-CONTRACT-DBL-NEXT: store bfloat [[D]], ptr [[D_ADDR]], align 2
// CHECK-CONTRACT-DBL-NEXT: [[TMP0:%.*]] = load bfloat, ptr [[A_ADDR]], align 2
// CHECK-CONTRACT-DBL-NEXT: [[CONV:%.*]] = fpext bfloat [[TMP0]] to double
// CHECK-CONTRACT-DBL-NEXT: [[TMP1:%.*]] = load bfloat, ptr [[B_ADDR]], align 2
// CHECK-CONTRACT-DBL-NEXT: [[CONV1:%.*]] = fpext bfloat [[TMP1]] to double
// CHECK-CONTRACT-DBL-NEXT: [[TMP2:%.*]] = load bfloat, ptr [[C_ADDR]], align 2
// CHECK-CONTRACT-DBL-NEXT: [[CONV2:%.*]] = fpext bfloat [[TMP2]] to double
// CHECK-CONTRACT-DBL-NEXT: [[TMP3:%.*]] = load bfloat, ptr [[D_ADDR]], align 2
// CHECK-CONTRACT-DBL-NEXT: [[CONV3:%.*]] = fpext bfloat [[TMP3]] to double
// CHECK-CONTRACT-DBL-NEXT: [[MUL4:%.*]] = fmul double [[CONV2]], [[CONV3]]
// CHECK-CONTRACT-DBL-NEXT: [[TMP4:%.*]] = call double @llvm.fmuladd.f64(double [[CONV]], double [[CONV1]], double [[MUL4]])
// CHECK-CONTRACT-DBL-NEXT: [[CONV5:%.*]] = fptrunc double [[TMP4]] to bfloat
// CHECK-CONTRACT-DBL-NEXT: ret bfloat [[CONV5]]
//
// CHECK-CONTRACT-EXT-LABEL: define dso_local bfloat @f
// CHECK-CONTRACT-EXT-SAME: (bfloat noundef [[A:%.*]], bfloat noundef [[B:%.*]], bfloat noundef [[C:%.*]], bfloat noundef [[D:%.*]]) #[[ATTR0:[0-9]+]] {
// CHECK-CONTRACT-EXT-NEXT: entry:
// CHECK-CONTRACT-EXT-NEXT: [[A_ADDR:%.*]] = alloca bfloat, align 2
// CHECK-CONTRACT-EXT-NEXT: [[B_ADDR:%.*]] = alloca bfloat, align 2
// CHECK-CONTRACT-EXT-NEXT: [[C_ADDR:%.*]] = alloca bfloat, align 2
// CHECK-CONTRACT-EXT-NEXT: [[D_ADDR:%.*]] = alloca bfloat, align 2
// CHECK-CONTRACT-EXT-NEXT: store bfloat [[A]], ptr [[A_ADDR]], align 2
// CHECK-CONTRACT-EXT-NEXT: store bfloat [[B]], ptr [[B_ADDR]], align 2
// CHECK-CONTRACT-EXT-NEXT: store bfloat [[C]], ptr [[C_ADDR]], align 2
// CHECK-CONTRACT-EXT-NEXT: store bfloat [[D]], ptr [[D_ADDR]], align 2
// CHECK-CONTRACT-EXT-NEXT: [[TMP0:%.*]] = load bfloat, ptr [[A_ADDR]], align 2
// CHECK-CONTRACT-EXT-NEXT: [[CONV:%.*]] = fpext bfloat [[TMP0]] to x86_fp80
// CHECK-CONTRACT-EXT-NEXT: [[TMP1:%.*]] = load bfloat, ptr [[B_ADDR]], align 2
// CHECK-CONTRACT-EXT-NEXT: [[CONV1:%.*]] = fpext bfloat [[TMP1]] to x86_fp80
// CHECK-CONTRACT-EXT-NEXT: [[TMP2:%.*]] = load bfloat, ptr [[C_ADDR]], align 2
// CHECK-CONTRACT-EXT-NEXT: [[CONV2:%.*]] = fpext bfloat [[TMP2]] to x86_fp80
// CHECK-CONTRACT-EXT-NEXT: [[TMP3:%.*]] = load bfloat, ptr [[D_ADDR]], align 2
// CHECK-CONTRACT-EXT-NEXT: [[CONV3:%.*]] = fpext bfloat [[TMP3]] to x86_fp80
// CHECK-CONTRACT-EXT-NEXT: [[MUL4:%.*]] = fmul x86_fp80 [[CONV2]], [[CONV3]]
// CHECK-CONTRACT-EXT-NEXT: [[TMP4:%.*]] = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 [[CONV]], x86_fp80 [[CONV1]], x86_fp80 [[MUL4]])
// CHECK-CONTRACT-EXT-NEXT: [[CONV5:%.*]] = fptrunc x86_fp80 [[TMP4]] to bfloat
// CHECK-CONTRACT-EXT-NEXT: ret bfloat [[CONV5]]
//
// CHECK-UNSAFE-LABEL: define dso_local bfloat @f
// CHECK-UNSAFE-SAME: (bfloat noundef [[A:%.*]], bfloat noundef [[B:%.*]], bfloat noundef [[C:%.*]], bfloat noundef [[D:%.*]]) #[[ATTR0:[0-9]+]] {
// CHECK-UNSAFE-NEXT: entry:
// CHECK-UNSAFE-NEXT: [[A_ADDR:%.*]] = alloca bfloat, align 2
// CHECK-UNSAFE-NEXT: [[B_ADDR:%.*]] = alloca bfloat, align 2
// CHECK-UNSAFE-NEXT: [[C_ADDR:%.*]] = alloca bfloat, align 2
// CHECK-UNSAFE-NEXT: [[D_ADDR:%.*]] = alloca bfloat, align 2
// CHECK-UNSAFE-NEXT: store bfloat [[A]], ptr [[A_ADDR]], align 2
// CHECK-UNSAFE-NEXT: store bfloat [[B]], ptr [[B_ADDR]], align 2
// CHECK-UNSAFE-NEXT: store bfloat [[C]], ptr [[C_ADDR]], align 2
// CHECK-UNSAFE-NEXT: store bfloat [[D]], ptr [[D_ADDR]], align 2
// CHECK-UNSAFE-NEXT: [[TMP0:%.*]] = load bfloat, ptr [[A_ADDR]], align 2
// CHECK-UNSAFE-NEXT: [[TMP1:%.*]] = load bfloat, ptr [[B_ADDR]], align 2
// CHECK-UNSAFE-NEXT: [[TMP2:%.*]] = load bfloat, ptr [[C_ADDR]], align 2
// CHECK-UNSAFE-NEXT: [[TMP3:%.*]] = load bfloat, ptr [[D_ADDR]], align 2
// CHECK-UNSAFE-NEXT: [[MUL1:%.*]] = fmul reassoc nsz arcp afn bfloat [[TMP2]], [[TMP3]]
// CHECK-UNSAFE-NEXT: [[TMP4:%.*]] = call reassoc nsz arcp afn bfloat @llvm.fmuladd.bf16(bfloat [[TMP0]], bfloat [[TMP1]], bfloat [[MUL1]])
// CHECK-UNSAFE-NEXT: ret bfloat [[TMP4]]
//
__bf16 f(__bf16 a, __bf16 b, __bf16 c, __bf16 d) {
return a * b + c * d;
}