[PATCH] D67595: [PowerPC] Add missing pattern for VSX Scalar Negative Multiply-Subtract Single Precision

Jinsong Ji via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 15 13:39:07 PDT 2019


jsji created this revision.
jsji added reviewers: PowerPC, hfinkel, nemanjai, steven.zhang.
Herald added subscribers: llvm-commits, shchenz, MaskRay, kbarton, hiraditya.
Herald added a project: LLVM.

This was found during review of https://reviews.llvm.org/D66050.
In the simple test of fdiv, we miss to fold

  fneg 2, 2
  xsmaddasp 3, 2, 0

to

  xsnmsubasp 3, 2, 0

We have the patterns for Double Precision and vectors, just missing
Single Precision, the patch add that.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D67595

Files:
  llvm/lib/Target/PowerPC/PPCInstrVSX.td
  llvm/test/CodeGen/PowerPC/fdiv.ll


Index: llvm/test/CodeGen/PowerPC/fdiv.ll
===================================================================
--- llvm/test/CodeGen/PowerPC/fdiv.ll
+++ llvm/test/CodeGen/PowerPC/fdiv.ll
@@ -5,9 +5,8 @@
 ; CHECK-LABEL: foo:
 ; CHECK:       # %bb.0:
 ; CHECK-NEXT:    xsresp 3, 2
-; CHECK-NEXT:    fneg 2, 2
 ; CHECK-NEXT:    xsmulsp 0, 1, 3
-; CHECK-NEXT:    xsmaddasp 1, 2, 0
+; CHECK-NEXT:    xsnmsubasp 1, 0, 2
 ; CHECK-NEXT:    xsmaddasp 0, 3, 1
 ; CHECK-NEXT:    fmr 1, 0
 ; CHECK-NEXT:    blr
Index: llvm/lib/Target/PowerPC/PPCInstrVSX.td
===================================================================
--- llvm/lib/Target/PowerPC/PPCInstrVSX.td
+++ llvm/lib/Target/PowerPC/PPCInstrVSX.td
@@ -1505,6 +1505,13 @@
                           AltVSXFMARel;
   }
 
+  // Additional fnmsub patterns: -a*c + b == -(a*c - b)
+  def : Pat<(fma (fneg f32:$A), f32:$C, f32:$B),
+            (XSNMSUBASP $B, $C, $A)>;
+  def : Pat<(fma f32:$A, (fneg f32:$C), f32:$B),
+            (XSNMSUBASP $B, $C, $A)>;
+
+
   // Single Precision Conversions (FP <-> INT)
   def XSCVSXDSP : XX2Form<60, 312,
                       (outs vssrc:$XT), (ins vsfrc:$XB),


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67595.220252.patch
Type: text/x-patch
Size: 1149 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190915/a0fb2982/attachment.bin>


More information about the llvm-commits mailing list