Skip to content

Commit b74182e

Browse files
committed
[llvm-reduce] Handle new flags in complexity score
This has gotten out of sync with the actual flag reduction. It's not particularly important though, as it only seems to be used to determine whether to do another round of delta reduction.
1 parent 3ac5f5e commit b74182e

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

llvm/tools/llvm-reduce/ReducerWorkItem.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -643,12 +643,27 @@ static uint64_t computeIRComplexityScoreImpl(const Function &F) {
643643
++Score;
644644
if (OverflowOp->hasNoSignedWrap())
645645
++Score;
646-
} else if (const auto *GEP = dyn_cast<GEPOperator>(&I)) {
647-
if (GEP->isInBounds())
646+
} else if (const auto *Trunc = dyn_cast<TruncInst>(&I)) {
647+
if (Trunc->hasNoSignedWrap())
648+
++Score;
649+
if (Trunc->hasNoUnsignedWrap())
648650
++Score;
649651
} else if (const auto *ExactOp = dyn_cast<PossiblyExactOperator>(&I)) {
650652
if (ExactOp->isExact())
651653
++Score;
654+
} else if (const auto *NNI = dyn_cast<PossiblyNonNegInst>(&I)) {
655+
if (NNI->hasNonNeg())
656+
++Score;
657+
} else if (const auto *PDI = dyn_cast<PossiblyDisjointInst>(&I)) {
658+
if (PDI->isDisjoint())
659+
++Score;
660+
} else if (const auto *GEP = dyn_cast<GEPOperator>(&I)) {
661+
if (GEP->isInBounds())
662+
++Score;
663+
if (GEP->hasNoUnsignedSignedWrap())
664+
++Score;
665+
if (GEP->hasNoUnsignedWrap())
666+
++Score;
652667
} else if (const auto *FPOp = dyn_cast<FPMathOperator>(&I)) {
653668
FastMathFlags FMF = FPOp->getFastMathFlags();
654669
if (FMF.allowReassoc())

llvm/tools/llvm-reduce/deltas/ReduceInstructionFlags.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
using namespace llvm;
2121

2222
static void reduceFlagsInModule(Oracle &O, ReducerWorkItem &WorkItem) {
23+
// Keep this in sync with computeIRComplexityScoreImpl().
2324
for (Function &F : WorkItem.getModule()) {
2425
for (Instruction &I : instructions(F)) {
2526
if (auto *OBO = dyn_cast<OverflowingBinaryOperator>(&I)) {

0 commit comments

Comments
 (0)