Skip to content

Commit fe3b3ab

Browse files
Review fix 4
Change-Id: I97f0ba5e8c41518f5cdf1322cfb5e3ec6681025e
1 parent 453332d commit fe3b3ab

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

llvm/lib/Transforms/InstCombine/InstructionCombining.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5184,19 +5184,17 @@ Instruction *InstCombinerImpl::visitFreeze(FreezeInst &I) {
51845184
// phi(freeze(undef), C, C). Choose C for freeze so the PHI can be
51855185
// removed.
51865186
Constant *BestValue = nullptr;
5187-
Constant *C = nullptr;
51885187
for (Value *V : PN.incoming_values()) {
51895188
if (match(V, m_Freeze(m_Undef())))
51905189
continue;
51915190

5192-
if (!isa<Constant>(V))
5191+
Constant *C = dyn_cast<Constant>(V);
5192+
if (!C)
51935193
return nullptr;
51945194

5195-
if (!isGuaranteedNotToBeUndefOrPoison(V))
5195+
if (!isGuaranteedNotToBeUndefOrPoison(C))
51965196
return nullptr;
51975197

5198-
C = cast<Constant>(V);
5199-
52005198
if (BestValue && BestValue != C)
52015199
return nullptr;
52025200

@@ -5206,7 +5204,6 @@ Instruction *InstCombinerImpl::visitFreeze(FreezeInst &I) {
52065204
};
52075205

52085206
Value *NullValue = Constant::getNullValue(Ty);
5209-
52105207
Value *BestValue = nullptr;
52115208
for (auto *U : I.users()) {
52125209
Value *V = NullValue;
@@ -5218,8 +5215,7 @@ Instruction *InstCombinerImpl::visitFreeze(FreezeInst &I) {
52185215
if (!isGuaranteedNotToBeUndefOrPoison(V, &AC, &I, &DT))
52195216
V = NullValue;
52205217
} else if (auto *PHI = dyn_cast<PHINode>(U)) {
5221-
Value *MaybeV = pickCommonConstantFromPHI(*PHI);
5222-
if (MaybeV)
5218+
if (Value *MaybeV = pickCommonConstantFromPHI(*PHI))
52235219
V = MaybeV;
52245220
}
52255221

0 commit comments

Comments
 (0)