Skip to content

Commit c45aa5c

Browse files
[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.
1 parent 2491dc3 commit c45aa5c

File tree

2 files changed

+0
-21
lines changed

2 files changed

+0
-21
lines changed

llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3155,16 +3155,6 @@ Instruction *InstCombinerImpl::visitFSub(BinaryOperator &I) {
31553155
Value *X, *Y;
31563156
Constant *C;
31573157

3158-
// B = fsub A, 0.0
3159-
// Z = Op B
3160-
// can be transformed into
3161-
// Z = Op A
3162-
// Where Op is such that we can ignore sign of 0 in fsub
3163-
Value *A;
3164-
if (match(&I, m_OneUse(m_FSub(m_Value(A), m_AnyZeroFP()))) &&
3165-
canIgnoreSignBitOfZero(*I.use_begin()))
3166-
return replaceInstUsesWith(I, A);
3167-
31683158
Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);
31693159
// If Op0 is not -0.0 or we can ignore -0.0: Z - (X - Y) --> Z + (Y - X)
31703160
// Canonicalize to fadd to make analysis easier.

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

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,3 @@ define float @src2(float %arg1) {
2424
%v4 = fsub float %v2, %v3
2525
ret float %v4
2626
}
27-
28-
define float @src_sub(float %arg1) {
29-
; CHECK-LABEL: define float @src_sub(
30-
; CHECK-SAME: float [[ARG1:%.*]]) {
31-
; CHECK-NEXT: [[V3:%.*]] = call float @llvm.fabs.f32(float [[ARG1]])
32-
; CHECK-NEXT: ret float [[V3]]
33-
;
34-
%v2 = fsub float %arg1, 0.000000e+00
35-
%v3 = call float @llvm.fabs.f32(float %v2)
36-
ret float %v3
37-
}

0 commit comments

Comments
 (0)