Skip to content

Commit 039432c

Browse files
author
Macsen Casaus
committed
match constant V2 value only
removes instruction creation before possible termination of the transform
1 parent f5bcc06 commit 039432c

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

llvm/lib/Transforms/InstCombine/InstructionCombining.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,9 +1363,11 @@ Value *InstCombinerImpl::SimplifySelectsFeedingBinaryOp(BinaryOperator &I,
13631363
if (!match(Masked, m_OneUse(m_And(m_Value(X), m_APInt(C)))))
13641364
return nullptr;
13651365

1366-
Value *V2, *Trunc;
1367-
if (!match(ZExtSel, m_ZExt(m_OneUse(m_Select(m_Specific(Cond), m_Value(V2),
1368-
m_Value(Trunc))))))
1366+
const APInt *V2;
1367+
Value *Trunc;
1368+
if (!match(ZExtSel,
1369+
m_ZExt(m_OneUse(m_Select(m_Specific(Cond), m_APInt(V2),
1370+
m_Value(Trunc))))))
13691371
return nullptr;
13701372

13711373
if (*C != APInt::getBitsSetFrom(X->getType()->getScalarSizeInBits(),
@@ -1376,8 +1378,10 @@ Value *InstCombinerImpl::SimplifySelectsFeedingBinaryOp(BinaryOperator &I,
13761378
if (!match(Trunc, m_Trunc(m_Specific(X))))
13771379
return nullptr;
13781380

1379-
Value *ZExtTrue = Builder.CreateZExt(V2, V1->getType());
1380-
Value *True = simplifyBinOp(Opcode, V1, ZExtTrue, FMF, Q);
1381+
unsigned V1Width = V1->getType()->getScalarSizeInBits();
1382+
APInt ZextV2 = V2->zext(V1Width);
1383+
Value *True = simplifyBinOp(
1384+
Opcode, V1, ConstantInt::get(V1->getType(), ZextV2), FMF, Q);
13811385
if (!True)
13821386
return nullptr;
13831387

0 commit comments

Comments
 (0)