mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 11:13:28 +01:00
[InstCombine] fold fsub+fsub with common operand
This is a sibling to the simplify from: rL339171 llvm-svn: 339266
This commit is contained in:
parent
4899351421
commit
d8df616a92
@ -1907,6 +1907,14 @@ Instruction *InstCombiner::visitFSub(BinaryOperator &I) {
|
||||
return replaceInstUsesWith(I, V);
|
||||
|
||||
if (I.hasAllowReassoc() && I.hasNoSignedZeros()) {
|
||||
// (Y - X) - Y --> -X
|
||||
if (match(Op0, m_FSub(m_Specific(Op1), m_Value(X))))
|
||||
return BinaryOperator::CreateFNegFMF(X, &I);
|
||||
|
||||
// TODO: This performs reassociative folds for FP ops. Some fraction of the
|
||||
// functionality has been subsumed by simple pattern matching here and in
|
||||
// InstSimplify. We should let a dedicated reassociation pass handle more
|
||||
// complex pattern matching and remove this from InstCombine.
|
||||
if (Value *V = FAddCombine(Builder).simplify(&I))
|
||||
return replaceInstUsesWith(I, V);
|
||||
}
|
||||
|
@ -335,8 +335,8 @@ define <2 x float> @fsub_fadd_common_op_fneg_commute_vec(<2 x float> %x, <2 x fl
|
||||
|
||||
define float @fsub_fsub_common_op_fneg(float %x, float %y) {
|
||||
; CHECK-LABEL: @fsub_fsub_common_op_fneg(
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = fsub reassoc nsz float -0.000000e+00, [[X:%.*]]
|
||||
; CHECK-NEXT: ret float [[TMP1]]
|
||||
; CHECK-NEXT: [[R:%.*]] = fsub reassoc nsz float -0.000000e+00, [[X:%.*]]
|
||||
; CHECK-NEXT: ret float [[R]]
|
||||
;
|
||||
%s = fsub float %y, %x
|
||||
%r = fsub reassoc nsz float %s, %y
|
||||
@ -347,8 +347,7 @@ define float @fsub_fsub_common_op_fneg(float %x, float %y) {
|
||||
|
||||
define <2 x float> @fsub_fsub_common_op_fneg_vec(<2 x float> %x, <2 x float> %y) {
|
||||
; CHECK-LABEL: @fsub_fsub_common_op_fneg_vec(
|
||||
; CHECK-NEXT: [[S:%.*]] = fsub <2 x float> [[Y:%.*]], [[X:%.*]]
|
||||
; CHECK-NEXT: [[R:%.*]] = fsub reassoc nsz <2 x float> [[S]], [[Y]]
|
||||
; CHECK-NEXT: [[R:%.*]] = fsub reassoc nsz <2 x float> <float -0.000000e+00, float -0.000000e+00>, [[X:%.*]]
|
||||
; CHECK-NEXT: ret <2 x float> [[R]]
|
||||
;
|
||||
%s = fsub <2 x float> %y, %x
|
||||
|
Loading…
Reference in New Issue
Block a user