[InstCombine] Revert FSub optimization from #157757 (#158315)

Since FSub X, 0 gets canoncialised to FAdd X, -0 the said optimization
didn't make much sense for FSub. Remove it from IC and the adjoined
testcase.
This commit is contained in:
Vedant Paranjape
2025-09-12 12:16:31 -04:00
committed by GitHub
parent 2491dc3d6f
commit c45aa5c764
2 changed files with 0 additions and 21 deletions

View File

@@ -3155,16 +3155,6 @@ Instruction *InstCombinerImpl::visitFSub(BinaryOperator &I) {
Value *X, *Y;
Constant *C;
// B = fsub A, 0.0
// Z = Op B
// can be transformed into
// Z = Op A
// Where Op is such that we can ignore sign of 0 in fsub
Value *A;
if (match(&I, m_OneUse(m_FSub(m_Value(A), m_AnyZeroFP()))) &&
canIgnoreSignBitOfZero(*I.use_begin()))
return replaceInstUsesWith(I, A);
Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);
// If Op0 is not -0.0 or we can ignore -0.0: Z - (X - Y) --> Z + (Y - X)
// Canonicalize to fadd to make analysis easier.

View File

@@ -24,14 +24,3 @@ define float @src2(float %arg1) {
%v4 = fsub float %v2, %v3
ret float %v4
}
define float @src_sub(float %arg1) {
; CHECK-LABEL: define float @src_sub(
; CHECK-SAME: float [[ARG1:%.*]]) {
; CHECK-NEXT: [[V3:%.*]] = call float @llvm.fabs.f32(float [[ARG1]])
; CHECK-NEXT: ret float [[V3]]
;
%v2 = fsub float %arg1, 0.000000e+00
%v3 = call float @llvm.fabs.f32(float %v2)
ret float %v3
}