Skip to content

Commit 3c88c39

Browse files
Merge branch 'main' into an/avx-masked-shuffles
2 parents ccc654a + b6bf196 commit 3c88c39

File tree

27 files changed

+768
-357
lines changed

27 files changed

+768
-357
lines changed

clang/include/clang/AST/TypeBase.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7082,10 +7082,6 @@ class SubstBuiltinTemplatePackType : public SubstPackType {
70827082
class SubstTemplateTypeParmPackType : public SubstPackType {
70837083
friend class ASTContext;
70847084

7085-
/// A pointer to the set of template arguments that this
7086-
/// parameter pack is instantiated with.
7087-
const TemplateArgument *Arguments;
7088-
70897085
llvm::PointerIntPair<Decl *, 1, bool> AssociatedDeclAndFinal;
70907086

70917087
SubstTemplateTypeParmPackType(QualType Canon, Decl *AssociatedDecl,

clang/lib/CodeGen/CGDebugInfo.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -900,10 +900,13 @@ llvm::DIType *CGDebugInfo::CreateType(const BuiltinType *BT) {
900900
assert((BT->getKind() != BuiltinType::SveCount || Info.NumVectors == 1) &&
901901
"Unsupported number of vectors for svcount_t");
902902

903-
// Debuggers can't extract 1bit from a vector, so will display a
904-
// bitpattern for predicates instead.
905903
unsigned NumElems = Info.EC.getKnownMinValue() * Info.NumVectors;
906-
if (Info.ElementType == CGM.getContext().BoolTy) {
904+
llvm::Metadata *BitStride = nullptr;
905+
if (BT->getKind() == BuiltinType::SveBool) {
906+
Info.ElementType = CGM.getContext().UnsignedCharTy;
907+
BitStride = llvm::ConstantAsMetadata::get(llvm::ConstantInt::getSigned(
908+
llvm::Type::getInt64Ty(CGM.getLLVMContext()), 1));
909+
} else if (BT->getKind() == BuiltinType::SveCount) {
907910
NumElems /= 8;
908911
Info.ElementType = CGM.getContext().UnsignedCharTy;
909912
}
@@ -929,7 +932,7 @@ llvm::DIType *CGDebugInfo::CreateType(const BuiltinType *BT) {
929932
getOrCreateType(Info.ElementType, TheCU->getFile());
930933
auto Align = getTypeAlignIfRequired(BT, CGM.getContext());
931934
return DBuilder.createVectorType(/*Size*/ 0, Align, ElemTy,
932-
SubscriptArray);
935+
SubscriptArray, BitStride);
933936
}
934937
// It doesn't make sense to generate debug info for PowerPC MMA vector types.
935938
// So we return a safe type here to avoid generating an error.

clang/test/DebugInfo/AArch64/sve-vector-types.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33

44
void test_locals(void) {
55
// CHECK-DAG: name: "__SVBool_t",{{.*}}, baseType: ![[CT1:[0-9]+]]
6-
// CHECK-DAG: ![[CT1]] = !DICompositeType(tag: DW_TAG_array_type, baseType: ![[ELTTYU8:[0-9]+]], flags: DIFlagVector, elements: ![[ELTS1_64:[0-9]+]])
6+
// CHECK-DAG: ![[CT1]] = !DICompositeType(tag: DW_TAG_array_type, baseType: ![[ELTTYU8:[0-9]+]], flags: DIFlagVector, elements: ![[ELTS8:[0-9]+]], bitStride: i64 1)
77
// CHECK-DAG: ![[ELTTYU8]] = !DIBasicType(name: "unsigned char", size: 8, encoding: DW_ATE_unsigned_char)
8-
// CHECK-DAG: ![[ELTS1_64]] = !{![[REALELTS1_64:[0-9]+]]}
9-
// CHECK-DAG: ![[REALELTS1_64]] = !DISubrange(lowerBound: 0, upperBound: !DIExpression(DW_OP_constu, 1, DW_OP_bregx, 46, 0, DW_OP_mul, DW_OP_constu, 1, DW_OP_minus))
8+
// CHECK-DAG: ![[ELTS8]] = !{![[REALELTS8:[0-9]+]]}
9+
// CHECK-DAG: ![[REALELTS8]] = !DISubrange(lowerBound: 0, upperBound: !DIExpression(DW_OP_constu, 8, DW_OP_bregx, 46, 0, DW_OP_mul, DW_OP_constu, 1, DW_OP_minus))
1010
__SVBool_t b8;
1111

1212
// CHECK-DAG: name: "__SVCount_t",{{.*}}, baseType: ![[CT1_2:[0-9]+]]
@@ -18,8 +18,6 @@ void test_locals(void) {
1818
// CHECK-DAG: name: "__SVInt8_t",{{.*}}, baseType: ![[CT8:[0-9]+]]
1919
// CHECK-DAG: ![[CT8]] = !DICompositeType(tag: DW_TAG_array_type, baseType: ![[ELTTYS8:[0-9]+]], flags: DIFlagVector, elements: ![[ELTS8:[0-9]+]])
2020
// CHECK-DAG: ![[ELTTYS8]] = !DIBasicType(name: "signed char", size: 8, encoding: DW_ATE_signed_char)
21-
// CHECK-DAG: ![[ELTS8]] = !{![[REALELTS8:[0-9]+]]}
22-
// CHECK-DAG: ![[REALELTS8]] = !DISubrange(lowerBound: 0, upperBound: !DIExpression(DW_OP_constu, 8, DW_OP_bregx, 46, 0, DW_OP_mul, DW_OP_constu, 1, DW_OP_minus))
2321
__SVInt8_t s8;
2422

2523
// CHECK-DAG: name: "__SVUint8_t",{{.*}}, baseType: ![[CT8:[0-9]+]]
@@ -51,12 +49,14 @@ void test_locals(void) {
5149
__SVUint32_t u32;
5250

5351
// CHECK-DAG: name: "__SVInt64_t",{{.*}}, baseType: ![[CT64:[0-9]+]]
54-
// CHECK-DAG: ![[CT64]] = !DICompositeType(tag: DW_TAG_array_type, baseType: ![[ELTTY64:[0-9]+]], flags: DIFlagVector, elements: ![[ELTS1_64]])
52+
// CHECK-DAG: ![[CT64]] = !DICompositeType(tag: DW_TAG_array_type, baseType: ![[ELTTY64:[0-9]+]], flags: DIFlagVector, elements: ![[ELTS64:[0-9]+]])
5553
// CHECK-DAG: ![[ELTTY64]] = !DIBasicType(name: "long", size: 64, encoding: DW_ATE_signed)
54+
// CHECK-DAG: ![[ELTS64]] = !{![[REALELTS64:[0-9]+]]}
55+
// CHECK-DAG: ![[REALELTS64]] = !DISubrange(lowerBound: 0, upperBound: !DIExpression(DW_OP_constu, 1, DW_OP_bregx, 46, 0, DW_OP_mul, DW_OP_constu, 1, DW_OP_minus))
5656
__SVInt64_t s64;
5757

5858
// CHECK-DAG: name: "__SVUint64_t",{{.*}}, baseType: ![[CT64:[0-9]+]]
59-
// CHECK-DAG: ![[CT64]] = !DICompositeType(tag: DW_TAG_array_type, baseType: ![[ELTTY64:[0-9]+]], flags: DIFlagVector, elements: ![[ELTS1_64]])
59+
// CHECK-DAG: ![[CT64]] = !DICompositeType(tag: DW_TAG_array_type, baseType: ![[ELTTY64:[0-9]+]], flags: DIFlagVector, elements: ![[ELTS64]])
6060
// CHECK-DAG: ![[ELTTY64]] = !DIBasicType(name: "unsigned long", size: 64, encoding: DW_ATE_unsigned)
6161
__SVUint64_t u64;
6262

@@ -71,7 +71,7 @@ void test_locals(void) {
7171
__SVFloat32_t f32;
7272

7373
// CHECK: name: "__SVFloat64_t",{{.*}}, baseType: ![[CT64:[0-9]+]]
74-
// CHECK-DAG: ![[CT64]] = !DICompositeType(tag: DW_TAG_array_type, baseType: ![[ELTTY64:[0-9]+]], flags: DIFlagVector, elements: ![[ELTS1_64]])
74+
// CHECK-DAG: ![[CT64]] = !DICompositeType(tag: DW_TAG_array_type, baseType: ![[ELTTY64:[0-9]+]], flags: DIFlagVector, elements: ![[ELTS64]])
7575
// CHECK-DAG: ![[ELTTY64]] = !DIBasicType(name: "double", size: 64, encoding: DW_ATE_float)
7676
__SVFloat64_t f64;
7777
}

libcxx/include/__algorithm/find.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@
1717
#include <__bit/countr.h>
1818
#include <__bit/invert_if.h>
1919
#include <__config>
20+
#include <__cstddef/size_t.h>
2021
#include <__functional/identity.h>
2122
#include <__fwd/bit_reference.h>
2223
#include <__iterator/segmented_iterator.h>
2324
#include <__string/constexpr_c_functions.h>
2425
#include <__type_traits/enable_if.h>
2526
#include <__type_traits/invoke.h>
27+
#include <__type_traits/is_constant_evaluated.h>
2628
#include <__type_traits/is_equality_comparable.h>
2729
#include <__type_traits/is_integral.h>
2830
#include <__type_traits/is_signed.h>

llvm/include/llvm/IR/DIBuilder.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,8 @@ namespace llvm {
729729
/// \param Subscripts Subscripts.
730730
LLVM_ABI DICompositeType *createVectorType(uint64_t Size,
731731
uint32_t AlignInBits, DIType *Ty,
732-
DINodeArray Subscripts);
732+
DINodeArray Subscripts,
733+
Metadata *BitStride = nullptr);
733734

734735
/// Create debugging information entry for an
735736
/// enumeration.

llvm/lib/Analysis/ScalarEvolution.cpp

Lines changed: 3 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -15749,51 +15749,11 @@ void ScalarEvolution::LoopGuards::collectFromBlock(
1574915749
return RewriteMap.lookup_or(S, S);
1575015750
};
1575115751

15752-
// Check for the SCEV expression (A /u B) * B while B is a constant, inside
15753-
// \p Expr. The check is done recuresively on \p Expr, which is assumed to
15754-
// be a composition of Min/Max SCEVs. Return whether the SCEV expression (A
15755-
// /u B) * B was found, and return the divisor B in \p DividesBy. For
15756-
// example, if Expr = umin (umax ((A /u 8) * 8, 16), 64), return true since
15757-
// (A /u 8) * 8 matched the pattern, and return the constant SCEV 8 in \p
15758-
// DividesBy.
15759-
std::function<bool(const SCEV *, const SCEV *&)> HasDivisibiltyInfo =
15760-
[&](const SCEV *Expr, const SCEV *&DividesBy) {
15761-
if (auto *Mul = dyn_cast<SCEVMulExpr>(Expr)) {
15762-
if (Mul->getNumOperands() != 2)
15763-
return false;
15764-
auto *MulLHS = Mul->getOperand(0);
15765-
auto *MulRHS = Mul->getOperand(1);
15766-
if (isa<SCEVConstant>(MulLHS))
15767-
std::swap(MulLHS, MulRHS);
15768-
if (auto *Div = dyn_cast<SCEVUDivExpr>(MulLHS))
15769-
if (Div->getOperand(1) == MulRHS) {
15770-
DividesBy = MulRHS;
15771-
return true;
15772-
}
15773-
}
15774-
if (auto *MinMax = dyn_cast<SCEVMinMaxExpr>(Expr))
15775-
return HasDivisibiltyInfo(MinMax->getOperand(0), DividesBy) ||
15776-
HasDivisibiltyInfo(MinMax->getOperand(1), DividesBy);
15777-
return false;
15778-
};
15779-
15780-
// Return true if Expr known to divide by \p DividesBy.
15781-
std::function<bool(const SCEV *, const SCEV *&)> IsKnownToDivideBy =
15782-
[&](const SCEV *Expr, const SCEV *DividesBy) {
15783-
if (SE.getURemExpr(Expr, DividesBy)->isZero())
15784-
return true;
15785-
if (auto *MinMax = dyn_cast<SCEVMinMaxExpr>(Expr))
15786-
return IsKnownToDivideBy(MinMax->getOperand(0), DividesBy) &&
15787-
IsKnownToDivideBy(MinMax->getOperand(1), DividesBy);
15788-
return false;
15789-
};
15790-
1579115752
const SCEV *RewrittenLHS = GetMaybeRewritten(LHS);
1579215753
const SCEV *DividesBy = nullptr;
15793-
if (HasDivisibiltyInfo(RewrittenLHS, DividesBy))
15794-
// Check that the whole expression is divided by DividesBy
15795-
DividesBy =
15796-
IsKnownToDivideBy(RewrittenLHS, DividesBy) ? DividesBy : nullptr;
15754+
const APInt &Multiple = SE.getConstantMultiple(RewrittenLHS);
15755+
if (!Multiple.isOne())
15756+
DividesBy = SE.getConstant(Multiple);
1579715757

1579815758
// Collect rewrites for LHS and its transitive operands based on the
1579915759
// condition.

llvm/lib/CodeGen/MachinePipeliner.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ STATISTIC(NumFailZeroMII, "Pipeliner abort due to zero MII");
110110
STATISTIC(NumFailNoSchedule, "Pipeliner abort due to no schedule found");
111111
STATISTIC(NumFailZeroStage, "Pipeliner abort due to zero stage");
112112
STATISTIC(NumFailLargeMaxStage, "Pipeliner abort due to too many stages");
113+
STATISTIC(NumFailTooManyStores, "Pipeliner abort due to too many stores");
113114

114115
/// A command line option to turn software pipelining on or off.
115116
static cl::opt<bool> EnableSWP("enable-pipeliner", cl::Hidden, cl::init(true),
@@ -193,6 +194,13 @@ static cl::opt<bool>
193194
MVECodeGen("pipeliner-mve-cg", cl::Hidden, cl::init(false),
194195
cl::desc("Use the MVE code generator for software pipelining"));
195196

197+
/// A command line argument to limit the number of store instructions in the
198+
/// target basic block.
199+
static cl::opt<unsigned> SwpMaxNumStores(
200+
"pipeliner-max-num-stores",
201+
cl::desc("Maximum number of stores allwed in the target loop."), cl::Hidden,
202+
cl::init(200));
203+
196204
namespace llvm {
197205

198206
// A command line option to enable the CopyToPhi DAG mutation.
@@ -544,6 +552,23 @@ bool MachinePipeliner::canPipelineLoop(MachineLoop &L) {
544552
return false;
545553
}
546554

555+
unsigned NumStores = 0;
556+
for (MachineInstr &MI : *L.getHeader())
557+
if (MI.mayStore())
558+
++NumStores;
559+
if (NumStores > SwpMaxNumStores) {
560+
LLVM_DEBUG(dbgs() << "Too many stores\n");
561+
NumFailTooManyStores++;
562+
ORE->emit([&]() {
563+
return MachineOptimizationRemarkAnalysis(DEBUG_TYPE, "canPipelineLoop",
564+
L.getStartLoc(), L.getHeader())
565+
<< "Too many store instructions in the loop: "
566+
<< ore::NV("NumStores", NumStores) << " > "
567+
<< ore::NV("SwpMaxNumStores", SwpMaxNumStores) << ".";
568+
});
569+
return false;
570+
}
571+
547572
// Remove any subregisters from inputs to phi nodes.
548573
preprocessPhiNodes(*L.getHeader());
549574
return true;

llvm/lib/IR/DIBuilder.cpp

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -715,11 +715,20 @@ DICompositeType *DIBuilder::createArrayType(
715715

716716
DICompositeType *DIBuilder::createVectorType(uint64_t Size,
717717
uint32_t AlignInBits, DIType *Ty,
718-
DINodeArray Subscripts) {
719-
auto *R = DICompositeType::get(VMContext, dwarf::DW_TAG_array_type, "",
720-
nullptr, 0, nullptr, Ty, Size, AlignInBits, 0,
721-
DINode::FlagVector, Subscripts, 0,
722-
/*EnumKind=*/std::nullopt, nullptr);
718+
DINodeArray Subscripts,
719+
Metadata *BitStride) {
720+
auto *R = DICompositeType::get(
721+
VMContext, dwarf::DW_TAG_array_type, /*Name=*/"",
722+
/*File=*/nullptr, /*Line=*/0, /*Scope=*/nullptr, /*BaseType=*/Ty,
723+
/*SizeInBits=*/Size, /*AlignInBits=*/AlignInBits, /*OffsetInBits=*/0,
724+
/*Flags=*/DINode::FlagVector, /*Elements=*/Subscripts,
725+
/*RuntimeLang=*/0, /*EnumKind=*/std::nullopt, /*VTableHolder=*/nullptr,
726+
/*TemplateParams=*/nullptr, /*Identifier=*/"",
727+
/*Discriminator=*/nullptr, /*DataLocation=*/nullptr,
728+
/*Associated=*/nullptr, /*Allocated=*/nullptr, /*Rank=*/nullptr,
729+
/*Annotations=*/nullptr, /*Specification=*/nullptr,
730+
/*NumExtraInhabitants=*/0,
731+
/*BitStride=*/BitStride);
723732
trackIfUnresolved(R);
724733
return R;
725734
}

llvm/lib/Target/Hexagon/Hexagon.td

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,6 @@ def FeatureSmallData: SubtargetFeature<"small-data", "UseSmallData", "true",
110110
"Allow GP-relative addressing of global variables">;
111111
def FeatureDuplex: SubtargetFeature<"duplex", "EnableDuplex", "true",
112112
"Enable generation of duplex instruction">;
113-
def FeatureUnsafeFP: SubtargetFeature<"unsafe-fp", "UseUnsafeMath", "true",
114-
"Use unsafe FP math">;
115113
def FeatureReservedR19: SubtargetFeature<"reserved-r19", "ReservedR19",
116114
"true", "Reserve register R19">;
117115
def FeatureNoreturnStackElim: SubtargetFeature<"noreturn-stack-elim",
@@ -167,7 +165,6 @@ def UseHVXQFloat : Predicate<"HST->useHVXQFloatOps()">,
167165
def UseHVXFloatingPoint: Predicate<"HST->useHVXFloatingPoint()">;
168166
def HasMemNoShuf : Predicate<"HST->hasMemNoShuf()">,
169167
AssemblerPredicate<(all_of FeatureMemNoShuf)>;
170-
def UseUnsafeMath : Predicate<"HST->useUnsafeMath()">;
171168
def NotOptTinyCore : Predicate<"!HST->isTinyCore() ||"
172169
"MF->getFunction().hasOptSize()"> {
173170
let RecomputePerFunction = 1;

llvm/lib/Target/Hexagon/HexagonPatterns.td

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1611,8 +1611,11 @@ def DfMpy: OutPatFrag<(ops node:$Rs, node:$Rt),
16111611
$Rt, $Rs),
16121612
$Rs, $Rt)>;
16131613

1614-
let Predicates = [HasV67,UseUnsafeMath], AddedComplexity = 50 in {
1615-
def: Pat<(fmul F64:$Rs, F64:$Rt), (DfMpy $Rs, $Rt)>;
1614+
def fmul_afn : PatFrag<(ops node:$a, node:$b), (fmul node:$a, node:$b), [{
1615+
return N->getFlags().hasApproximateFuncs();
1616+
}]>;
1617+
let Predicates = [HasV67], AddedComplexity = 50 in {
1618+
def : Pat<(fmul_afn F64:$Rs, F64:$Rt), (DfMpy $Rs, $Rt)>;
16161619
}
16171620
let Predicates = [HasV67] in {
16181621
def: OpR_RR_pat<F2_dfmin, pf2<fminimumnum>, f64, F64>;

0 commit comments

Comments
 (0)