Skip to content

Commit 4dfc106

Browse files
author
Oscar Smith
committed
cleanup
1 parent cdab5cc commit 4dfc106

File tree

4 files changed

+19
-16
lines changed

4 files changed

+19
-16
lines changed

llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4018,8 +4018,7 @@ bool SelectionDAGLegalize::ExpandNode(SDNode *Node) {
40184018
Results.push_back(Expanded);
40194019
break;
40204020
case ISD::CLMUL:
4021-
if (SDValue Expanded = TLI.expandCLMUL(Node, DAG))
4022-
Results.push_back(Expanded);
4021+
Results.push_back(TLI.expandCLMUL(Node, DAG));
40234022
break;
40244023
case ISD::ROTL:
40254024
case ISD::ROTR:

llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5484,29 +5484,29 @@ void DAGTypeLegalizer::ExpandIntRes_FunnelShift(SDNode *N, SDValue &Lo,
54845484
void DAGTypeLegalizer::ExpandIntRes_CLMUL(SDNode *N, SDValue &Lo,
54855485
SDValue &Hi) {
54865486
// Values numbered from least significant to most significant.
5487-
SDValue In1, In2, In3, In4;
5488-
GetExpandedInteger(N->getOperand(0), In3, In4);
5489-
GetExpandedInteger(N->getOperand(1), In1, In2);
5490-
EVT HalfVT = In1.getValueType();
5487+
SDValue LL, LH, RL, RH;
5488+
GetExpandedInteger(N->getOperand(0), LL, LH);
5489+
GetExpandedInteger(N->getOperand(1), RL, RH);
5490+
EVT HalfVT = LL.getValueType();
54915491
SDLoc DL(N);
54925492

54935493
// CLMUL is carryless so Lo is computed from the low half
5494-
Lo = DAG.getNode(ISD::CLMUL, DL, HalfVT, In1, In3);
5494+
Lo = DAG.getNode(ISD::CLMUL, DL, HalfVT, LL, RL);
54955495
// the high bits not included in CLMUL(A,B) can be computed by
54965496
// BITREVERSE(CLMUL(BITREVERSE(A), BITREVERSE(B))) >> 1
54975497
// Therefore we can compute the 2 hi/lo cross products
54985498
// and the the overflow of the low product
54995499
// and xor them together to compute HI
5500-
SDValue BitRevIn1 = DAG.getNode(ISD::BITREVERSE, DL, HalfVT, In1);
5501-
SDValue BitRevIn3 = DAG.getNode(ISD::BITREVERSE, DL, HalfVT, In3);
5502-
SDValue BitRevLoHi = DAG.getNode(ISD::CLMUL, DL, HalfVT, BitRevIn1, BitRevIn3);
5500+
SDValue BitRevLL = DAG.getNode(ISD::BITREVERSE, DL, HalfVT, LL);
5501+
SDValue BitRevRL = DAG.getNode(ISD::BITREVERSE, DL, HalfVT, RL);
5502+
SDValue BitRevLoHi = DAG.getNode(ISD::CLMUL, DL, HalfVT, BitRevLL, BitRevRL);
55035503
SDValue LoHi = DAG.getNode(ISD::BITREVERSE, DL, HalfVT, BitRevLoHi);
5504-
SDValue One = DAG.getConstant(0, DL, HalfVT);
5504+
SDValue One = DAG.getShiftAmountConstant(1, HalfVT, DL);
55055505
Hi = DAG.getNode(ISD::SRL, DL, HalfVT, LoHi, One);
55065506

5507-
SDValue HITMP = DAG.getNode(ISD::CLMUL, DL, HalfVT, In1, In4);
5507+
SDValue HITMP = DAG.getNode(ISD::CLMUL, DL, HalfVT, LL, RH);
55085508
Hi = DAG.getNode(ISD::XOR, DL, HalfVT, Hi, HITMP);
5509-
HITMP = DAG.getNode(ISD::CLMUL, DL, HalfVT, In2, In3);
5509+
HITMP = DAG.getNode(ISD::CLMUL, DL, HalfVT, LH, RL);
55105510
Hi = DAG.getNode(ISD::XOR, DL, HalfVT, Hi, HITMP);
55115511
}
55125512

llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7231,7 +7231,11 @@ void SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I,
72317231
case Intrinsic::clmul: {
72327232
SDValue Op1 = getValue(I.getArgOperand(0));
72337233
SDValue Op2 = getValue(I.getArgOperand(1));
7234-
setValue(&I, DAG.getNode(ISD::CLMUL, sdl, Op1.getValueType(), Op1, Op2));
7234+
EVT VT = Op1.getValueType();
7235+
assert(VT.isInteger() && "This operator does not apply to FP types!");
7236+
assert(Op1.getValueType() == Op2.getValueType() &&
7237+
Op1.getValueType() == VT && "Binary operator types must match!");
7238+
setValue(&I, DAG.getNode(ISD::CLMUL, sdl, VT, Op1, Op2));
72357239
return;
72367240
}
72377241
case Intrinsic::sadd_sat: {

llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8299,12 +8299,12 @@ SDValue TargetLowering::expandCLMUL(SDNode *Node,
82998299
SDValue Res = DAG.getConstant(0, DL, VT);
83008300
SDValue Zero = DAG.getConstant(0, DL, VT);
83018301
SDValue One = DAG.getConstant(1, DL, VT);
8302-
for (unsigned I = 0; I < NumBitsPerElt-1; ++I) {
8302+
for (unsigned I = 0; I < NumBitsPerElt; ++I) {
83038303
SDValue LowBit = DAG.getNode(ISD::AND, DL, VT, V1, One);
83048304
SDValue LowBool = DAG.getSetCC(DL, SetCCType, LowBit, Zero, ISD::SETNE);
83058305
SDValue Pred = DAG.getNode(ISD::SELECT, DL, VT, LowBool, V2, Zero);
83068306
Res = DAG.getNode(ISD::XOR, DL, VT, Res, Pred);
8307-
if (I != NumBitsPerElt) {
8307+
if (I != NumBitsPerElt-1) {
83088308
V1 = DAG.getNode(ISD::SRL, DL, VT, V1, One);
83098309
V2 = DAG.getNode(ISD::SHL, DL, VT, V2, One);
83108310
}

0 commit comments

Comments
 (0)