llvm-reduce: Check shouldKeep before trying to reduce operands
authorMatt Arsenault <Matthew.Arsenault@amd.com>
Thu, 9 Jun 2022 15:17:09 +0000 (11:17 -0400)
committerMatt Arsenault <Matthew.Arsenault@amd.com>
Mon, 27 Jun 2022 17:16:15 +0000 (13:16 -0400)
No point doing the more complicated check first.

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

index 49a4837..9c713f5 100644 (file)
@@ -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);
+        }
       }
     }
   }