case ISD::CTTZ_ZERO_UNDEF:
return getConstant(Val.countTrailingZeros(), DL, VT, C->isTargetOpcode(),
C->isOpaque());
- case ISD::FP16_TO_FP: {
+ case ISD::FP16_TO_FP:
+ case ISD::BF16_TO_FP: {
bool Ignored;
- APFloat FPV(APFloat::IEEEhalf(),
+ APFloat FPV(Opcode == ISD::FP16_TO_FP ? APFloat::IEEEhalf()
+ : APFloat::BFloat(),
(Val.getBitWidth() == 16) ? Val : Val.trunc(16));
// This can return overflow, underflow, or inexact; we don't care.
if (VT == MVT::i64 && C->getValueType(0) == MVT::f64)
return getConstant(V.bitcastToAPInt().getZExtValue(), DL, VT);
break;
- case ISD::FP_TO_FP16: {
+ case ISD::FP_TO_FP16:
+ case ISD::FP_TO_BF16: {
bool Ignored;
// This can return overflow, underflow, or inexact; we don't care.
// FIXME need to be more flexible about rounding mode.
- (void)V.convert(APFloat::IEEEhalf(),
+ (void)V.convert(Opcode == ISD::FP_TO_FP16 ? APFloat::IEEEhalf()
+ : APFloat::BFloat(),
APFloat::rmNearestTiesToEven, &Ignored);
return getConstant(V.bitcastToAPInt().getZExtValue(), DL, VT);
}
store double %dadd, ptr %pc
ret void
}
+
+define void @add_constant(ptr %pa, ptr %pc) {
+; CHECK-LABEL: add_constant:
+; CHECK: # %bb.0:
+; CHECK-NEXT: pushq %rbx
+; CHECK-NEXT: .cfi_def_cfa_offset 16
+; CHECK-NEXT: .cfi_offset %rbx, -16
+; CHECK-NEXT: movq %rsi, %rbx
+; CHECK-NEXT: movzwl (%rdi), %eax
+; CHECK-NEXT: shll $16, %eax
+; CHECK-NEXT: movd %eax, %xmm0
+; CHECK-NEXT: addss {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0
+; CHECK-NEXT: callq __truncsfbf2@PLT
+; CHECK-NEXT: movw %ax, (%rbx)
+; CHECK-NEXT: popq %rbx
+; CHECK-NEXT: .cfi_def_cfa_offset 8
+; CHECK-NEXT: retq
+ %a = load bfloat, ptr %pa
+ %add = fadd bfloat %a, 1.0
+ store bfloat %add, ptr %pc
+ ret void
+}
+
+define void @store_constant(ptr %pc) {
+; CHECK-LABEL: store_constant:
+; CHECK: # %bb.0:
+; CHECK-NEXT: movw $16256, (%rdi) # imm = 0x3F80
+; CHECK-NEXT: retq
+ store bfloat 1.0, ptr %pc
+ ret void
+}