Skip to content

Commit 3aaf155

Browse files
moved opt to IC from InstSimplify
1 parent b230ed7 commit 3aaf155

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

llvm/lib/Analysis/InstructionSimplify.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5710,9 +5710,7 @@ simplifyFAddInst(Value *Op0, Value *Op1, FastMathFlags FMF,
57105710
// fadd X, 0 ==> X, when we know X is not -0
57115711
if (canIgnoreSNaN(ExBehavior, FMF))
57125712
if (match(Op1, m_PosZeroFP()) &&
5713-
(FMF.noSignedZeros() || cannotBeNegativeZero(Op0, Q) ||
5714-
(Q.CxtI && !Q.CxtI->use_empty() &&
5715-
canIgnoreSignBitOfZero(*(Q.CxtI->use_begin())))))
5713+
(FMF.noSignedZeros() || cannotBeNegativeZero(Op0, Q)))
57165714
return Op0;
57175715

57185716
if (!isDefaultFPEnvironment(ExBehavior, Rounding))

llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2002,6 +2002,16 @@ Instruction *InstCombinerImpl::visitFAdd(BinaryOperator &I) {
20022002
if (Instruction *FoldedFAdd = foldBinOpIntoSelectOrPhi(I))
20032003
return FoldedFAdd;
20042004

2005+
// B = fadd A, 0
2006+
// Z = Op B
2007+
// can be transformed into
2008+
// Z = Op A
2009+
// Where Op is such that we can ignore sign of 0 in fadd
2010+
Value *A;
2011+
if (match(&I, m_c_FAdd(m_Value(A), m_AnyZeroFP())) && !I.use_empty() &&
2012+
canIgnoreSignBitOfZero(*I.use_begin()))
2013+
return replaceInstUsesWith(I, A);
2014+
20052015
// (-X) + Y --> Y - X
20062016
Value *X, *Y;
20072017
if (match(&I, m_c_FAdd(m_FNeg(m_Value(X)), m_Value(Y))))

llvm/test/Transforms/InstSimplify/fold-fadd-with-zero-gh154238.ll renamed to llvm/test/Transforms/InstCombine/fold-fadd-with-zero-gh154238.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
2-
; RUN: opt < %s -passes=instsimplify -S | FileCheck %s
2+
; RUN: opt < %s -passes=instcombine -S | FileCheck %s
33
define float @src(float %arg1) {
44
; CHECK-LABEL: define float @src(
55
; CHECK-SAME: float [[ARG1:%.*]]) {

0 commit comments

Comments
 (0)