Skip to content

Commit 3f2ad41

Browse files
oscardssmithOscar Smith
authored andcommitted
address review
1 parent d960e6e commit 3f2ad41

File tree

4 files changed

+7
-8
lines changed

4 files changed

+7
-8
lines changed

llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5497,6 +5497,7 @@ void DAGTypeLegalizer::ExpandIntRes_CLMUL(SDNode *N, SDValue &Lo,
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+
// TODO: if the target supports a widening CLMUL or a CLMULH we should probably use that
55005501
SDValue BitRevLL = DAG.getNode(ISD::BITREVERSE, DL, HalfVT, LL);
55015502
SDValue BitRevRL = DAG.getNode(ISD::BITREVERSE, DL, HalfVT, RL);
55025503
SDValue BitRevLoHi = DAG.getNode(ISD::CLMUL, DL, HalfVT, BitRevLL, BitRevRL);

llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7521,6 +7521,7 @@ SDValue SelectionDAG::getNode(unsigned Opcode, const SDLoc &DL, EVT VT,
75217521
case ISD::SSUBSAT:
75227522
case ISD::UADDSAT:
75237523
case ISD::USUBSAT:
7524+
case ISD::CLMUL:
75247525
assert(VT.isInteger() && "This operator does not apply to FP types!");
75257526
assert(N1.getValueType() == N2.getValueType() &&
75267527
N1.getValueType() == VT && "Binary operator types must match!");

llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7231,11 +7231,7 @@ 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-
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));
7234+
setValue(&I, DAG.getNode(ISD::CLMUL, sdl, Op1.getValueType(), Op1, Op2));
72397235
return;
72407236
}
72417237
case Intrinsic::sadd_sat: {

llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8301,14 +8301,15 @@ SDValue TargetLowering::expandCLMUL(SDNode *Node,
83018301
SDValue Res = DAG.getConstant(0, DL, VT);
83028302
SDValue Zero = DAG.getConstant(0, DL, VT);
83038303
SDValue One = DAG.getConstant(1, DL, VT);
8304+
SDValue OneForShift = DAG.getShiftAmountConstant(1, VT, DL);
83048305
for (unsigned I = 0; I < NumBitsPerElt; ++I) {
83058306
SDValue LowBit = DAG.getNode(ISD::AND, DL, VT, V1, One);
83068307
SDValue LowBool = DAG.getSetCC(DL, SetCCType, LowBit, Zero, ISD::SETNE);
83078308
SDValue Pred = DAG.getNode(ISD::SELECT, DL, VT, LowBool, V2, Zero);
83088309
Res = DAG.getNode(ISD::XOR, DL, VT, Res, Pred);
8309-
if (I != NumBitsPerElt-1) {
8310-
V1 = DAG.getNode(ISD::SRL, DL, VT, V1, One);
8311-
V2 = DAG.getNode(ISD::SHL, DL, VT, V2, One);
8310+
if (I != NumBitsPerElt - 1) {
8311+
V1 = DAG.getNode(ISD::SRL, DL, VT, V1, OneForShift);
8312+
V2 = DAG.getNode(ISD::SHL, DL, VT, V2, OneForShift);
83128313
}
83138314
}
83148315
return Res;

0 commit comments

Comments
 (0)