[llvm] b74182e - [llvm-reduce] Handle new flags in complexity score

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 7 05:09:06 PDT 2024


Author: Nikita Popov
Date: 2024-08-07T14:08:35+02:00
New Revision: b74182edaeeddfb10930e44048bf6b16704c45d9

URL: https://github.com/llvm/llvm-project/commit/b74182edaeeddfb10930e44048bf6b16704c45d9
DIFF: https://github.com/llvm/llvm-project/commit/b74182edaeeddfb10930e44048bf6b16704c45d9.diff

LOG: [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.

Added: 
    

Modified: 
    llvm/tools/llvm-reduce/ReducerWorkItem.cpp
    llvm/tools/llvm-reduce/deltas/ReduceInstructionFlags.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/tools/llvm-reduce/ReducerWorkItem.cpp b/llvm/tools/llvm-reduce/ReducerWorkItem.cpp
index 3fa49cbef4ec2..1510e9fb32007 100644
--- a/llvm/tools/llvm-reduce/ReducerWorkItem.cpp
+++ b/llvm/tools/llvm-reduce/ReducerWorkItem.cpp
@@ -643,12 +643,27 @@ static uint64_t computeIRComplexityScoreImpl(const Function &F) {
           ++Score;
         if (OverflowOp->hasNoSignedWrap())
           ++Score;
-      } else if (const auto *GEP = dyn_cast<GEPOperator>(&I)) {
-        if (GEP->isInBounds())
+      } else if (const auto *Trunc = dyn_cast<TruncInst>(&I)) {
+        if (Trunc->hasNoSignedWrap())
+          ++Score;
+        if (Trunc->hasNoUnsignedWrap())
           ++Score;
       } else if (const auto *ExactOp = dyn_cast<PossiblyExactOperator>(&I)) {
         if (ExactOp->isExact())
           ++Score;
+      } else if (const auto *NNI = dyn_cast<PossiblyNonNegInst>(&I)) {
+        if (NNI->hasNonNeg())
+          ++Score;
+      } else if (const auto *PDI = dyn_cast<PossiblyDisjointInst>(&I)) {
+        if (PDI->isDisjoint())
+          ++Score;
+      } else if (const auto *GEP = dyn_cast<GEPOperator>(&I)) {
+        if (GEP->isInBounds())
+          ++Score;
+        if (GEP->hasNoUnsignedSignedWrap())
+          ++Score;
+        if (GEP->hasNoUnsignedWrap())
+          ++Score;
       } else if (const auto *FPOp = dyn_cast<FPMathOperator>(&I)) {
         FastMathFlags FMF = FPOp->getFastMathFlags();
         if (FMF.allowReassoc())

diff  --git a/llvm/tools/llvm-reduce/deltas/ReduceInstructionFlags.cpp b/llvm/tools/llvm-reduce/deltas/ReduceInstructionFlags.cpp
index ba345d3659b22..ff9dde40b2df4 100644
--- a/llvm/tools/llvm-reduce/deltas/ReduceInstructionFlags.cpp
+++ b/llvm/tools/llvm-reduce/deltas/ReduceInstructionFlags.cpp
@@ -20,6 +20,7 @@
 using namespace llvm;
 
 static void reduceFlagsInModule(Oracle &O, ReducerWorkItem &WorkItem) {
+  // Keep this in sync with computeIRComplexityScoreImpl().
   for (Function &F : WorkItem.getModule()) {
     for (Instruction &I : instructions(F)) {
       if (auto *OBO = dyn_cast<OverflowingBinaryOperator>(&I)) {


        


More information about the llvm-commits mailing list