Skip to content

Commit ac9a225

Browse files
committed
Address review comments
1 parent dfd9bf7 commit ac9a225

File tree

3 files changed

+5
-24
lines changed

3 files changed

+5
-24
lines changed

llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include "LegalizeTypes.h"
2323
#include "llvm/ADT/SmallBitVector.h"
2424
#include "llvm/Analysis/MemoryLocation.h"
25-
#include "llvm/Analysis/ValueTracking.h"
2625
#include "llvm/Analysis/VectorUtils.h"
2726
#include "llvm/IR/DataLayout.h"
2827
#include "llvm/Support/ErrorHandling.h"
@@ -6957,32 +6956,14 @@ SDValue DAGTypeLegalizer::WidenVecOp_VSELECT(SDNode *N) {
69576956
}
69586957

69596958
SDValue DAGTypeLegalizer::WidenVecOp_VP_CttzElements(SDNode *N) {
6960-
// Widen the result bit width if needed.
69616959
SDLoc DL(N);
6962-
EVT OrigResVT = N->getValueType(0);
6963-
const Function &F = DAG.getMachineFunction().getFunction();
6964-
69656960
SDValue Source = GetWidenedVector(N->getOperand(0));
69666961
EVT SrcVT = Source.getValueType();
69676962
SDValue Mask =
69686963
GetWidenedMask(N->getOperand(1), SrcVT.getVectorElementCount());
69696964

6970-
// Compute the number of bits that can fit the result.
6971-
ConstantRange CR(APInt(64, SrcVT.getVectorMinNumElements()));
6972-
if (SrcVT.isScalableVT())
6973-
CR = CR.umul_sat(getVScaleRange(&F, 64));
6974-
// If the zero-is-poison flag is set in the original intrinsic, we can
6975-
// assume the upper limit of the result is EVL - 1.
6976-
if (N->getOpcode() == ISD::VP_CTTZ_ELTS_ZERO_UNDEF)
6977-
CR = CR.subtract(APInt(64, 1));
6978-
6979-
unsigned NewResWidth = OrigResVT.getScalarSizeInBits();
6980-
NewResWidth = std::min(NewResWidth, unsigned(CR.getActiveBits()));
6981-
NewResWidth = std::max(llvm::bit_ceil(NewResWidth), 8U);
6982-
6983-
EVT NewResVT = EVT::getIntegerVT(*DAG.getContext(), NewResWidth);
6984-
return DAG.getNode(N->getOpcode(), DL, NewResVT, Source, Mask,
6985-
N->getOperand(2));
6965+
return DAG.getNode(N->getOpcode(), DL, N->getValueType(0),
6966+
{Source, Mask, N->getOperand(2)}, N->getFlags());
69866967
}
69876968

69886969
//===----------------------------------------------------------------------===//

llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9095,7 +9095,8 @@ SDValue TargetLowering::expandVPCTTZElements(SDNode *N,
90959095
SDValue AllZero = DAG.getConstant(0, DL, SrcVT);
90969096
SrcVT = EVT::getVectorVT(*DAG.getContext(), MVT::i1,
90979097
SrcVT.getVectorElementCount());
9098-
Source = DAG.getSetCC(DL, SrcVT, Source, AllZero, ISD::SETNE);
9098+
Source = DAG.getNode(ISD::VP_SETCC, DL, SrcVT, Source, AllZero,
9099+
DAG.getCondCode(ISD::SETNE), Mask, EVL);
90999100
}
91009101

91019102
SDValue ExtEVL = DAG.getZExtOrTrunc(EVL, DL, ResVT);

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5378,8 +5378,7 @@ SDValue RISCVTargetLowering::lowerVPCttzElements(SDValue Op,
53785378
// Convert -1 to VL.
53795379
SDValue SetCC =
53805380
DAG.getSetCC(DL, XLenVT, Res, DAG.getConstant(0, DL, XLenVT), ISD::SETLT);
5381-
Res = DAG.getSelect(DL, XLenVT, SetCC, DAG.getZExtOrTrunc(EVL, DL, XLenVT),
5382-
Res);
5381+
Res = DAG.getSelect(DL, XLenVT, SetCC, EVL, Res);
53835382
return DAG.getNode(ISD::TRUNCATE, DL, Op.getValueType(), Res);
53845383
}
53855384

0 commit comments

Comments
 (0)