Skip to content

Commit 30c317d

Browse files
committed
SCEVExpander: Don't look at uses of constants
This could be more relaxed, and look for uses of globals in the same function but no tests apparently depend on that.
1 parent fa88dda commit 30c317d

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp

+16-13
Original file line numberDiff line numberDiff line change
@@ -111,20 +111,23 @@ Value *SCEVExpander::ReuseOrCreateCast(Value *V, Type *Ty,
111111

112112
Value *Ret = nullptr;
113113

114-
// Check to see if there is already a cast!
115-
for (User *U : V->users()) {
116-
if (U->getType() != Ty)
117-
continue;
118-
CastInst *CI = dyn_cast<CastInst>(U);
119-
if (!CI || CI->getOpcode() != Op)
120-
continue;
114+
if (!isa<Constant>(V)) {
115+
// Check to see if there is already a cast!
116+
for (User *U : V->users()) {
117+
if (U->getType() != Ty)
118+
continue;
119+
CastInst *CI = dyn_cast<CastInst>(U);
120+
if (!CI || CI->getOpcode() != Op)
121+
continue;
121122

122-
// Found a suitable cast that is at IP or comes before IP. Use it. Note that
123-
// the cast must also properly dominate the Builder's insertion point.
124-
if (IP->getParent() == CI->getParent() && &*BIP != CI &&
125-
(&*IP == CI || CI->comesBefore(&*IP))) {
126-
Ret = CI;
127-
break;
123+
// Found a suitable cast that is at IP or comes before IP. Use it. Note
124+
// that the cast must also properly dominate the Builder's insertion
125+
// point.
126+
if (IP->getParent() == CI->getParent() && &*BIP != CI &&
127+
(&*IP == CI || CI->comesBefore(&*IP))) {
128+
Ret = CI;
129+
break;
130+
}
128131
}
129132
}
130133

0 commit comments

Comments
 (0)