-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[LoopUnswitch] Remove redundant condition. (NFC) #107893
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-llvm-transforms Author: Amr Hesham (AmrDeveloper) ChangesRemove redundant condition from '!A || (A && B)' to '!A || B' Fixes: #99799 Full diff: https://github.com/llvm/llvm-project/pull/107893.diff 1 Files Affected:
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;
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the patch. Would be good to update the title to be more precise, e.g. something like [LoopUnswitch] Remove redundant condition. (NFC)
@@ -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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return !isUnreachable || (BBToCheck.getFirstNonPHIOrDbg() != TI); | |
return !isUnreachable || BBToCheck.getFirstNonPHIOrDbg() != TI; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure i will update it now, thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
3beba7a
to
7898cd1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
Remove redundant condition from '!A || (A && B)' to '!A || B'
Fixes: #99799