Skip to content

Commit c00d2bc

Browse files
committed
[InstCombine] Regard zext nneg as sext when folding add(zext neg(add))
Signed-off-by: ZelinMa557 <[email protected]>
1 parent 58d4470 commit c00d2bc

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -828,9 +828,10 @@ static Instruction *foldNoWrapAdd(BinaryOperator &Add,
828828

829829
// More general combining of constants in the wide type.
830830
// (sext (X +nsw NarrowC)) + C --> (sext X) + (sext(NarrowC) + C)
831+
// or (zext nneg (X +nsw NarrowC)) + C --> (sext X) + (sext(NarrowC) + C)
831832
Constant *NarrowC;
832-
if (match(Op0,
833-
m_OneUse(m_SExt(m_NSWAddLike(m_Value(X), m_Constant(NarrowC)))))) {
833+
if (match(Op0, m_OneUse(m_SExtLike(
834+
m_NSWAddLike(m_Value(X), m_Constant(NarrowC)))))) {
834835
Value *WideC = Builder.CreateSExt(NarrowC, Ty);
835836
Value *NewC = Builder.CreateAdd(WideC, Op1C);
836837
Value *WideX = Builder.CreateSExt(X, Ty);
@@ -844,7 +845,6 @@ static Instruction *foldNoWrapAdd(BinaryOperator &Add,
844845
Value *WideX = Builder.CreateZExt(X, Ty);
845846
return BinaryOperator::CreateAdd(WideX, NewC);
846847
}
847-
848848
return nullptr;
849849
}
850850

0 commit comments

Comments
 (0)