2018-05-03 19:41:37 +02:00
|
|
|
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
|
|
|
|
; REQUIRES: asserts
|
2018-05-03 20:49:35 +02:00
|
|
|
; RUN: llc < %s -mtriple=powerpc64le -debug-only=isel -o /dev/null 2>&1 | FileCheck %s --check-prefix=FMFDEBUG
|
|
|
|
; RUN: llc < %s -mtriple=powerpc64le | FileCheck %s --check-prefix=FMF
|
2018-05-14 23:17:49 +02:00
|
|
|
; RUN: llc < %s -mtriple=powerpc64le -debug-only=isel -o /dev/null 2>&1 -enable-unsafe-fp-math -enable-no-nans-fp-math | FileCheck %s --check-prefix=GLOBALDEBUG
|
|
|
|
; RUN: llc < %s -mtriple=powerpc64le -enable-unsafe-fp-math -enable-no-nans-fp-math | FileCheck %s --check-prefix=GLOBAL
|
2018-05-03 19:41:37 +02:00
|
|
|
|
|
|
|
; Test FP transforms using instruction/node-level fast-math-flags.
|
|
|
|
; We're also checking debug output to verify that FMF is propagated to the newly created nodes.
|
|
|
|
; The run with the global unsafe param tests the pre-FMF behavior using regular instructions/nodes.
|
|
|
|
|
|
|
|
declare float @llvm.fma.f32(float, float, float)
|
|
|
|
declare float @llvm.sqrt.f32(float)
|
|
|
|
|
|
|
|
; X * Y + Z --> fma(X, Y, Z)
|
|
|
|
|
|
|
|
; FMFDEBUG-LABEL: Optimized lowered selection DAG: %bb.0 'fmul_fadd_contract1:'
|
Utilize new SDNode flag functionality to expand current support for fma
Summary: This patch originated from D47388 and is a proper subset of the originating changes, containing only the fmf optimization guard extensions.
Reviewers: spatel, hfinkel, wristow, arsenm, javed.absar, rampitec, nhaehnle, nemanjai
Reviewed By: rampitec, nhaehnle
Subscribers: tpr, nemanjai, wdng
Differential Revision: https://reviews.llvm.org/D47918
llvm-svn: 334876
2018-06-16 02:03:06 +02:00
|
|
|
; FMFDEBUG: fma contract {{t[0-9]+}}, {{t[0-9]+}}, {{t[0-9]+}}
|
2018-05-03 19:41:37 +02:00
|
|
|
; FMFDEBUG: Type-legalized selection DAG: %bb.0 'fmul_fadd_contract1:'
|
|
|
|
|
|
|
|
define float @fmul_fadd_contract1(float %x, float %y, float %z) {
|
|
|
|
; FMF-LABEL: fmul_fadd_contract1:
|
|
|
|
; FMF: # %bb.0:
|
Utilize new SDNode flag functionality to expand current support for fma
Summary: This patch originated from D47388 and is a proper subset of the originating changes, containing only the fmf optimization guard extensions.
Reviewers: spatel, hfinkel, wristow, arsenm, javed.absar, rampitec, nhaehnle, nemanjai
Reviewed By: rampitec, nhaehnle
Subscribers: tpr, nemanjai, wdng
Differential Revision: https://reviews.llvm.org/D47918
llvm-svn: 334876
2018-06-16 02:03:06 +02:00
|
|
|
; FMF-NEXT: xsmaddasp 3, 1, 2
|
|
|
|
; FMF-NEXT: fmr 1, 3
|
2018-05-03 19:41:37 +02:00
|
|
|
; FMF-NEXT: blr
|
|
|
|
;
|
|
|
|
; GLOBAL-LABEL: fmul_fadd_contract1:
|
|
|
|
; GLOBAL: # %bb.0:
|
|
|
|
; GLOBAL-NEXT: xsmaddasp 3, 1, 2
|
|
|
|
; GLOBAL-NEXT: fmr 1, 3
|
|
|
|
; GLOBAL-NEXT: blr
|
|
|
|
%mul = fmul float %x, %y
|
|
|
|
%add = fadd contract float %mul, %z
|
|
|
|
ret float %add
|
|
|
|
}
|
|
|
|
|
|
|
|
; This shouldn't change anything - the intermediate fmul result is now also flagged.
|
|
|
|
|
|
|
|
; FMFDEBUG-LABEL: Optimized lowered selection DAG: %bb.0 'fmul_fadd_contract2:'
|
2018-06-08 00:49:09 +02:00
|
|
|
; FMFDEBUG: fma contract {{t[0-9]+}}, {{t[0-9]+}}, {{t[0-9]+}}
|
2018-05-03 19:41:37 +02:00
|
|
|
; FMFDEBUG: Type-legalized selection DAG: %bb.0 'fmul_fadd_contract2:'
|
|
|
|
|
|
|
|
define float @fmul_fadd_contract2(float %x, float %y, float %z) {
|
|
|
|
; FMF-LABEL: fmul_fadd_contract2:
|
|
|
|
; FMF: # %bb.0:
|
|
|
|
; FMF-NEXT: xsmaddasp 3, 1, 2
|
|
|
|
; FMF-NEXT: fmr 1, 3
|
|
|
|
; FMF-NEXT: blr
|
|
|
|
;
|
|
|
|
; GLOBAL-LABEL: fmul_fadd_contract2:
|
|
|
|
; GLOBAL: # %bb.0:
|
|
|
|
; GLOBAL-NEXT: xsmaddasp 3, 1, 2
|
|
|
|
; GLOBAL-NEXT: fmr 1, 3
|
|
|
|
; GLOBAL-NEXT: blr
|
|
|
|
%mul = fmul contract float %x, %y
|
|
|
|
%add = fadd contract float %mul, %z
|
|
|
|
ret float %add
|
|
|
|
}
|
|
|
|
|
|
|
|
; Reassociation implies that FMA contraction is allowed.
|
|
|
|
|
|
|
|
; FMFDEBUG-LABEL: Optimized lowered selection DAG: %bb.0 'fmul_fadd_reassoc1:'
|
Utilize new SDNode flag functionality to expand current support for fma
Summary: This patch originated from D47388 and is a proper subset of the originating changes, containing only the fmf optimization guard extensions.
Reviewers: spatel, hfinkel, wristow, arsenm, javed.absar, rampitec, nhaehnle, nemanjai
Reviewed By: rampitec, nhaehnle
Subscribers: tpr, nemanjai, wdng
Differential Revision: https://reviews.llvm.org/D47918
llvm-svn: 334876
2018-06-16 02:03:06 +02:00
|
|
|
; FMFDEBUG: fma reassoc {{t[0-9]+}}, {{t[0-9]+}}, {{t[0-9]+}}
|
2018-05-03 19:41:37 +02:00
|
|
|
; FMFDEBUG: Type-legalized selection DAG: %bb.0 'fmul_fadd_reassoc1:'
|
|
|
|
|
|
|
|
define float @fmul_fadd_reassoc1(float %x, float %y, float %z) {
|
|
|
|
; FMF-LABEL: fmul_fadd_reassoc1:
|
|
|
|
; FMF: # %bb.0:
|
Utilize new SDNode flag functionality to expand current support for fma
Summary: This patch originated from D47388 and is a proper subset of the originating changes, containing only the fmf optimization guard extensions.
Reviewers: spatel, hfinkel, wristow, arsenm, javed.absar, rampitec, nhaehnle, nemanjai
Reviewed By: rampitec, nhaehnle
Subscribers: tpr, nemanjai, wdng
Differential Revision: https://reviews.llvm.org/D47918
llvm-svn: 334876
2018-06-16 02:03:06 +02:00
|
|
|
; FMF-NEXT: xsmaddasp 3, 1, 2
|
|
|
|
; FMF-NEXT: fmr 1, 3
|
2018-05-03 19:41:37 +02:00
|
|
|
; FMF-NEXT: blr
|
|
|
|
;
|
|
|
|
; GLOBAL-LABEL: fmul_fadd_reassoc1:
|
|
|
|
; GLOBAL: # %bb.0:
|
|
|
|
; GLOBAL-NEXT: xsmaddasp 3, 1, 2
|
|
|
|
; GLOBAL-NEXT: fmr 1, 3
|
|
|
|
; GLOBAL-NEXT: blr
|
|
|
|
%mul = fmul float %x, %y
|
|
|
|
%add = fadd reassoc float %mul, %z
|
|
|
|
ret float %add
|
|
|
|
}
|
|
|
|
|
|
|
|
; This shouldn't change anything - the intermediate fmul result is now also flagged.
|
|
|
|
|
|
|
|
; FMFDEBUG-LABEL: Optimized lowered selection DAG: %bb.0 'fmul_fadd_reassoc2:'
|
2018-06-08 00:49:09 +02:00
|
|
|
; FMFDEBUG: fma reassoc {{t[0-9]+}}, {{t[0-9]+}}
|
2018-05-03 19:41:37 +02:00
|
|
|
; FMFDEBUG: Type-legalized selection DAG: %bb.0 'fmul_fadd_reassoc2:'
|
|
|
|
|
|
|
|
define float @fmul_fadd_reassoc2(float %x, float %y, float %z) {
|
|
|
|
; FMF-LABEL: fmul_fadd_reassoc2:
|
|
|
|
; FMF: # %bb.0:
|
Fast Math Flag mapping into SDNode
Summary: Adding support for Fast flags in the SDNode to leverage fast math sub flag usage.
Reviewers: spatel, arsenm, jbhateja, hfinkel, escha, qcolombet, echristo, wristow, javed.absar
Reviewed By: spatel
Subscribers: llvm-commits, rampitec, nhaehnle, tstellar, FarhanaAleen, nemanjai, javed.absar, jbhateja, hfinkel, wdng
Differential Revision: https://reviews.llvm.org/D45710
llvm-svn: 331547
2018-05-04 20:48:20 +02:00
|
|
|
; FMF-NEXT: xsmaddasp 3, 1, 2
|
|
|
|
; FMF-NEXT: fmr 1, 3
|
2018-05-03 19:41:37 +02:00
|
|
|
; FMF-NEXT: blr
|
|
|
|
;
|
|
|
|
; GLOBAL-LABEL: fmul_fadd_reassoc2:
|
|
|
|
; GLOBAL: # %bb.0:
|
|
|
|
; GLOBAL-NEXT: xsmaddasp 3, 1, 2
|
|
|
|
; GLOBAL-NEXT: fmr 1, 3
|
|
|
|
; GLOBAL-NEXT: blr
|
|
|
|
%mul = fmul reassoc float %x, %y
|
|
|
|
%add = fadd reassoc float %mul, %z
|
|
|
|
ret float %add
|
|
|
|
}
|
|
|
|
|
|
|
|
; The fadd is now fully 'fast'. This implies that contraction is allowed.
|
|
|
|
|
|
|
|
; FMFDEBUG-LABEL: Optimized lowered selection DAG: %bb.0 'fmul_fadd_fast1:'
|
2018-06-08 00:49:09 +02:00
|
|
|
; FMFDEBUG: fma nnan ninf nsz arcp contract afn reassoc {{t[0-9]+}}, {{t[0-9]+}}, {{t[0-9]+}}
|
2018-05-03 19:41:37 +02:00
|
|
|
; FMFDEBUG: Type-legalized selection DAG: %bb.0 'fmul_fadd_fast1:'
|
|
|
|
|
|
|
|
define float @fmul_fadd_fast1(float %x, float %y, float %z) {
|
|
|
|
; FMF-LABEL: fmul_fadd_fast1:
|
|
|
|
; FMF: # %bb.0:
|
|
|
|
; FMF-NEXT: xsmaddasp 3, 1, 2
|
|
|
|
; FMF-NEXT: fmr 1, 3
|
|
|
|
; FMF-NEXT: blr
|
|
|
|
;
|
|
|
|
; GLOBAL-LABEL: fmul_fadd_fast1:
|
|
|
|
; GLOBAL: # %bb.0:
|
|
|
|
; GLOBAL-NEXT: xsmaddasp 3, 1, 2
|
|
|
|
; GLOBAL-NEXT: fmr 1, 3
|
|
|
|
; GLOBAL-NEXT: blr
|
|
|
|
%mul = fmul fast float %x, %y
|
|
|
|
%add = fadd fast float %mul, %z
|
|
|
|
ret float %add
|
|
|
|
}
|
|
|
|
|
|
|
|
; This shouldn't change anything - the intermediate fmul result is now also flagged.
|
|
|
|
|
|
|
|
; FMFDEBUG-LABEL: Optimized lowered selection DAG: %bb.0 'fmul_fadd_fast2:'
|
2018-06-08 00:49:09 +02:00
|
|
|
; FMFDEBUG: fma nnan ninf nsz arcp contract afn reassoc {{t[0-9]+}}, {{t[0-9]+}}, {{t[0-9]+}}
|
2018-05-03 19:41:37 +02:00
|
|
|
; FMFDEBUG: Type-legalized selection DAG: %bb.0 'fmul_fadd_fast2:'
|
|
|
|
|
|
|
|
define float @fmul_fadd_fast2(float %x, float %y, float %z) {
|
|
|
|
; FMF-LABEL: fmul_fadd_fast2:
|
|
|
|
; FMF: # %bb.0:
|
|
|
|
; FMF-NEXT: xsmaddasp 3, 1, 2
|
|
|
|
; FMF-NEXT: fmr 1, 3
|
|
|
|
; FMF-NEXT: blr
|
|
|
|
;
|
|
|
|
; GLOBAL-LABEL: fmul_fadd_fast2:
|
|
|
|
; GLOBAL: # %bb.0:
|
|
|
|
; GLOBAL-NEXT: xsmaddasp 3, 1, 2
|
|
|
|
; GLOBAL-NEXT: fmr 1, 3
|
|
|
|
; GLOBAL-NEXT: blr
|
|
|
|
%mul = fmul fast float %x, %y
|
|
|
|
%add = fadd fast float %mul, %z
|
|
|
|
ret float %add
|
|
|
|
}
|
|
|
|
|
|
|
|
; fma(X, 7.0, X * 42.0) --> X * 49.0
|
|
|
|
; This is the minimum FMF needed for this transform - the FMA allows reassociation.
|
|
|
|
|
|
|
|
; FMFDEBUG-LABEL: Optimized lowered selection DAG: %bb.0 'fmul_fma_reassoc1:'
|
2018-07-04 20:54:25 +02:00
|
|
|
; FMFDEBUG: fmul reassoc {{t[0-9]+}},
|
2018-05-03 19:41:37 +02:00
|
|
|
; FMFDEBUG: Type-legalized selection DAG: %bb.0 'fmul_fma_reassoc1:'
|
|
|
|
|
2018-05-03 20:49:35 +02:00
|
|
|
; GLOBALDEBUG-LABEL: Optimized lowered selection DAG: %bb.0 'fmul_fma_reassoc1:'
|
Fast Math Flag mapping into SDNode
Summary: Adding support for Fast flags in the SDNode to leverage fast math sub flag usage.
Reviewers: spatel, arsenm, jbhateja, hfinkel, escha, qcolombet, echristo, wristow, javed.absar
Reviewed By: spatel
Subscribers: llvm-commits, rampitec, nhaehnle, tstellar, FarhanaAleen, nemanjai, javed.absar, jbhateja, hfinkel, wdng
Differential Revision: https://reviews.llvm.org/D45710
llvm-svn: 331547
2018-05-04 20:48:20 +02:00
|
|
|
; GLOBALDEBUG: fmul reassoc {{t[0-9]+}}
|
2018-05-03 20:49:35 +02:00
|
|
|
; GLOBALDEBUG: Type-legalized selection DAG: %bb.0 'fmul_fma_reassoc1:'
|
|
|
|
|
2018-05-03 19:41:37 +02:00
|
|
|
define float @fmul_fma_reassoc1(float %x) {
|
|
|
|
; FMF-LABEL: fmul_fma_reassoc1:
|
|
|
|
; FMF: # %bb.0:
|
|
|
|
; FMF-NEXT: addis 3, 2, .LCPI6_0@toc@ha
|
2018-08-20 04:52:55 +02:00
|
|
|
; FMF-NEXT: lfs 0, .LCPI6_0@toc@l(3)
|
Utilize new SDNode flag functionality to expand current support for fma
Summary: This patch originated from D47388 and is a proper subset of the originating changes, containing only the fmf optimization guard extensions.
Reviewers: spatel, hfinkel, wristow, arsenm, javed.absar, rampitec, nhaehnle, nemanjai
Reviewed By: rampitec, nhaehnle
Subscribers: tpr, nemanjai, wdng
Differential Revision: https://reviews.llvm.org/D47918
llvm-svn: 334876
2018-06-16 02:03:06 +02:00
|
|
|
; FMF-NEXT: xsmulsp 1, 1, 0
|
2018-05-03 19:41:37 +02:00
|
|
|
; FMF-NEXT: blr
|
|
|
|
;
|
|
|
|
; GLOBAL-LABEL: fmul_fma_reassoc1:
|
|
|
|
; GLOBAL: # %bb.0:
|
|
|
|
; GLOBAL-NEXT: addis 3, 2, .LCPI6_0@toc@ha
|
2018-08-20 04:52:55 +02:00
|
|
|
; GLOBAL-NEXT: lfs 0, .LCPI6_0@toc@l(3)
|
2018-05-03 19:41:37 +02:00
|
|
|
; GLOBAL-NEXT: xsmulsp 1, 1, 0
|
|
|
|
; GLOBAL-NEXT: blr
|
|
|
|
%mul = fmul float %x, 42.0
|
|
|
|
%fma = call reassoc float @llvm.fma.f32(float %x, float 7.0, float %mul)
|
|
|
|
ret float %fma
|
|
|
|
}
|
|
|
|
|
|
|
|
; This shouldn't change anything - the intermediate fmul result is now also flagged.
|
|
|
|
|
|
|
|
; FMFDEBUG-LABEL: Optimized lowered selection DAG: %bb.0 'fmul_fma_reassoc2:'
|
2018-06-08 00:49:09 +02:00
|
|
|
; FMFDEBUG: fmul reassoc {{t[0-9]+}}
|
2018-05-03 19:41:37 +02:00
|
|
|
; FMFDEBUG: Type-legalized selection DAG: %bb.0 'fmul_fma_reassoc2:'
|
|
|
|
|
2018-05-03 20:49:35 +02:00
|
|
|
; GLOBALDEBUG-LABEL: Optimized lowered selection DAG: %bb.0 'fmul_fma_reassoc2:'
|
Fast Math Flag mapping into SDNode
Summary: Adding support for Fast flags in the SDNode to leverage fast math sub flag usage.
Reviewers: spatel, arsenm, jbhateja, hfinkel, escha, qcolombet, echristo, wristow, javed.absar
Reviewed By: spatel
Subscribers: llvm-commits, rampitec, nhaehnle, tstellar, FarhanaAleen, nemanjai, javed.absar, jbhateja, hfinkel, wdng
Differential Revision: https://reviews.llvm.org/D45710
llvm-svn: 331547
2018-05-04 20:48:20 +02:00
|
|
|
; GLOBALDEBUG: fmul reassoc {{t[0-9]+}}
|
2018-05-03 20:49:35 +02:00
|
|
|
; GLOBALDEBUG: Type-legalized selection DAG: %bb.0 'fmul_fma_reassoc2:'
|
|
|
|
|
2018-05-03 19:41:37 +02:00
|
|
|
define float @fmul_fma_reassoc2(float %x) {
|
|
|
|
; FMF-LABEL: fmul_fma_reassoc2:
|
|
|
|
; FMF: # %bb.0:
|
|
|
|
; FMF-NEXT: addis 3, 2, .LCPI7_0@toc@ha
|
2018-08-20 04:52:55 +02:00
|
|
|
; FMF-NEXT: lfs 0, .LCPI7_0@toc@l(3)
|
Utilize new SDNode flag functionality to expand current support for fma
Summary: This patch originated from D47388 and is a proper subset of the originating changes, containing only the fmf optimization guard extensions.
Reviewers: spatel, hfinkel, wristow, arsenm, javed.absar, rampitec, nhaehnle, nemanjai
Reviewed By: rampitec, nhaehnle
Subscribers: tpr, nemanjai, wdng
Differential Revision: https://reviews.llvm.org/D47918
llvm-svn: 334876
2018-06-16 02:03:06 +02:00
|
|
|
; FMF-NEXT: xsmulsp 1, 1, 0
|
2018-05-03 19:41:37 +02:00
|
|
|
; FMF-NEXT: blr
|
|
|
|
;
|
|
|
|
; GLOBAL-LABEL: fmul_fma_reassoc2:
|
|
|
|
; GLOBAL: # %bb.0:
|
|
|
|
; GLOBAL-NEXT: addis 3, 2, .LCPI7_0@toc@ha
|
2018-08-20 04:52:55 +02:00
|
|
|
; GLOBAL-NEXT: lfs 0, .LCPI7_0@toc@l(3)
|
2018-05-03 19:41:37 +02:00
|
|
|
; GLOBAL-NEXT: xsmulsp 1, 1, 0
|
|
|
|
; GLOBAL-NEXT: blr
|
|
|
|
%mul = fmul reassoc float %x, 42.0
|
|
|
|
%fma = call reassoc float @llvm.fma.f32(float %x, float 7.0, float %mul)
|
|
|
|
ret float %fma
|
|
|
|
}
|
|
|
|
|
|
|
|
; The FMA is now fully 'fast'. This implies that reassociation is allowed.
|
|
|
|
|
|
|
|
; FMFDEBUG-LABEL: Optimized lowered selection DAG: %bb.0 'fmul_fma_fast1:'
|
Utilize new SDNode flag functionality to expand current support for fma
Summary: This patch originated from D47388 and is a proper subset of the originating changes, containing only the fmf optimization guard extensions.
Reviewers: spatel, hfinkel, wristow, arsenm, javed.absar, rampitec, nhaehnle, nemanjai
Reviewed By: rampitec, nhaehnle
Subscribers: tpr, nemanjai, wdng
Differential Revision: https://reviews.llvm.org/D47918
llvm-svn: 334876
2018-06-16 02:03:06 +02:00
|
|
|
; FMFDEBUG: fmul nnan ninf nsz arcp contract afn reassoc {{t[0-9]+}}
|
2018-05-03 19:41:37 +02:00
|
|
|
; FMFDEBUG: Type-legalized selection DAG: %bb.0 'fmul_fma_fast1:'
|
|
|
|
|
2018-05-03 20:49:35 +02:00
|
|
|
; GLOBALDEBUG-LABEL: Optimized lowered selection DAG: %bb.0 'fmul_fma_fast1:'
|
2018-06-08 00:49:09 +02:00
|
|
|
; GLOBALDEBUG: fmul nnan ninf nsz arcp contract afn reassoc {{t[0-9]+}}
|
2018-05-03 20:49:35 +02:00
|
|
|
; GLOBALDEBUG: Type-legalized selection DAG: %bb.0 'fmul_fma_fast1:'
|
|
|
|
|
2018-05-03 19:41:37 +02:00
|
|
|
define float @fmul_fma_fast1(float %x) {
|
|
|
|
; FMF-LABEL: fmul_fma_fast1:
|
|
|
|
; FMF: # %bb.0:
|
|
|
|
; FMF-NEXT: addis 3, 2, .LCPI8_0@toc@ha
|
2018-08-20 04:52:55 +02:00
|
|
|
; FMF-NEXT: lfs 0, .LCPI8_0@toc@l(3)
|
Utilize new SDNode flag functionality to expand current support for fma
Summary: This patch originated from D47388 and is a proper subset of the originating changes, containing only the fmf optimization guard extensions.
Reviewers: spatel, hfinkel, wristow, arsenm, javed.absar, rampitec, nhaehnle, nemanjai
Reviewed By: rampitec, nhaehnle
Subscribers: tpr, nemanjai, wdng
Differential Revision: https://reviews.llvm.org/D47918
llvm-svn: 334876
2018-06-16 02:03:06 +02:00
|
|
|
; FMF-NEXT: xsmulsp 1, 1, 0
|
2018-05-03 19:41:37 +02:00
|
|
|
; FMF-NEXT: blr
|
|
|
|
;
|
|
|
|
; GLOBAL-LABEL: fmul_fma_fast1:
|
|
|
|
; GLOBAL: # %bb.0:
|
|
|
|
; GLOBAL-NEXT: addis 3, 2, .LCPI8_0@toc@ha
|
2018-08-20 04:52:55 +02:00
|
|
|
; GLOBAL-NEXT: lfs 0, .LCPI8_0@toc@l(3)
|
2018-05-03 19:41:37 +02:00
|
|
|
; GLOBAL-NEXT: xsmulsp 1, 1, 0
|
|
|
|
; GLOBAL-NEXT: blr
|
|
|
|
%mul = fmul float %x, 42.0
|
|
|
|
%fma = call fast float @llvm.fma.f32(float %x, float 7.0, float %mul)
|
|
|
|
ret float %fma
|
|
|
|
}
|
|
|
|
|
|
|
|
; This shouldn't change anything - the intermediate fmul result is now also flagged.
|
|
|
|
|
|
|
|
; FMFDEBUG-LABEL: Optimized lowered selection DAG: %bb.0 'fmul_fma_fast2:'
|
2018-06-08 00:49:09 +02:00
|
|
|
; FMFDEBUG: fmul nnan ninf nsz arcp contract afn reassoc {{t[0-9]+}}
|
2018-05-03 19:41:37 +02:00
|
|
|
; FMFDEBUG: Type-legalized selection DAG: %bb.0 'fmul_fma_fast2:'
|
|
|
|
|
2018-05-03 20:49:35 +02:00
|
|
|
; GLOBALDEBUG-LABEL: Optimized lowered selection DAG: %bb.0 'fmul_fma_fast2:'
|
2018-06-08 00:49:09 +02:00
|
|
|
; GLOBALDEBUG: fmul nnan ninf nsz arcp contract afn reassoc {{t[0-9]+}}
|
2018-05-03 20:49:35 +02:00
|
|
|
; GLOBALDEBUG: Type-legalized selection DAG: %bb.0 'fmul_fma_fast2:'
|
|
|
|
|
2018-05-03 19:41:37 +02:00
|
|
|
define float @fmul_fma_fast2(float %x) {
|
|
|
|
; FMF-LABEL: fmul_fma_fast2:
|
|
|
|
; FMF: # %bb.0:
|
|
|
|
; FMF-NEXT: addis 3, 2, .LCPI9_0@toc@ha
|
2018-08-20 04:52:55 +02:00
|
|
|
; FMF-NEXT: lfs 0, .LCPI9_0@toc@l(3)
|
Utilize new SDNode flag functionality to expand current support for fma
Summary: This patch originated from D47388 and is a proper subset of the originating changes, containing only the fmf optimization guard extensions.
Reviewers: spatel, hfinkel, wristow, arsenm, javed.absar, rampitec, nhaehnle, nemanjai
Reviewed By: rampitec, nhaehnle
Subscribers: tpr, nemanjai, wdng
Differential Revision: https://reviews.llvm.org/D47918
llvm-svn: 334876
2018-06-16 02:03:06 +02:00
|
|
|
; FMF-NEXT: xsmulsp 1, 1, 0
|
2018-05-03 19:41:37 +02:00
|
|
|
; FMF-NEXT: blr
|
|
|
|
;
|
|
|
|
; GLOBAL-LABEL: fmul_fma_fast2:
|
|
|
|
; GLOBAL: # %bb.0:
|
|
|
|
; GLOBAL-NEXT: addis 3, 2, .LCPI9_0@toc@ha
|
2018-08-20 04:52:55 +02:00
|
|
|
; GLOBAL-NEXT: lfs 0, .LCPI9_0@toc@l(3)
|
2018-05-03 19:41:37 +02:00
|
|
|
; GLOBAL-NEXT: xsmulsp 1, 1, 0
|
|
|
|
; GLOBAL-NEXT: blr
|
|
|
|
%mul = fmul fast float %x, 42.0
|
|
|
|
%fma = call fast float @llvm.fma.f32(float %x, float 7.0, float %mul)
|
|
|
|
ret float %fma
|
|
|
|
}
|
|
|
|
|
|
|
|
; Reduced precision for sqrt is allowed - should use estimate and NR iterations.
|
|
|
|
|
|
|
|
; FMFDEBUG-LABEL: Optimized lowered selection DAG: %bb.0 'sqrt_afn:'
|
2018-06-06 20:47:55 +02:00
|
|
|
; FMFDEBUG: fmul afn {{t[0-9]+}}
|
2018-05-03 19:41:37 +02:00
|
|
|
; FMFDEBUG: Type-legalized selection DAG: %bb.0 'sqrt_afn:'
|
|
|
|
|
2018-05-03 20:49:35 +02:00
|
|
|
; GLOBALDEBUG-LABEL: Optimized lowered selection DAG: %bb.0 'sqrt_afn:'
|
2018-06-06 20:47:55 +02:00
|
|
|
; GLOBALDEBUG: fmul afn {{t[0-9]+}}
|
2018-05-03 20:49:35 +02:00
|
|
|
; GLOBALDEBUG: Type-legalized selection DAG: %bb.0 'sqrt_afn:'
|
|
|
|
|
2018-05-03 19:41:37 +02:00
|
|
|
define float @sqrt_afn(float %x) {
|
|
|
|
; FMF-LABEL: sqrt_afn:
|
2018-07-04 20:54:25 +02:00
|
|
|
; FMF: # %bb.0:
|
|
|
|
; FMF-NEXT: xxlxor 0, 0, 0
|
|
|
|
; FMF-NEXT: fcmpu 0, 1, 0
|
|
|
|
; FMF-NEXT: beq 0, .LBB10_2
|
|
|
|
; FMF-NEXT: # %bb.1:
|
|
|
|
; FMF-NEXT: addis 3, 2, .LCPI10_0@toc@ha
|
|
|
|
; FMF-NEXT: xsrsqrtesp 3, 1
|
2018-08-20 04:52:55 +02:00
|
|
|
; FMF-NEXT: lfs 0, .LCPI10_0@toc@l(3)
|
2018-07-04 20:54:25 +02:00
|
|
|
; FMF-NEXT: xsmulsp 2, 1, 0
|
|
|
|
; FMF-NEXT: xsmulsp 4, 3, 3
|
|
|
|
; FMF-NEXT: xssubsp 2, 2, 1
|
|
|
|
; FMF-NEXT: xsmulsp 2, 2, 4
|
|
|
|
; FMF-NEXT: xssubsp 0, 0, 2
|
|
|
|
; FMF-NEXT: xsmulsp 0, 3, 0
|
|
|
|
; FMF-NEXT: xsmulsp 0, 0, 1
|
|
|
|
; FMF-NEXT: .LBB10_2:
|
|
|
|
; FMF-NEXT: fmr 1, 0
|
|
|
|
; FMF-NEXT: blr
|
2018-05-03 19:41:37 +02:00
|
|
|
;
|
|
|
|
; GLOBAL-LABEL: sqrt_afn:
|
|
|
|
; GLOBAL: # %bb.0:
|
|
|
|
; GLOBAL-NEXT: xxlxor 0, 0, 0
|
|
|
|
; GLOBAL-NEXT: fcmpu 0, 1, 0
|
|
|
|
; GLOBAL-NEXT: beq 0, .LBB10_2
|
|
|
|
; GLOBAL-NEXT: # %bb.1:
|
|
|
|
; GLOBAL-NEXT: xsrsqrtesp 2, 1
|
|
|
|
; GLOBAL-NEXT: fneg 0, 1
|
2018-07-04 20:54:25 +02:00
|
|
|
; GLOBAL-NEXT: addis 3, 2, .LCPI10_0@toc@ha
|
2018-05-03 19:41:37 +02:00
|
|
|
; GLOBAL-NEXT: fmr 4, 1
|
2018-08-20 04:52:55 +02:00
|
|
|
; GLOBAL-NEXT: lfs 3, .LCPI10_0@toc@l(3)
|
2018-05-03 19:41:37 +02:00
|
|
|
; GLOBAL-NEXT: xsmaddasp 4, 0, 3
|
|
|
|
; GLOBAL-NEXT: xsmulsp 0, 2, 2
|
|
|
|
; GLOBAL-NEXT: xsmaddasp 3, 4, 0
|
|
|
|
; GLOBAL-NEXT: xsmulsp 0, 2, 3
|
|
|
|
; GLOBAL-NEXT: xsmulsp 0, 0, 1
|
|
|
|
; GLOBAL-NEXT: .LBB10_2:
|
|
|
|
; GLOBAL-NEXT: fmr 1, 0
|
|
|
|
; GLOBAL-NEXT: blr
|
|
|
|
%rt = call afn float @llvm.sqrt.f32(float %x)
|
|
|
|
ret float %rt
|
|
|
|
}
|
|
|
|
|
|
|
|
; The call is now fully 'fast'. This implies that approximation is allowed.
|
|
|
|
|
|
|
|
; FMFDEBUG-LABEL: Optimized lowered selection DAG: %bb.0 'sqrt_fast:'
|
2018-06-06 20:47:55 +02:00
|
|
|
; FMFDEBUG: fmul nnan ninf nsz arcp contract afn reassoc {{t[0-9]+}}
|
2018-05-03 19:41:37 +02:00
|
|
|
; FMFDEBUG: Type-legalized selection DAG: %bb.0 'sqrt_fast:'
|
|
|
|
|
2018-05-03 20:49:35 +02:00
|
|
|
; GLOBALDEBUG-LABEL: Optimized lowered selection DAG: %bb.0 'sqrt_fast:'
|
2018-06-06 20:47:55 +02:00
|
|
|
; GLOBALDEBUG: fmul nnan ninf nsz arcp contract afn reassoc {{t[0-9]+}}
|
2018-05-03 20:49:35 +02:00
|
|
|
; GLOBALDEBUG: Type-legalized selection DAG: %bb.0 'sqrt_fast:'
|
|
|
|
|
2018-05-03 19:41:37 +02:00
|
|
|
define float @sqrt_fast(float %x) {
|
|
|
|
; FMF-LABEL: sqrt_fast:
|
2018-07-04 20:54:25 +02:00
|
|
|
; FMF: # %bb.0:
|
|
|
|
; FMF-NEXT: xxlxor 0, 0, 0
|
|
|
|
; FMF-NEXT: fcmpu 0, 1, 0
|
|
|
|
; FMF-NEXT: beq 0, .LBB11_2
|
|
|
|
; FMF-NEXT: # %bb.1:
|
|
|
|
; FMF-NEXT: xsrsqrtesp 2, 1
|
|
|
|
; FMF-NEXT: fneg 0, 1
|
|
|
|
; FMF-NEXT: addis 3, 2, .LCPI11_0@toc@ha
|
|
|
|
; FMF-NEXT: fmr 4, 1
|
2018-08-20 04:52:55 +02:00
|
|
|
; FMF-NEXT: lfs 3, .LCPI11_0@toc@l(3)
|
2018-07-04 20:54:25 +02:00
|
|
|
; FMF-NEXT: xsmaddasp 4, 0, 3
|
|
|
|
; FMF-NEXT: xsmulsp 0, 2, 2
|
|
|
|
; FMF-NEXT: xsmaddasp 3, 4, 0
|
|
|
|
; FMF-NEXT: xsmulsp 0, 2, 3
|
|
|
|
; FMF-NEXT: xsmulsp 0, 0, 1
|
|
|
|
; FMF-NEXT: .LBB11_2:
|
|
|
|
; FMF-NEXT: fmr 1, 0
|
|
|
|
; FMF-NEXT: blr
|
2018-05-03 19:41:37 +02:00
|
|
|
;
|
|
|
|
; GLOBAL-LABEL: sqrt_fast:
|
|
|
|
; GLOBAL: # %bb.0:
|
|
|
|
; GLOBAL-NEXT: xxlxor 0, 0, 0
|
|
|
|
; GLOBAL-NEXT: fcmpu 0, 1, 0
|
|
|
|
; GLOBAL-NEXT: beq 0, .LBB11_2
|
|
|
|
; GLOBAL-NEXT: # %bb.1:
|
|
|
|
; GLOBAL-NEXT: xsrsqrtesp 2, 1
|
|
|
|
; GLOBAL-NEXT: fneg 0, 1
|
2018-07-04 20:54:25 +02:00
|
|
|
; GLOBAL-NEXT: addis 3, 2, .LCPI11_0@toc@ha
|
2018-05-03 19:41:37 +02:00
|
|
|
; GLOBAL-NEXT: fmr 4, 1
|
2018-08-20 04:52:55 +02:00
|
|
|
; GLOBAL-NEXT: lfs 3, .LCPI11_0@toc@l(3)
|
2018-05-03 19:41:37 +02:00
|
|
|
; GLOBAL-NEXT: xsmaddasp 4, 0, 3
|
|
|
|
; GLOBAL-NEXT: xsmulsp 0, 2, 2
|
|
|
|
; GLOBAL-NEXT: xsmaddasp 3, 4, 0
|
|
|
|
; GLOBAL-NEXT: xsmulsp 0, 2, 3
|
|
|
|
; GLOBAL-NEXT: xsmulsp 0, 0, 1
|
|
|
|
; GLOBAL-NEXT: .LBB11_2:
|
|
|
|
; GLOBAL-NEXT: fmr 1, 0
|
|
|
|
; GLOBAL-NEXT: blr
|
|
|
|
%rt = call fast float @llvm.sqrt.f32(float %x)
|
|
|
|
ret float %rt
|
|
|
|
}
|
|
|
|
|
2018-05-14 23:17:49 +02:00
|
|
|
; fcmp can have fast-math-flags.
|
|
|
|
|
|
|
|
; FMFDEBUG-LABEL: Optimized lowered selection DAG: %bb.0 'fcmp_nnan:'
|
|
|
|
; FMFDEBUG: select_cc {{t[0-9]+}}
|
|
|
|
; FMFDEBUG: Type-legalized selection DAG: %bb.0 'fcmp_nnan:'
|
|
|
|
|
|
|
|
; GLOBALDEBUG-LABEL: Optimized lowered selection DAG: %bb.0 'fcmp_nnan:'
|
|
|
|
; GLOBALDEBUG: select_cc {{t[0-9]+}}
|
|
|
|
; GLOBALDEBUG: Type-legalized selection DAG: %bb.0 'fcmp_nnan:'
|
|
|
|
|
|
|
|
define double @fcmp_nnan(double %a, double %y, double %z) {
|
|
|
|
; FMF-LABEL: fcmp_nnan:
|
|
|
|
; FMF: # %bb.0:
|
|
|
|
; FMF-NEXT: xxlxor 0, 0, 0
|
2018-05-15 16:16:24 +02:00
|
|
|
; FMF-NEXT: xscmpudp 0, 1, 0
|
|
|
|
; FMF-NEXT: blt 0, .LBB12_2
|
2018-05-14 23:17:49 +02:00
|
|
|
; FMF-NEXT: # %bb.1:
|
|
|
|
; FMF-NEXT: fmr 3, 2
|
|
|
|
; FMF-NEXT: .LBB12_2:
|
|
|
|
; FMF-NEXT: fmr 1, 3
|
|
|
|
; FMF-NEXT: blr
|
|
|
|
;
|
|
|
|
; GLOBAL-LABEL: fcmp_nnan:
|
|
|
|
; GLOBAL: # %bb.0:
|
|
|
|
; GLOBAL-NEXT: xxlxor 0, 0, 0
|
|
|
|
; GLOBAL-NEXT: xscmpudp 0, 1, 0
|
|
|
|
; GLOBAL-NEXT: blt 0, .LBB12_2
|
|
|
|
; GLOBAL-NEXT: # %bb.1:
|
|
|
|
; GLOBAL-NEXT: fmr 3, 2
|
|
|
|
; GLOBAL-NEXT: .LBB12_2:
|
|
|
|
; GLOBAL-NEXT: fmr 1, 3
|
|
|
|
; GLOBAL-NEXT: blr
|
|
|
|
%cmp = fcmp nnan ult double %a, 0.0
|
|
|
|
%z.y = select i1 %cmp, double %z, double %y
|
|
|
|
ret double %z.y
|
|
|
|
}
|
|
|
|
|
|
|
|
; FP library calls can have fast-math-flags.
|
|
|
|
|
|
|
|
; FMFDEBUG-LABEL: Optimized lowered selection DAG: %bb.0 'log2_approx:'
|
|
|
|
; FMFDEBUG: ch,glue = PPCISD::CALL_NOP t11, TargetGlobalAddress:i64<double (double)* @log2>
|
|
|
|
; FMFDEBUG: ch,glue = callseq_end t15, TargetConstant:i64<32>, TargetConstant:i64<0>, t15:1
|
2018-05-15 16:16:24 +02:00
|
|
|
; FMFDEBUG: f64,ch,glue = CopyFromReg afn t16, Register:f64 $f1, t16:1
|
2018-05-14 23:17:49 +02:00
|
|
|
; FMFDEBUG: Type-legalized selection DAG: %bb.0 'log2_approx:'
|
|
|
|
|
|
|
|
; GLOBALDEBUG-LABEL: Optimized lowered selection DAG: %bb.0 'log2_approx:'
|
|
|
|
; GLOBALDEBUG: ch,glue = PPCISD::CALL_NOP t11, TargetGlobalAddress:i64<double (double)* @log2>
|
|
|
|
; GLOBALDEBUG: ch,glue = callseq_end t15, TargetConstant:i64<32>, TargetConstant:i64<0>, t15:1
|
2018-05-15 16:16:24 +02:00
|
|
|
; GLOBALDEBUG: f64,ch,glue = CopyFromReg afn t16, Register:f64 $f1, t16:1
|
2018-05-14 23:17:49 +02:00
|
|
|
; GLOBALDEBUG: Type-legalized selection DAG: %bb.0 'log2_approx:'
|
|
|
|
|
|
|
|
declare double @log2(double)
|
|
|
|
define double @log2_approx(double %x) nounwind {
|
|
|
|
; FMF-LABEL: log2_approx:
|
|
|
|
; FMF: # %bb.0:
|
|
|
|
; FMF-NEXT: mflr 0
|
|
|
|
; FMF-NEXT: std 0, 16(1)
|
|
|
|
; FMF-NEXT: stdu 1, -32(1)
|
|
|
|
; FMF-NEXT: bl log2
|
|
|
|
; FMF-NEXT: nop
|
|
|
|
; FMF-NEXT: addi 1, 1, 32
|
|
|
|
; FMF-NEXT: ld 0, 16(1)
|
|
|
|
; FMF-NEXT: mtlr 0
|
|
|
|
; FMF-NEXT: blr
|
|
|
|
;
|
|
|
|
; GLOBAL-LABEL: log2_approx:
|
|
|
|
; GLOBAL: # %bb.0:
|
|
|
|
; GLOBAL-NEXT: mflr 0
|
|
|
|
; GLOBAL-NEXT: std 0, 16(1)
|
|
|
|
; GLOBAL-NEXT: stdu 1, -32(1)
|
|
|
|
; GLOBAL-NEXT: bl log2
|
|
|
|
; GLOBAL-NEXT: nop
|
|
|
|
; GLOBAL-NEXT: addi 1, 1, 32
|
|
|
|
; GLOBAL-NEXT: ld 0, 16(1)
|
|
|
|
; GLOBAL-NEXT: mtlr 0
|
|
|
|
; GLOBAL-NEXT: blr
|
|
|
|
%r = call afn double @log2(double %x)
|
|
|
|
ret double %r
|
|
|
|
}
|
|
|
|
|
2018-06-05 20:12:25 +02:00
|
|
|
; -(X - Y) --> (Y - X)
|
|
|
|
|
|
|
|
; FMFDEBUG-LABEL: Optimized lowered selection DAG: %bb.0 'fneg_fsub_nozeros_1:'
|
2018-06-05 20:49:47 +02:00
|
|
|
; FMFDEBUG: fsub nsz {{t[0-9]+}}, {{t[0-9]+}}
|
2018-06-05 20:12:25 +02:00
|
|
|
; FMFDEBUG: Type-legalized selection DAG: %bb.0 'fneg_fsub_nozeros_1:'
|
|
|
|
|
|
|
|
; GLOBALDEBUG-LABEL: Optimized lowered selection DAG: %bb.0 'fneg_fsub_nozeros_1:'
|
2018-06-05 20:49:47 +02:00
|
|
|
; GLOBALDEBUG: fsub nsz {{t[0-9]+}}, {{t[0-9]+}}
|
2018-06-05 20:12:25 +02:00
|
|
|
; GLOBALDEBUG: Type-legalized selection DAG: %bb.0 'fneg_fsub_nozeros_1:'
|
|
|
|
|
|
|
|
define float @fneg_fsub_nozeros_1(float %x, float %y, float %z) {
|
|
|
|
; FMF-LABEL: fneg_fsub_nozeros_1:
|
|
|
|
; FMF: # %bb.0:
|
2018-06-05 20:49:47 +02:00
|
|
|
; FMF-NEXT: xssubsp 1, 2, 1
|
2018-06-05 20:12:25 +02:00
|
|
|
; FMF-NEXT: blr
|
|
|
|
;
|
|
|
|
; GLOBAL-LABEL: fneg_fsub_nozeros_1:
|
|
|
|
; GLOBAL: # %bb.0:
|
2018-06-05 20:49:47 +02:00
|
|
|
; GLOBAL-NEXT: xssubsp 1, 2, 1
|
2018-06-05 20:12:25 +02:00
|
|
|
; GLOBAL-NEXT: blr
|
|
|
|
%neg = fsub float %x, %y
|
2018-06-05 20:49:47 +02:00
|
|
|
%add = fsub nsz float 0.0, %neg
|
2018-06-05 20:12:25 +02:00
|
|
|
ret float %add
|
|
|
|
}
|
2018-06-05 20:49:47 +02:00
|
|
|
|