[llvm] [AArch64] Lower bfloat FADD/SUB to BFMLAL top/bottom instructions (PR #174814)
Sander de Smalen via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 26 06:06:16 PST 2026
================
@@ -7780,29 +7767,57 @@ SDValue AArch64TargetLowering::LowerFMUL(SDValue Op, SelectionDAG &DAG) const {
: Intrinsic::aarch64_neon_bfmlalt);
EVT AccVT = UseSVEBFMLAL ? MVT::nxv4f32 : MVT::v4f32;
- SDValue Zero = DAG.getNeutralElement(ISD::FADD, DL, AccVT, Op->getFlags());
SDValue Pg = getPredicateForVector(DAG, DL, AccVT);
- // Lower bf16 FMUL as a pair (VT == [nx]v8bf16) of BFMLAL top/bottom
- // instructions. These result in two f32 vectors, which can be converted back
- // to bf16 with FCVT and FCVTNT.
- SDValue LHS = Op.getOperand(0);
- SDValue RHS = Op.getOperand(1);
+ SDValue BottomAcc, TopAcc, LHS, RHS;
+
+ if (Opcode == ISD::FMUL) {
+ // Set both accumulators to zero.
+ BottomAcc = TopAcc =
+ DAG.getNeutralElement(ISD::FADD, DL, AccVT, Op->getFlags());
+
+ // Lower bf16 FMUL as a pair (VT == [nx]v8bf16) of BFMLAL top/bottom
+ // instructions. These result in two f32 vectors, which can be converted
+ // back to bf16 with FCVT and FCVTNT.
+ LHS = Op.getOperand(0);
+ RHS = Op.getOperand(1);
+ } else if (Opcode == ISD::FADD || Opcode == ISD::FSUB) {
+ // Lower FADD/SUB by extending the LHS to be used as the accumulator, and
+ // multiplying the RHS by 1.0F (or -1.0F for FSUB).
+ if (VT.getVectorMinNumElements() > 4) {
----------------
sdesmalen-arm wrote:
```suggestion
if (VT != MVT::nxv4bf16) {
```
https://github.com/llvm/llvm-project/pull/174814
More information about the llvm-commits
mailing list