Skip to content

Commit 0436fcc

Browse files
committed
[CVP] Fix predicate mismatch
1 parent 398fa6e commit 0436fcc

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -233,21 +233,22 @@ static Value *getValueOnEdge(LazyValueInfo *LVI, Value *Incoming,
233233
// value can never be that constant. In that case replace the incoming
234234
// value with the other value of the select. This often allows us to
235235
// remove the select later.
236+
if (!SI->getType()->isFPOrFPVectorTy()) {
237+
// The "false" case
238+
if (auto *C = dyn_cast<Constant>(SI->getFalseValue()))
239+
if (auto *Res = dyn_cast_or_null<ConstantInt>(LVI->getPredicateOnEdge(
240+
ICmpInst::ICMP_EQ, SI, C, From, To, CxtI));
241+
Res && Res->isZero())
242+
return SI->getTrueValue();
236243

237-
// The "false" case
238-
if (auto *C = dyn_cast<Constant>(SI->getFalseValue()))
239-
if (auto *Res = dyn_cast_or_null<ConstantInt>(
240-
LVI->getPredicateOnEdge(ICmpInst::ICMP_EQ, SI, C, From, To, CxtI));
241-
Res && Res->isZero())
242-
return SI->getTrueValue();
243-
244-
// The "true" case,
245-
// similar to the select "false" case, but try the select "true" value
246-
if (auto *C = dyn_cast<Constant>(SI->getTrueValue()))
247-
if (auto *Res = dyn_cast_or_null<ConstantInt>(
248-
LVI->getPredicateOnEdge(ICmpInst::ICMP_EQ, SI, C, From, To, CxtI));
249-
Res && Res->isZero())
250-
return SI->getFalseValue();
244+
// The "true" case,
245+
// similar to the select "false" case, but try the select "true" value
246+
if (auto *C = dyn_cast<Constant>(SI->getTrueValue()))
247+
if (auto *Res = dyn_cast_or_null<ConstantInt>(LVI->getPredicateOnEdge(
248+
ICmpInst::ICMP_EQ, SI, C, From, To, CxtI));
249+
Res && Res->isZero())
250+
return SI->getFalseValue();
251+
}
251252

252253
return nullptr;
253254
}

0 commit comments

Comments
 (0)