[llvm] [Transform] Remove redundant condition (PR #107893)

Amr Hesham via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 9 10:27:23 PDT 2024


https://github.com/AmrDeveloper created https://github.com/llvm/llvm-project/pull/107893

Remove redundant condition from  '!A || (A && B)' to '!A || B' 

Fixes: #99799 

>From 3beba7a9ce8aff3203ea3736055e9c8c9a077ef0 Mon Sep 17 00:00:00 2001
From: AmrDeveloper <amr96 at programmer.net>
Date: Mon, 9 Sep 2024 19:26:00 +0200
Subject: [PATCH] [Transform] Remove redundant condition

---
 llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
index c235d2fb2a5bd4..7d87df1805d1ea 100644
--- a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
+++ b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
@@ -770,8 +770,7 @@ static bool unswitchTrivialSwitch(Loop &L, SwitchInst &SI, DominatorTree &DT,
     // instruction in the block.
     auto *TI = BBToCheck.getTerminator();
     bool isUnreachable = isa<UnreachableInst>(TI);
-    return !isUnreachable ||
-           (isUnreachable && (BBToCheck.getFirstNonPHIOrDbg() != TI));
+    return !isUnreachable || (BBToCheck.getFirstNonPHIOrDbg() != TI);
   };
 
   SmallVector<int, 4> ExitCaseIndices;



More information about the llvm-commits mailing list