Skip to content

Commit

Permalink
[PowerPC] Adjust the naming and operand order of fnmsub patterns
Browse files Browse the repository at this point in the history
Summary:
This is follow up patch of https://reviews.llvm.org/D67595.
Adjust naming and the Commutable operands for additional patterns
to make it easier to read.

The testcase update also show that we can save some unecessary fmr as
well.

Reviewers: #powerpc, steven.zhang, hfinkel, nemanjai

Reviewed By: #powerpc, nemanjai

Subscribers: wuzish, hiraditya, kbarton, MaskRay, shchenz, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D68112

llvm-svn: 373652
  • Loading branch information
Jinsong Ji committed Oct 3, 2019
1 parent 18350af commit 4a6881e
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 23 deletions.
36 changes: 18 additions & 18 deletions llvm/lib/Target/PowerPC/PPCInstrVSX.td
Original file line number Diff line number Diff line change
Expand Up @@ -1011,21 +1011,21 @@ def : Pat<(f64 (extractelt v2f64:$S, 1)),
(f64 (EXTRACT_SUBREG $S, sub_64))>;
}

// Additional fnmsub patterns: -a*c + b == -(a*c - b)
def : Pat<(fma (fneg f64:$A), f64:$C, f64:$B),
(XSNMSUBADP $B, $C, $A)>;
def : Pat<(fma f64:$A, (fneg f64:$C), f64:$B),
(XSNMSUBADP $B, $C, $A)>;

def : Pat<(fma (fneg v2f64:$A), v2f64:$C, v2f64:$B),
(XVNMSUBADP $B, $C, $A)>;
def : Pat<(fma v2f64:$A, (fneg v2f64:$C), v2f64:$B),
(XVNMSUBADP $B, $C, $A)>;

def : Pat<(fma (fneg v4f32:$A), v4f32:$C, v4f32:$B),
(XVNMSUBASP $B, $C, $A)>;
def : Pat<(fma v4f32:$A, (fneg v4f32:$C), v4f32:$B),
(XVNMSUBASP $B, $C, $A)>;
// Additional fnmsub patterns: -a*b + c == -(a*b - c)
def : Pat<(fma (fneg f64:$A), f64:$B, f64:$C),
(XSNMSUBADP $C, $A, $B)>;
def : Pat<(fma f64:$A, (fneg f64:$B), f64:$C),
(XSNMSUBADP $C, $A, $B)>;

def : Pat<(fma (fneg v2f64:$A), v2f64:$B, v2f64:$C),
(XVNMSUBADP $C, $A, $B)>;
def : Pat<(fma v2f64:$A, (fneg v2f64:$B), v2f64:$C),
(XVNMSUBADP $C, $A, $B)>;

def : Pat<(fma (fneg v4f32:$A), v4f32:$B, v4f32:$C),
(XVNMSUBASP $C, $A, $B)>;
def : Pat<(fma v4f32:$A, (fneg v4f32:$B), v4f32:$C),
(XVNMSUBASP $C, $A, $B)>;

def : Pat<(v2f64 (bitconvert v4f32:$A)),
(COPY_TO_REGCLASS $A, VSRC)>;
Expand Down Expand Up @@ -2656,9 +2656,9 @@ let AddedComplexity = 400, Predicates = [HasP9Vector] in {
(fneg (int_ppc_fmaf128_round_to_odd
f128:$vA, f128:$vB, (fneg f128:$vTi))))]>;

// Additional fnmsub patterns: -a*c + b == -(a*c - b)
def : Pat<(fma (fneg f128:$A), f128:$C, f128:$B), (XSNMSUBQP $B, $C, $A)>;
def : Pat<(fma f128:$A, (fneg f128:$C), f128:$B), (XSNMSUBQP $B, $C, $A)>;
// Additional fnmsub patterns: -a*b + c == -(a*b - c)
def : Pat<(fma (fneg f128:$A), f128:$B, f128:$C), (XSNMSUBQP $C, $A, $B)>;
def : Pat<(fma f128:$A, (fneg f128:$B), f128:$C), (XSNMSUBQP $C, $A, $B)>;

//===--------------------------------------------------------------------===//
// Quad/Double-Precision Compare Instructions:
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/CodeGen/PowerPC/combine-fneg.ll
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ define <4 x double> @fneg_fdiv_splat(double %a0, <4 x double> %a1) {
; CHECK-NEXT: xvredp 2, 0
; CHECK-NEXT: addi 3, 3, .LCPI0_1@toc@l
; CHECK-NEXT: xxswapd 1, 1
; CHECK-NEXT: xvnmsubadp 1, 2, 0
; CHECK-NEXT: xvnmsubadp 1, 0, 2
; CHECK-NEXT: xvmaddadp 2, 2, 1
; CHECK-NEXT: lxvd2x 1, 0, 3
; CHECK-NEXT: xxswapd 1, 1
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/CodeGen/PowerPC/f128-fma.ll
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ entry:
; CHECK-DAG: lxv v[[REG3:[0-9]+]], 0(r3)
; CHECK-DAG: lxv v[[REG4:[0-9]+]], 0(r4)
; CHECK-DAG: lxv v[[REG5:[0-9]+]], 0(r5)
; CHECK: xsnmsubqp v[[REG3]], v[[REG5]], v[[REG4]]
; CHECK: xsnmsubqp v[[REG3]], v[[REG4]], v[[REG5]]
; CHECK-NEXT: stxv v[[REG3]], 0(r6)
; CHECK-NEXT: blr
}
Expand Down
1 change: 0 additions & 1 deletion llvm/test/CodeGen/PowerPC/fma-assoc.ll
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,6 @@ define double @test_FMSUB_ASSOC_EXT3(float %A, float %B, double %C,
; CHECK-VSX-LABEL: test_FMSUB_ASSOC_EXT3:
; CHECK-VSX: xsnmsubmdp
; CHECK-VSX-NEXT: xsnmsubadp
; CHECK-VSX-NEXT: fmr
; CHECK-VSX-NEXT: blr
}

Expand Down
1 change: 0 additions & 1 deletion llvm/test/CodeGen/PowerPC/fma-ext.ll
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ define double @test_FMSUB_EXT2(float %A, float %B, double %C) {

; CHECK-VSX-LABEL: test_FMSUB_EXT2:
; CHECK-VSX: xsnmsubmdp
; CHECK-VSX-NEXT: fmr
; CHECK-VSX-NEXT: blr
}

Expand Down
2 changes: 1 addition & 1 deletion llvm/test/CodeGen/PowerPC/repeated-fp-divisors.ll
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ define <4 x float> @repeated_fp_divisor(float %a, <4 x float> %b) {
; CHECK-NEXT: lvx 4, 0, 3
; CHECK-NEXT: xxspltw 0, 0, 0
; CHECK-NEXT: xvresp 1, 0
; CHECK-NEXT: xvnmsubasp 35, 1, 0
; CHECK-NEXT: xvnmsubasp 35, 0, 1
; CHECK-NEXT: xvmulsp 0, 34, 36
; CHECK-NEXT: xvmaddasp 1, 1, 35
; CHECK-NEXT: xvmulsp 34, 0, 1
Expand Down

0 comments on commit 4a6881e

Please sign in to comment.