Hi,
Here's a trivial patch to relax the FP math also
if -cl-fast-relaxed-math is set.
This supersedes the previous patch with title
"if unsafe-fp-math FN attribute is set, enable reduction
detection with float operations"
On 11/28/2014 08:04 PM, Pekka Jääskeläinen wrote:
Hi Hal,
OK, I didn't know which way was the chosen "future approach" or
if they both are used for some use cases.
I just noticed that when I set -cl-fast-relaxed-math in OpenCL C,
it didn't propagate to the FP instructions as 'fast' attributes,
but the func attribute did get set.
So I suppose it should be investigated why the flags are not
generated to the produced instructions in this case instead
in case the fnattr is deprecated?
On 11/28/2014 07:43 PM, Hal Finkel wrote:
Pekka,
What's your motivation for doing this? Aside from the fact that we
can't yet set fast math flags on function calls (to sqrt, etc.), I
think we're pretty close to removing the function attribute all
together. The instruction-level flags play much nicer with LTO, and
give more precision control to the frontends; it is not clear to me
that overriding them with the function-level attribute is desirable.
-Hal
----- Original Message -----
From: "Pekka Jääskeläinen" <[email protected]> To: "Commit
Messages and Patches for LLVM" <[email protected]> Sent:
Friday, November 28, 2014 11:13:39 AM Subject: [PATCH]
[LoopVectorizer] if unsafe-fp-math FN attribute is set, enable
reduction detection with float operations
Hi,
The attached patch checks the function attributes for
"unsafe-fp-math" to relax FP constraints when detecting reduction
operations.
-- --Pekka
_______________________________________________ llvm-commits
mailing list [email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
--
--Pekka
Index: lib/Frontend/CompilerInvocation.cpp
===================================================================
--- lib/Frontend/CompilerInvocation.cpp (revision 222892)
+++ lib/Frontend/CompilerInvocation.cpp (working copy)
@@ -1596,7 +1596,8 @@
// inlining enabled.
Opts.NoInlineDefine = !Opt || Args.hasArg(OPT_fno_inline);
- Opts.FastMath = Args.hasArg(OPT_ffast_math);
+ Opts.FastMath = Args.hasArg(OPT_ffast_math) ||
+ Args.hasArg(OPT_cl_fast_relaxed_math);
Opts.FiniteMathOnly = Args.hasArg(OPT_ffinite_math_only);
Opts.RetainCommentsFromSystemHeaders =
Index: test/CodeGenOpenCL/relaxed-fpmath.cl
===================================================================
--- test/CodeGenOpenCL/relaxed-fpmath.cl (revision 0)
+++ test/CodeGenOpenCL/relaxed-fpmath.cl (working copy)
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 %s -emit-llvm -cl-fast-relaxed-math -o - | FileCheck %s -check-prefix=FAST
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s -check-prefix=NORMAL
+
+typedef __attribute__(( ext_vector_type(4) )) float float4;
+
+float spscalardiv(float a, float b) {
+ // FAST: @spscalardiv
+ // NORMAL: @spscalardiv
+ // FAST: fdiv fast float
+ // NORMAL: fdiv float
+ return a / b;
+}
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits