Skip to content

Commit 87fad5c

Browse files
[LLVM][AArch64] Correctly lower funnel shifts by zero.
Prevent LowerFunnelShift from creating an invalid ISD::FSHR when lowering "ISD::FSHL X, Y, 0". Such inputs are rare because it's a NOP that DAGCombiner will optimise away. However, we shoudl not rely on this and so this PR mirror the same optimisation. NOTE: To simiplify testing, this PR also adds a command line option to disable the DAG combiner (-combiner-disabled).
1 parent 8dd0065 commit 87fad5c

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7266,12 +7266,18 @@ static SDValue LowerFunnelShift(SDValue Op, SelectionDAG &DAG) {
72667266
MVT VT = Op.getSimpleValueType();
72677267

72687268
if (Op.getOpcode() == ISD::FSHL) {
7269+
if (ShiftNo->isZero())
7270+
return Op.getOperand(0);
7271+
72697272
unsigned int NewShiftNo =
72707273
VT.getFixedSizeInBits() - ShiftNo->getZExtValue();
72717274
return DAG.getNode(
72727275
ISD::FSHR, DL, VT, Op.getOperand(0), Op.getOperand(1),
72737276
DAG.getConstant(NewShiftNo, DL, Shifts.getValueType()));
72747277
} else if (Op.getOpcode() == ISD::FSHR) {
7278+
if (ShiftNo->isZero())
7279+
return Op.getOperand(1);
7280+
72757281
return Op;
72767282
}
72777283
}

0 commit comments

Comments
 (0)