[llvm] 62b5aa9 - llvm-reduce: Check shouldKeep before trying to reduce operands

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 27 10:16:19 PDT 2022


Author: Matt Arsenault
Date: 2022-06-27T13:16:15-04:00
New Revision: 62b5aa984e845b95548ce85b4ecdd41a8683ae6b

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

LOG: llvm-reduce: Check shouldKeep before trying to reduce operands

No point doing the more complicated check first.

Added: 
    

Modified: 
    llvm/tools/llvm-reduce/deltas/ReduceOperands.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/tools/llvm-reduce/deltas/ReduceOperands.cpp b/llvm/tools/llvm-reduce/deltas/ReduceOperands.cpp
index 49a48373c7e5f..9c713f56cbb51 100644
--- a/llvm/tools/llvm-reduce/deltas/ReduceOperands.cpp
+++ b/llvm/tools/llvm-reduce/deltas/ReduceOperands.cpp
@@ -23,9 +23,10 @@ extractOperandsFromModule(Oracle &O, Module &Program,
   for (auto &F : Program.functions()) {
     for (auto &I : instructions(&F)) {
       for (auto &Op : I.operands()) {
-        Value *Reduced = ReduceValue(Op);
-        if (Reduced && !O.shouldKeep())
-          Op.set(Reduced);
+        if (!O.shouldKeep()) {
+          if (Value *Reduced = ReduceValue(Op))
+            Op.set(Reduced);
+        }
       }
     }
   }


        


More information about the llvm-commits mailing list