[llvm] [BOLT][NFC] Simplify successor check (PR #91980)

via llvm-commits llvm-commits at lists.llvm.org
Mon May 13 10:16:19 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-bolt

Author: Nathan Sidwell (urnathan)

<details>
<summary>Changes</summary>

I found the logic here confusing, the expression is over-parenthesized, and IMHO `boolean ? true-case : false-case` is clearer than `(boolean && true-case) || (!boolean && false-case)`.

---
Full diff: https://github.com/llvm/llvm-project/pull/91980.diff


1 Files Affected:

- (modified) bolt/lib/Core/BinaryBasicBlock.cpp (+4-5) 


``````````diff
diff --git a/bolt/lib/Core/BinaryBasicBlock.cpp b/bolt/lib/Core/BinaryBasicBlock.cpp
index 4a83fece0e43d..a4b9a7f558cd8 100644
--- a/bolt/lib/Core/BinaryBasicBlock.cpp
+++ b/bolt/lib/Core/BinaryBasicBlock.cpp
@@ -131,11 +131,10 @@ bool BinaryBasicBlock::validateSuccessorInvariants() {
         break;
       }
       case 2:
-        Valid = (CondBranch &&
-                 (TBB == getConditionalSuccessor(true)->getLabel() &&
-                  ((!UncondBranch && !FBB) ||
-                   (UncondBranch &&
-                    FBB == getConditionalSuccessor(false)->getLabel()))));
+        Valid =
+            CondBranch && TBB == getConditionalSuccessor(true)->getLabel() &&
+            (UncondBranch ? FBB == getConditionalSuccessor(false)->getLabel()
+                          : !FBB);
         break;
       }
     }

``````````

</details>


https://github.com/llvm/llvm-project/pull/91980


More information about the llvm-commits mailing list