-
Notifications
You must be signed in to change notification settings - Fork 14.3k
SCEVExpander: Don't look at uses of constants #134691
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
SCEVExpander: Don't look at uses of constants #134691
Conversation
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
@llvm/pr-subscribers-llvm-transforms Author: Matt Arsenault (arsenm) ChangesThis could be more relaxed, and look for uses of globals in Full diff: https://github.com/llvm/llvm-project/pull/134691.diff 1 Files Affected:
diff --git a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
index 41bf202230e22..e25ec6c3b2a58 100644
--- a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
+++ b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
@@ -111,20 +111,23 @@ Value *SCEVExpander::ReuseOrCreateCast(Value *V, Type *Ty,
Value *Ret = nullptr;
- // Check to see if there is already a cast!
- for (User *U : V->users()) {
- if (U->getType() != Ty)
- continue;
- CastInst *CI = dyn_cast<CastInst>(U);
- if (!CI || CI->getOpcode() != Op)
- continue;
+ if (!isa<Constant>(V)) {
+ // Check to see if there is already a cast!
+ for (User *U : V->users()) {
+ if (U->getType() != Ty)
+ continue;
+ CastInst *CI = dyn_cast<CastInst>(U);
+ if (!CI || CI->getOpcode() != Op)
+ continue;
- // Found a suitable cast that is at IP or comes before IP. Use it. Note that
- // the cast must also properly dominate the Builder's insertion point.
- if (IP->getParent() == CI->getParent() && &*BIP != CI &&
- (&*IP == CI || CI->comesBefore(&*IP))) {
- Ret = CI;
- break;
+ // Found a suitable cast that is at IP or comes before IP. Use it. Note
+ // that the cast must also properly dominate the Builder's insertion
+ // point.
+ if (IP->getParent() == CI->getParent() && &*BIP != CI &&
+ (&*IP == CI || CI->comesBefore(&*IP))) {
+ Ret = CI;
+ break;
+ }
}
}
|
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
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
05c26c5
to
7954b84
Compare
f543f05
to
aedd9ec
Compare
7954b84
to
fa88dda
Compare
aedd9ec
to
30c317d
Compare
This could be more relaxed, and look for uses of globals in the same function but no tests apparently depend on that.
fa88dda
to
a0cee0a
Compare
30c317d
to
36377c3
Compare
This could be more relaxed, and look for uses of globals in the same function but no tests apparently depend on that.
This could be more relaxed, and look for uses of globals in the same function but no tests apparently depend on that.
This could be more relaxed, and look for uses of globals in
the same function but no tests apparently depend on that.