[PATCH] D29477: [NVPTX] Enable combineRepeatedFPDivisors for NVPTX.

Justin Lebar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 3 07:25:20 PST 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL294011: [NVPTX] Enable combineRepeatedFPDivisors for NVPTX. (authored by jlebar).

Changed prior to commit:
  https://reviews.llvm.org/D29477?vs=86917&id=86960#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D29477

Files:
  llvm/trunk/lib/Target/NVPTX/NVPTXISelLowering.h
  llvm/trunk/test/CodeGen/NVPTX/fast-math.ll


Index: llvm/trunk/lib/Target/NVPTX/NVPTXISelLowering.h
===================================================================
--- llvm/trunk/lib/Target/NVPTX/NVPTXISelLowering.h
+++ llvm/trunk/lib/Target/NVPTX/NVPTXISelLowering.h
@@ -530,6 +530,8 @@
                           int &ExtraSteps, bool &UseOneConst,
                           bool Reciprocal) const override;
 
+  unsigned combineRepeatedFPDivisors() const override { return 2; }
+
   bool allowFMA(MachineFunction &MF, CodeGenOpt::Level OptLevel) const;
   bool allowUnsafeFPMath(MachineFunction &MF) const;
 
Index: llvm/trunk/test/CodeGen/NVPTX/fast-math.ll
===================================================================
--- llvm/trunk/test/CodeGen/NVPTX/fast-math.ll
+++ llvm/trunk/test/CodeGen/NVPTX/fast-math.ll
@@ -117,5 +117,49 @@
   ret float %r
 }
 
+; CHECK-LABEL: repeated_div_recip_allowed
+define float @repeated_div_recip_allowed(i1 %pred, float %a, float %b, float %divisor) {
+; CHECK: rcp.rn.f32
+; CHECK: mul.rn.f32
+; CHECK: mul.rn.f32
+  %x = fdiv arcp float %a, %divisor
+  %y = fdiv arcp float %b, %divisor
+  %z = select i1 %pred, float %x, float %y
+  ret float %z
+}
+
+; CHECK-LABEL: repeated_div_recip_allowed_ftz
+define float @repeated_div_recip_allowed_ftz(i1 %pred, float %a, float %b, float %divisor) #1 {
+; CHECK: rcp.rn.ftz.f32
+; CHECK: mul.rn.ftz.f32
+; CHECK: mul.rn.ftz.f32
+  %x = fdiv arcp float %a, %divisor
+  %y = fdiv arcp float %b, %divisor
+  %z = select i1 %pred, float %x, float %y
+  ret float %z
+}
+
+; CHECK-LABEL: repeated_div_fast
+define float @repeated_div_fast(i1 %pred, float %a, float %b, float %divisor) #0 {
+; CHECK: rcp.approx.f32
+; CHECK: mul.f32
+; CHECK: mul.f32
+  %x = fdiv float %a, %divisor
+  %y = fdiv float %b, %divisor
+  %z = select i1 %pred, float %x, float %y
+  ret float %z
+}
+
+; CHECK-LABEL: repeated_div_fast_ftz
+define float @repeated_div_fast_ftz(i1 %pred, float %a, float %b, float %divisor) #0 #1 {
+; CHECK: rcp.approx.ftz.f32
+; CHECK: mul.ftz.f32
+; CHECK: mul.ftz.f32
+  %x = fdiv float %a, %divisor
+  %y = fdiv float %b, %divisor
+  %z = select i1 %pred, float %x, float %y
+  ret float %z
+}
+
 attributes #0 = { "unsafe-fp-math" = "true" }
 attributes #1 = { "nvptx-f32ftz" = "true" }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29477.86960.patch
Type: text/x-patch
Size: 2250 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170203/4b53337b/attachment.bin>


More information about the llvm-commits mailing list