Skip to content

Commit 3d6f18d

Browse files
[AArch64] Remove redundant FDIV Combine. (#91924)
The target combine is no longer required because InstCombine will transform the DIV by a power of 2 into a multiply, so in practice this case will never trigger. Additionally, the generated code would have been incorrect for streaming(-compatible) functions, because it assumed NEON was available.
1 parent 08536b0 commit 3d6f18d

File tree

3 files changed

+1
-240
lines changed

3 files changed

+1
-240
lines changed

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp

Lines changed: 1 addition & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,7 +1040,7 @@ AArch64TargetLowering::AArch64TargetLowering(const TargetMachine &TM,
10401040
ISD::UINT_TO_FP});
10411041

10421042
setTargetDAGCombine({ISD::FP_TO_SINT, ISD::FP_TO_UINT, ISD::FP_TO_SINT_SAT,
1043-
ISD::FP_TO_UINT_SAT, ISD::FADD, ISD::FDIV});
1043+
ISD::FP_TO_UINT_SAT, ISD::FADD});
10441044

10451045
// Try and combine setcc with csel
10461046
setTargetDAGCombine(ISD::SETCC);
@@ -17963,75 +17963,6 @@ static SDValue performFpToIntCombine(SDNode *N, SelectionDAG &DAG,
1796317963
return FixConv;
1796417964
}
1796517965

17966-
/// Fold a floating-point divide by power of two into fixed-point to
17967-
/// floating-point conversion.
17968-
static SDValue performFDivCombine(SDNode *N, SelectionDAG &DAG,
17969-
TargetLowering::DAGCombinerInfo &DCI,
17970-
const AArch64Subtarget *Subtarget) {
17971-
if (!Subtarget->hasNEON())
17972-
return SDValue();
17973-
17974-
SDValue Op = N->getOperand(0);
17975-
unsigned Opc = Op->getOpcode();
17976-
if (!Op.getValueType().isVector() || !Op.getValueType().isSimple() ||
17977-
!Op.getOperand(0).getValueType().isSimple() ||
17978-
(Opc != ISD::SINT_TO_FP && Opc != ISD::UINT_TO_FP))
17979-
return SDValue();
17980-
17981-
SDValue ConstVec = N->getOperand(1);
17982-
if (!isa<BuildVectorSDNode>(ConstVec))
17983-
return SDValue();
17984-
17985-
MVT IntTy = Op.getOperand(0).getSimpleValueType().getVectorElementType();
17986-
int32_t IntBits = IntTy.getSizeInBits();
17987-
if (IntBits != 16 && IntBits != 32 && IntBits != 64)
17988-
return SDValue();
17989-
17990-
MVT FloatTy = N->getSimpleValueType(0).getVectorElementType();
17991-
int32_t FloatBits = FloatTy.getSizeInBits();
17992-
if (FloatBits != 32 && FloatBits != 64)
17993-
return SDValue();
17994-
17995-
// Avoid conversions where iN is larger than the float (e.g., i64 -> float).
17996-
if (IntBits > FloatBits)
17997-
return SDValue();
17998-
17999-
BitVector UndefElements;
18000-
BuildVectorSDNode *BV = cast<BuildVectorSDNode>(ConstVec);
18001-
int32_t C = BV->getConstantFPSplatPow2ToLog2Int(&UndefElements, FloatBits + 1);
18002-
if (C == -1 || C == 0 || C > FloatBits)
18003-
return SDValue();
18004-
18005-
MVT ResTy;
18006-
unsigned NumLanes = Op.getValueType().getVectorNumElements();
18007-
switch (NumLanes) {
18008-
default:
18009-
return SDValue();
18010-
case 2:
18011-
ResTy = FloatBits == 32 ? MVT::v2i32 : MVT::v2i64;
18012-
break;
18013-
case 4:
18014-
ResTy = FloatBits == 32 ? MVT::v4i32 : MVT::v4i64;
18015-
break;
18016-
}
18017-
18018-
if (ResTy == MVT::v4i64 && DCI.isBeforeLegalizeOps())
18019-
return SDValue();
18020-
18021-
SDLoc DL(N);
18022-
SDValue ConvInput = Op.getOperand(0);
18023-
bool IsSigned = Opc == ISD::SINT_TO_FP;
18024-
if (IntBits < FloatBits)
18025-
ConvInput = DAG.getNode(IsSigned ? ISD::SIGN_EXTEND : ISD::ZERO_EXTEND, DL,
18026-
ResTy, ConvInput);
18027-
18028-
unsigned IntrinsicOpcode = IsSigned ? Intrinsic::aarch64_neon_vcvtfxs2fp
18029-
: Intrinsic::aarch64_neon_vcvtfxu2fp;
18030-
return DAG.getNode(ISD::INTRINSIC_WO_CHAIN, DL, Op.getValueType(),
18031-
DAG.getConstant(IntrinsicOpcode, DL, MVT::i32), ConvInput,
18032-
DAG.getConstant(C, DL, MVT::i32));
18033-
}
18034-
1803517966
static SDValue tryCombineToBSL(SDNode *N, TargetLowering::DAGCombinerInfo &DCI,
1803617967
const AArch64TargetLowering &TLI) {
1803717968
EVT VT = N->getValueType(0);
@@ -24720,8 +24651,6 @@ SDValue AArch64TargetLowering::PerformDAGCombine(SDNode *N,
2472024651
case ISD::FP_TO_SINT_SAT:
2472124652
case ISD::FP_TO_UINT_SAT:
2472224653
return performFpToIntCombine(N, DAG, DCI, Subtarget);
24723-
case ISD::FDIV:
24724-
return performFDivCombine(N, DAG, DCI, Subtarget);
2472524654
case ISD::OR:
2472624655
return performORCombine(N, DCI, Subtarget, *this);
2472724656
case ISD::AND:

llvm/test/CodeGen/AArch64/fdiv_combine.ll

Lines changed: 0 additions & 126 deletions
This file was deleted.

llvm/test/CodeGen/AArch64/sitofp-fixed-legal.ll

Lines changed: 0 additions & 42 deletions
This file was deleted.

0 commit comments

Comments
 (0)