[llvm] r294011 - [NVPTX] Enable combineRepeatedFPDivisors for NVPTX.
Justin Lebar via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 3 07:13:50 PST 2017
Author: jlebar
Date: Fri Feb 3 09:13:50 2017
New Revision: 294011
URL: http://llvm.org/viewvc/llvm-project?rev=294011&view=rev
Log:
[NVPTX] Enable combineRepeatedFPDivisors for NVPTX.
Reviewers: tra
Subscribers: jholewinski, llvm-commits
Differential Revision: https://reviews.llvm.org/D29477
Modified:
llvm/trunk/lib/Target/NVPTX/NVPTXISelLowering.h
llvm/trunk/test/CodeGen/NVPTX/fast-math.ll
Modified: llvm/trunk/lib/Target/NVPTX/NVPTXISelLowering.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/NVPTX/NVPTXISelLowering.h?rev=294011&r1=294010&r2=294011&view=diff
==============================================================================
--- llvm/trunk/lib/Target/NVPTX/NVPTXISelLowering.h (original)
+++ llvm/trunk/lib/Target/NVPTX/NVPTXISelLowering.h Fri Feb 3 09:13:50 2017
@@ -530,6 +530,8 @@ public:
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;
Modified: llvm/trunk/test/CodeGen/NVPTX/fast-math.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/NVPTX/fast-math.ll?rev=294011&r1=294010&r2=294011&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/NVPTX/fast-math.ll (original)
+++ llvm/trunk/test/CodeGen/NVPTX/fast-math.ll Fri Feb 3 09:13:50 2017
@@ -117,5 +117,49 @@ define float @fcos_approx(float %a) #0 {
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" }
More information about the llvm-commits
mailing list