mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-15 22:06:32 +00:00
SCEVExpander: Don't look at uses of constants (#134691)
This could be more relaxed, and look for uses of globals in the same function but no tests apparently depend on that.
This commit is contained in:
parent
393c783a10
commit
30ae47eeef
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user