Skip to content

Commit 3c27360

Browse files
committed
merge main into amd-staging
2 parents f5d93b8 + f42e58f commit 3c27360

File tree

21 files changed

+211
-157
lines changed

21 files changed

+211
-157
lines changed

llvm/include/llvm/Analysis/TargetTransformInfo.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@ class MemIntrinsicCostAttributes {
157157
Alignment(Alignment) {}
158158

159159
LLVM_ABI MemIntrinsicCostAttributes(Intrinsic::ID Id, Type *DataTy,
160-
Align Alignment, unsigned AddressSpace)
160+
Align Alignment,
161+
unsigned AddressSpace = 0)
161162
: DataTy(DataTy), IID(Id), AddressSpace(AddressSpace),
162163
Alignment(Alignment) {}
163164

llvm/include/llvm/CodeGen/BasicTTIImpl.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1817,7 +1817,16 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
18171817
}
18181818
}
18191819
}
1820-
1820+
if (ICA.getID() == Intrinsic::vp_load_ff) {
1821+
Type *RetTy = ICA.getReturnType();
1822+
Type *DataTy = cast<StructType>(RetTy)->getElementType(0);
1823+
Align Alignment;
1824+
if (auto *VPI = dyn_cast_or_null<VPIntrinsic>(ICA.getInst()))
1825+
Alignment = VPI->getPointerAlignment().valueOrOne();
1826+
return thisT()->getMemIntrinsicInstrCost(
1827+
MemIntrinsicCostAttributes(ICA.getID(), DataTy, Alignment),
1828+
CostKind);
1829+
}
18211830
if (ICA.getID() == Intrinsic::vp_scatter) {
18221831
if (ICA.isTypeBasedOnly()) {
18231832
IntrinsicCostAttributes MaskedScatter(
@@ -3076,6 +3085,8 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
30763085
case Intrinsic::masked_compressstore:
30773086
case Intrinsic::masked_expandload:
30783087
return thisT()->getExpandCompressMemoryOpCost(MICA, CostKind);
3088+
case Intrinsic::vp_load_ff:
3089+
return InstructionCost::getInvalid();
30793090
default:
30803091
llvm_unreachable("unexpected intrinsic");
30813092
}

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3288,6 +3288,9 @@ static SDValue getAsCarry(const TargetLowering &TLI, SDValue V,
32883288

32893289
// First, peel away TRUNCATE/ZERO_EXTEND/AND nodes due to legalization.
32903290
while (true) {
3291+
if (ForceCarryReconstruction && V.getValueType() == MVT::i1)
3292+
return V;
3293+
32913294
if (V.getOpcode() == ISD::TRUNCATE || V.getOpcode() == ISD::ZERO_EXTEND) {
32923295
V = V.getOperand(0);
32933296
continue;
@@ -3302,9 +3305,6 @@ static SDValue getAsCarry(const TargetLowering &TLI, SDValue V,
33023305
continue;
33033306
}
33043307

3305-
if (ForceCarryReconstruction && V.getValueType() == MVT::i1)
3306-
return V;
3307-
33083308
break;
33093309
}
33103310

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25364,6 +25364,22 @@ bool RISCVTargetLowering::isLegalStridedLoadStore(EVT DataType,
2536425364
return true;
2536525365
}
2536625366

25367+
bool RISCVTargetLowering::isLegalFirstFaultLoad(EVT DataType,
25368+
Align Alignment) const {
25369+
if (!Subtarget.hasVInstructions())
25370+
return false;
25371+
25372+
EVT ScalarType = DataType.getScalarType();
25373+
if (!isLegalElementTypeForRVV(ScalarType))
25374+
return false;
25375+
25376+
if (!Subtarget.enableUnalignedVectorMem() &&
25377+
Alignment < ScalarType.getStoreSize())
25378+
return false;
25379+
25380+
return true;
25381+
}
25382+
2536725383
MachineInstr *
2536825384
RISCVTargetLowering::EmitKCFICheck(MachineBasicBlock &MBB,
2536925385
MachineBasicBlock::instr_iterator &MBBI,

llvm/lib/Target/RISCV/RISCVISelLowering.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,10 @@ class RISCVTargetLowering : public TargetLowering {
429429
/// alignment is legal.
430430
bool isLegalStridedLoadStore(EVT DataType, Align Alignment) const;
431431

432+
/// Return true if a fault-only-first load of the given result type and
433+
/// alignment is legal.
434+
bool isLegalFirstFaultLoad(EVT DataType, Align Alignment) const;
435+
432436
unsigned getMaxSupportedInterleaveFactor() const override { return 8; }
433437

434438
bool fallBackToDAGISel(const Instruction &Inst) const override;

llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,6 +1007,25 @@ InstructionCost RISCVTTIImpl::getScalarizationOverhead(
10071007
return Cost;
10081008
}
10091009

1010+
InstructionCost
1011+
RISCVTTIImpl::getMemIntrinsicInstrCost(const MemIntrinsicCostAttributes &MICA,
1012+
TTI::TargetCostKind CostKind) const {
1013+
Type *DataTy = MICA.getDataType();
1014+
Align Alignment = MICA.getAlignment();
1015+
switch (MICA.getID()) {
1016+
case Intrinsic::vp_load_ff: {
1017+
EVT DataTypeVT = TLI->getValueType(DL, DataTy);
1018+
if (!TLI->isLegalFirstFaultLoad(DataTypeVT, Alignment))
1019+
return BaseT::getMemIntrinsicInstrCost(MICA, CostKind);
1020+
1021+
unsigned AS = MICA.getAddressSpace();
1022+
return getMemoryOpCost(Instruction::Load, DataTy, Alignment, AS, CostKind,
1023+
{TTI::OK_AnyValue, TTI::OP_None}, nullptr);
1024+
}
1025+
}
1026+
return BaseT::getMemIntrinsicInstrCost(MICA, CostKind);
1027+
}
1028+
10101029
InstructionCost
10111030
RISCVTTIImpl::getMaskedMemoryOpCost(const MemIntrinsicCostAttributes &MICA,
10121031
TTI::TargetCostKind CostKind) const {

llvm/lib/Target/RISCV/RISCVTargetTransformInfo.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,10 @@ class RISCVTTIImpl final : public BasicTTIImplBase<RISCVTTIImpl> {
143143

144144
bool shouldConsiderVectorizationRegPressure() const override { return true; }
145145

146+
InstructionCost
147+
getMemIntrinsicInstrCost(const MemIntrinsicCostAttributes &MICA,
148+
TTI::TargetCostKind CostKind) const override;
149+
146150
InstructionCost
147151
getMaskedMemoryOpCost(const MemIntrinsicCostAttributes &MICA,
148152
TTI::TargetCostKind CostKind) const override;

0 commit comments

Comments
 (0)