[clang] [FPEnv] Add strictfp in some C++ constructors lacking a FunctionDecl. (PR #74883)

2024-03-08 Thread Kevin P. Neal via cfe-commits

kpneal wrote:

OK, I'll head in the direction you've pointed. Thanks for your time!

https://github.com/llvm/llvm-project/pull/74883
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [FPEnv] Add strictfp in some C++ constructors lacking a FunctionDecl. (PR #74883)

2024-03-08 Thread Kevin P. Neal via cfe-commits

https://github.com/kpneal closed https://github.com/llvm/llvm-project/pull/74883
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [FPEnv] Add strictfp in some C++ constructors lacking a FunctionDecl. (PR #74883)

2024-01-16 Thread Kevin P. Neal via cfe-commits

https://github.com/kpneal updated 
https://github.com/llvm/llvm-project/pull/74883

>From eb43ba5adbf57988fdd5f490a74dc59d72f495e5 Mon Sep 17 00:00:00 2001
From: "Kevin P. Neal" 
Date: Fri, 8 Dec 2023 14:43:50 -0500
Subject: [PATCH 1/5] [FPEnv] Add strictfp in some C++ constructors lacking a
 FunctionDecl.

Some C++ constructors require the strictfp attribute on all function calls
but don't get it because the comstructor lacks a FunctionDecl. Use the
IRBuilder's strictfp mode to communicate that the strictfp attribute is
required. Note that the function calls that were missing the attribute
were getting it from the IRBuilder but it then was getting lost when
CGCall.cpp replaced all the attributes for the function call.

Verified with "https://reviews.llvm.org/D146845;.
---
 clang/include/clang/AST/ExprCXX.h|  4 ++
 clang/lib/CodeGen/CGCall.cpp |  8 +++
 clang/lib/CodeGen/CGDeclCXX.cpp  |  5 ++
 clang/test/CodeGen/fp-floatcontrol-class.cpp | 75 ++--
 4 files changed, 88 insertions(+), 4 deletions(-)

diff --git a/clang/include/clang/AST/ExprCXX.h 
b/clang/include/clang/AST/ExprCXX.h
index 24278016431837..f9269082c32475 100644
--- a/clang/include/clang/AST/ExprCXX.h
+++ b/clang/include/clang/AST/ExprCXX.h
@@ -1698,6 +1698,10 @@ class CXXConstructExpr : public Expr {
   SourceRange getParenOrBraceRange() const { return ParenOrBraceRange; }
   void setParenOrBraceRange(SourceRange Range) { ParenOrBraceRange = Range; }
 
+  /// Determine whether the function was declared in source context
+  /// that requires constrained FP intrinsics
+  bool UsesFPIntrin() const { return Constructor->UsesFPIntrin(); }
+
   static bool classof(const Stmt *T) {
 return T->getStmtClass() == CXXConstructExprClass ||
T->getStmtClass() == CXXTemporaryObjectExprClass;
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index a24aeea7ae32bf..7d1bb4dc75ab45 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -5520,6 +5520,12 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo 
,
   CGM.AdjustMemoryAttribute(CalleePtr->getName(), Callee.getAbstractInfo(),
 Attrs);
   }
+  // We may not have a FunctionDecl*, but we still need to support strictfp.
+  if (Builder.getIsFPConstrained()) {
+// All calls within a strictfp function are marked strictfp
+Attrs = Attrs.addFnAttribute(getLLVMContext(), llvm::Attribute::StrictFP);
+  }
+
   // Add call-site nomerge attribute if exists.
   if (InNoMergeAttributedStmt)
 Attrs = Attrs.addFnAttribute(getLLVMContext(), llvm::Attribute::NoMerge);
@@ -5587,10 +5593,12 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo 
,
   !isa_and_nonnull(TargetDecl))
 EmitKCFIOperandBundle(ConcreteCallee, BundleList);
 
+#if 0 // XXX Why is this here? Duplicate!
   if (const FunctionDecl *FD = dyn_cast_or_null(CurFuncDecl))
 if (FD->hasAttr())
   // All calls within a strictfp function are marked strictfp
   Attrs = Attrs.addFnAttribute(getLLVMContext(), 
llvm::Attribute::StrictFP);
+#endif
 
   AssumeAlignedAttrEmitter AssumeAlignedAttrEmitter(*this, TargetDecl);
   Attrs = AssumeAlignedAttrEmitter.TryEmitAsCallSiteAttribute(Attrs);
diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp
index e08a1e5f42df20..5700b7fcb49d32 100644
--- a/clang/lib/CodeGen/CGDeclCXX.cpp
+++ b/clang/lib/CodeGen/CGDeclCXX.cpp
@@ -1012,6 +1012,11 @@ void 
CodeGenFunction::GenerateCXXGlobalVarDeclInitFunc(llvm::Function *Fn,
 
   CurEHLocation = D->getBeginLoc();
 
+  if (const auto *CE = dyn_cast(D->getInit())) {
+if (CE->UsesFPIntrin())
+  Builder.setIsFPConstrained(true);
+  }
+
   StartFunction(GlobalDecl(D, DynamicInitKind::Initializer),
 getContext().VoidTy, Fn, getTypes().arrangeNullaryFunction(),
 FunctionArgList());
diff --git a/clang/test/CodeGen/fp-floatcontrol-class.cpp 
b/clang/test/CodeGen/fp-floatcontrol-class.cpp
index 83a27cb206eb82..c9953119fd3a22 100644
--- a/clang/test/CodeGen/fp-floatcontrol-class.cpp
+++ b/clang/test/CodeGen/fp-floatcontrol-class.cpp
@@ -1,3 +1,4 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --include-generated-funcs --version 4
 // RUN: %clang_cc1 -ffp-contract=on -triple x86_64-linux-gnu -emit-llvm -o - 
%s | FileCheck %s
 // Verify that float_control does not pertain to initializer expressions
 
@@ -6,14 +7,80 @@ float z();
 #pragma float_control(except, on)
 class ON {
   float w = 2 + y() * z();
-  // CHECK-LABEL: define {{.*}} @_ZN2ONC2Ev{{.*}}
-  // CHECK: llvm.experimental.constrained.fmul{{.*}}tonearest{{.*}}strict
 };
 ON on;
 #pragma float_control(except, off)
 class OFF {
   float w = 2 + y() * z();
-  // CHECK-LABEL: define {{.*}} @_ZN3OFFC2Ev{{.*}}
-  // CHECK-NOT: llvm.experimental.constrained.fmul{{.*}}tonearest{{.*}}strict
 };
 OFF off;
+// CHECK-LABEL: define internal void 

[clang] [FPEnv] Add strictfp in some C++ constructors lacking a FunctionDecl. (PR #74883)

2023-12-14 Thread Kevin P. Neal via cfe-commits


@@ -6,14 +7,80 @@ float z();
 #pragma float_control(except, on)
 class ON {
   float w = 2 + y() * z();
-  // CHECK-LABEL: define {{.*}} @_ZN2ONC2Ev{{.*}}
-  // CHECK: llvm.experimental.constrained.fmul{{.*}}tonearest{{.*}}strict
 };
 ON on;
 #pragma float_control(except, off)
 class OFF {
   float w = 2 + y() * z();
-  // CHECK-LABEL: define {{.*}} @_ZN3OFFC2Ev{{.*}}
-  // CHECK-NOT: llvm.experimental.constrained.fmul{{.*}}tonearest{{.*}}strict
 };
 OFF off;
+// CHECK-LABEL: define internal void @__cxx_global_var_init(
+// CHECK-SAME: ) #[[ATTR0:[0-9]+]] section ".text.startup" {

kpneal wrote:

I missed the argument to update_cc_test_checks.py that includes the attribute 
comments. Fixed. Is the new comment about checking for strictfp sufficient? Or 
do I need to include a mention of the documentation in the LangRef?

https://github.com/llvm/llvm-project/pull/74883
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [FPEnv] Add strictfp in some C++ constructors lacking a FunctionDecl. (PR #74883)

2023-12-14 Thread Kevin P. Neal via cfe-commits


@@ -5587,10 +5593,12 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo 
,
   !isa_and_nonnull(TargetDecl))
 EmitKCFIOperandBundle(ConcreteCallee, BundleList);
 
+#if 0 // XXX Why is this here? Duplicate!
   if (const FunctionDecl *FD = dyn_cast_or_null(CurFuncDecl))
 if (FD->hasAttr())
   // All calls within a strictfp function are marked strictfp
   Attrs = Attrs.addFnAttribute(getLLVMContext(), 
llvm::Attribute::StrictFP);
+#endif

kpneal wrote:

Done.

https://github.com/llvm/llvm-project/pull/74883
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [FPEnv] Add strictfp in some C++ constructors lacking a FunctionDecl. (PR #74883)

2023-12-14 Thread Kevin P. Neal via cfe-commits

https://github.com/kpneal updated 
https://github.com/llvm/llvm-project/pull/74883

>From eb43ba5adbf57988fdd5f490a74dc59d72f495e5 Mon Sep 17 00:00:00 2001
From: "Kevin P. Neal" 
Date: Fri, 8 Dec 2023 14:43:50 -0500
Subject: [PATCH 1/3] [FPEnv] Add strictfp in some C++ constructors lacking a
 FunctionDecl.

Some C++ constructors require the strictfp attribute on all function calls
but don't get it because the comstructor lacks a FunctionDecl. Use the
IRBuilder's strictfp mode to communicate that the strictfp attribute is
required. Note that the function calls that were missing the attribute
were getting it from the IRBuilder but it then was getting lost when
CGCall.cpp replaced all the attributes for the function call.

Verified with "https://reviews.llvm.org/D146845;.
---
 clang/include/clang/AST/ExprCXX.h|  4 ++
 clang/lib/CodeGen/CGCall.cpp |  8 +++
 clang/lib/CodeGen/CGDeclCXX.cpp  |  5 ++
 clang/test/CodeGen/fp-floatcontrol-class.cpp | 75 ++--
 4 files changed, 88 insertions(+), 4 deletions(-)

diff --git a/clang/include/clang/AST/ExprCXX.h 
b/clang/include/clang/AST/ExprCXX.h
index 24278016431837..f9269082c32475 100644
--- a/clang/include/clang/AST/ExprCXX.h
+++ b/clang/include/clang/AST/ExprCXX.h
@@ -1698,6 +1698,10 @@ class CXXConstructExpr : public Expr {
   SourceRange getParenOrBraceRange() const { return ParenOrBraceRange; }
   void setParenOrBraceRange(SourceRange Range) { ParenOrBraceRange = Range; }
 
+  /// Determine whether the function was declared in source context
+  /// that requires constrained FP intrinsics
+  bool UsesFPIntrin() const { return Constructor->UsesFPIntrin(); }
+
   static bool classof(const Stmt *T) {
 return T->getStmtClass() == CXXConstructExprClass ||
T->getStmtClass() == CXXTemporaryObjectExprClass;
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index a24aeea7ae32bf..7d1bb4dc75ab45 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -5520,6 +5520,12 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo 
,
   CGM.AdjustMemoryAttribute(CalleePtr->getName(), Callee.getAbstractInfo(),
 Attrs);
   }
+  // We may not have a FunctionDecl*, but we still need to support strictfp.
+  if (Builder.getIsFPConstrained()) {
+// All calls within a strictfp function are marked strictfp
+Attrs = Attrs.addFnAttribute(getLLVMContext(), llvm::Attribute::StrictFP);
+  }
+
   // Add call-site nomerge attribute if exists.
   if (InNoMergeAttributedStmt)
 Attrs = Attrs.addFnAttribute(getLLVMContext(), llvm::Attribute::NoMerge);
@@ -5587,10 +5593,12 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo 
,
   !isa_and_nonnull(TargetDecl))
 EmitKCFIOperandBundle(ConcreteCallee, BundleList);
 
+#if 0 // XXX Why is this here? Duplicate!
   if (const FunctionDecl *FD = dyn_cast_or_null(CurFuncDecl))
 if (FD->hasAttr())
   // All calls within a strictfp function are marked strictfp
   Attrs = Attrs.addFnAttribute(getLLVMContext(), 
llvm::Attribute::StrictFP);
+#endif
 
   AssumeAlignedAttrEmitter AssumeAlignedAttrEmitter(*this, TargetDecl);
   Attrs = AssumeAlignedAttrEmitter.TryEmitAsCallSiteAttribute(Attrs);
diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp
index e08a1e5f42df20..5700b7fcb49d32 100644
--- a/clang/lib/CodeGen/CGDeclCXX.cpp
+++ b/clang/lib/CodeGen/CGDeclCXX.cpp
@@ -1012,6 +1012,11 @@ void 
CodeGenFunction::GenerateCXXGlobalVarDeclInitFunc(llvm::Function *Fn,
 
   CurEHLocation = D->getBeginLoc();
 
+  if (const auto *CE = dyn_cast(D->getInit())) {
+if (CE->UsesFPIntrin())
+  Builder.setIsFPConstrained(true);
+  }
+
   StartFunction(GlobalDecl(D, DynamicInitKind::Initializer),
 getContext().VoidTy, Fn, getTypes().arrangeNullaryFunction(),
 FunctionArgList());
diff --git a/clang/test/CodeGen/fp-floatcontrol-class.cpp 
b/clang/test/CodeGen/fp-floatcontrol-class.cpp
index 83a27cb206eb82..c9953119fd3a22 100644
--- a/clang/test/CodeGen/fp-floatcontrol-class.cpp
+++ b/clang/test/CodeGen/fp-floatcontrol-class.cpp
@@ -1,3 +1,4 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --include-generated-funcs --version 4
 // RUN: %clang_cc1 -ffp-contract=on -triple x86_64-linux-gnu -emit-llvm -o - 
%s | FileCheck %s
 // Verify that float_control does not pertain to initializer expressions
 
@@ -6,14 +7,80 @@ float z();
 #pragma float_control(except, on)
 class ON {
   float w = 2 + y() * z();
-  // CHECK-LABEL: define {{.*}} @_ZN2ONC2Ev{{.*}}
-  // CHECK: llvm.experimental.constrained.fmul{{.*}}tonearest{{.*}}strict
 };
 ON on;
 #pragma float_control(except, off)
 class OFF {
   float w = 2 + y() * z();
-  // CHECK-LABEL: define {{.*}} @_ZN3OFFC2Ev{{.*}}
-  // CHECK-NOT: llvm.experimental.constrained.fmul{{.*}}tonearest{{.*}}strict
 };
 OFF off;
+// CHECK-LABEL: define internal void 

[clang] [FPEnv] Add strictfp in some C++ constructors lacking a FunctionDecl. (PR #74883)

2023-12-08 Thread Kevin P. Neal via cfe-commits

https://github.com/kpneal created 
https://github.com/llvm/llvm-project/pull/74883

Some C++ constructors require the strictfp attribute on all function calls but 
don't get it because the comstructor lacks a FunctionDecl. Use the IRBuilder's 
strictfp mode to communicate that the strictfp attribute is required. Note that 
the function calls that were missing the attribute were getting it from the 
IRBuilder but it then was getting lost when CGCall.cpp replaced all the 
attributes for the function call.

Verified with "https://reviews.llvm.org/D146845;.

>From eb43ba5adbf57988fdd5f490a74dc59d72f495e5 Mon Sep 17 00:00:00 2001
From: "Kevin P. Neal" 
Date: Fri, 8 Dec 2023 14:43:50 -0500
Subject: [PATCH] [FPEnv] Add strictfp in some C++ constructors lacking a
 FunctionDecl.

Some C++ constructors require the strictfp attribute on all function calls
but don't get it because the comstructor lacks a FunctionDecl. Use the
IRBuilder's strictfp mode to communicate that the strictfp attribute is
required. Note that the function calls that were missing the attribute
were getting it from the IRBuilder but it then was getting lost when
CGCall.cpp replaced all the attributes for the function call.

Verified with "https://reviews.llvm.org/D146845;.
---
 clang/include/clang/AST/ExprCXX.h|  4 ++
 clang/lib/CodeGen/CGCall.cpp |  8 +++
 clang/lib/CodeGen/CGDeclCXX.cpp  |  5 ++
 clang/test/CodeGen/fp-floatcontrol-class.cpp | 75 ++--
 4 files changed, 88 insertions(+), 4 deletions(-)

diff --git a/clang/include/clang/AST/ExprCXX.h 
b/clang/include/clang/AST/ExprCXX.h
index 2427801643183..f9269082c3247 100644
--- a/clang/include/clang/AST/ExprCXX.h
+++ b/clang/include/clang/AST/ExprCXX.h
@@ -1698,6 +1698,10 @@ class CXXConstructExpr : public Expr {
   SourceRange getParenOrBraceRange() const { return ParenOrBraceRange; }
   void setParenOrBraceRange(SourceRange Range) { ParenOrBraceRange = Range; }
 
+  /// Determine whether the function was declared in source context
+  /// that requires constrained FP intrinsics
+  bool UsesFPIntrin() const { return Constructor->UsesFPIntrin(); }
+
   static bool classof(const Stmt *T) {
 return T->getStmtClass() == CXXConstructExprClass ||
T->getStmtClass() == CXXTemporaryObjectExprClass;
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index a24aeea7ae32b..7d1bb4dc75ab4 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -5520,6 +5520,12 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo 
,
   CGM.AdjustMemoryAttribute(CalleePtr->getName(), Callee.getAbstractInfo(),
 Attrs);
   }
+  // We may not have a FunctionDecl*, but we still need to support strictfp.
+  if (Builder.getIsFPConstrained()) {
+// All calls within a strictfp function are marked strictfp
+Attrs = Attrs.addFnAttribute(getLLVMContext(), llvm::Attribute::StrictFP);
+  }
+
   // Add call-site nomerge attribute if exists.
   if (InNoMergeAttributedStmt)
 Attrs = Attrs.addFnAttribute(getLLVMContext(), llvm::Attribute::NoMerge);
@@ -5587,10 +5593,12 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo 
,
   !isa_and_nonnull(TargetDecl))
 EmitKCFIOperandBundle(ConcreteCallee, BundleList);
 
+#if 0 // XXX Why is this here? Duplicate!
   if (const FunctionDecl *FD = dyn_cast_or_null(CurFuncDecl))
 if (FD->hasAttr())
   // All calls within a strictfp function are marked strictfp
   Attrs = Attrs.addFnAttribute(getLLVMContext(), 
llvm::Attribute::StrictFP);
+#endif
 
   AssumeAlignedAttrEmitter AssumeAlignedAttrEmitter(*this, TargetDecl);
   Attrs = AssumeAlignedAttrEmitter.TryEmitAsCallSiteAttribute(Attrs);
diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp
index e08a1e5f42df2..5700b7fcb49d3 100644
--- a/clang/lib/CodeGen/CGDeclCXX.cpp
+++ b/clang/lib/CodeGen/CGDeclCXX.cpp
@@ -1012,6 +1012,11 @@ void 
CodeGenFunction::GenerateCXXGlobalVarDeclInitFunc(llvm::Function *Fn,
 
   CurEHLocation = D->getBeginLoc();
 
+  if (const auto *CE = dyn_cast(D->getInit())) {
+if (CE->UsesFPIntrin())
+  Builder.setIsFPConstrained(true);
+  }
+
   StartFunction(GlobalDecl(D, DynamicInitKind::Initializer),
 getContext().VoidTy, Fn, getTypes().arrangeNullaryFunction(),
 FunctionArgList());
diff --git a/clang/test/CodeGen/fp-floatcontrol-class.cpp 
b/clang/test/CodeGen/fp-floatcontrol-class.cpp
index 83a27cb206eb8..c9953119fd3a2 100644
--- a/clang/test/CodeGen/fp-floatcontrol-class.cpp
+++ b/clang/test/CodeGen/fp-floatcontrol-class.cpp
@@ -1,3 +1,4 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --include-generated-funcs --version 4
 // RUN: %clang_cc1 -ffp-contract=on -triple x86_64-linux-gnu -emit-llvm -o - 
%s | FileCheck %s
 // Verify that float_control does not pertain to initializer expressions
 
@@ -6,14 +7,80 @@ float z();
 #pragma 

[clang] [clang] Additional FP classification functions (PR #69041)

2023-10-30 Thread Kevin P. Neal via cfe-commits

https://github.com/kpneal approved this pull request.

The rest LGTM.

https://github.com/llvm/llvm-project/pull/69041
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 91f886a - [FPEnv][TableGen] Add strictfp attribute to constrained intrinsics by default.

2023-07-12 Thread Kevin P. Neal via cfe-commits

Author: Kevin P. Neal
Date: 2023-07-12T09:55:53-04:00
New Revision: 91f886a40d3fbabfc539c2bd8977a1ccb45aa450

URL: 
https://github.com/llvm/llvm-project/commit/91f886a40d3fbabfc539c2bd8977a1ccb45aa450
DIFF: 
https://github.com/llvm/llvm-project/commit/91f886a40d3fbabfc539c2bd8977a1ccb45aa450.diff

LOG: [FPEnv][TableGen] Add strictfp attribute to constrained intrinsics by 
default.

In D146869 @arsenm pointed out that the constrained intrinsics aren't
getting the strictfp attribute by default. They should be since they are
required to have it anyway.

TableGen did not know about this attribute until now. This patch adds
strictfp to TableGen, and it uses it on all of the constrained intrinsics.

Differential Revision: https://reviews.llvm.org/D154991

Added: 
llvm/test/Assembler/fp-intrinsics-attr.ll

Modified: 
clang/test/CodeGenOpenCL/cl20-device-side-enqueue-attributes.cl
llvm/include/llvm/IR/Intrinsics.td
llvm/test/Verifier/fp-intrinsics-pass.ll
llvm/utils/TableGen/CodeGenIntrinsics.cpp
llvm/utils/TableGen/CodeGenIntrinsics.h
llvm/utils/TableGen/IntrinsicEmitter.cpp

Removed: 




diff  --git a/clang/test/CodeGenOpenCL/cl20-device-side-enqueue-attributes.cl 
b/clang/test/CodeGenOpenCL/cl20-device-side-enqueue-attributes.cl
index e7433787c89c88..605790164a7898 100644
--- a/clang/test/CodeGenOpenCL/cl20-device-side-enqueue-attributes.cl
+++ b/clang/test/CodeGenOpenCL/cl20-device-side-enqueue-attributes.cl
@@ -171,7 +171,7 @@ kernel void device_side_enqueue(global float *a, global 
float *b, int i) {
 // STRICTFP: attributes #[[ATTR0]] = { convergent noinline norecurse nounwind 
optnone strictfp "stack-protector-buffer-size"="8" 
"uniform-work-group-size"="false" }
 // STRICTFP: attributes #[[ATTR1:[0-9]+]] = { nocallback nofree nounwind 
willreturn memory(argmem: readwrite) }
 // STRICTFP: attributes #[[ATTR2]] = { convergent noinline nounwind optnone 
strictfp "stack-protector-buffer-size"="8" }
-// STRICTFP: attributes #[[ATTR3:[0-9]+]] = { nocallback nofree nosync 
nounwind willreturn memory(inaccessiblemem: readwrite) }
+// STRICTFP: attributes #[[ATTR3:[0-9]+]] = { nocallback nofree nosync 
nounwind strictfp willreturn memory(inaccessiblemem: readwrite) }
 // STRICTFP: attributes #[[ATTR4]] = { convergent nounwind 
"stack-protector-buffer-size"="8" }
 // STRICTFP: attributes #[[ATTR5]] = { strictfp }
 //.

diff  --git a/llvm/include/llvm/IR/Intrinsics.td 
b/llvm/include/llvm/IR/Intrinsics.td
index 0779d1fd958f60..638a9fda29b15c 100644
--- a/llvm/include/llvm/IR/Intrinsics.td
+++ b/llvm/include/llvm/IR/Intrinsics.td
@@ -1099,7 +1099,11 @@ def int_is_fpclass
 //===--- Constrained Floating Point Intrinsics 
===//
 //
 
-let IntrProperties = [IntrInaccessibleMemOnly, IntrWillReturn] in {
+/// IntrStrictFP - The intrinsic is allowed to be used in an alternate
+/// floating point environment.
+def IntrStrictFP : IntrinsicProperty;
+
+let IntrProperties = [IntrInaccessibleMemOnly, IntrWillReturn, IntrStrictFP] 
in {
   def int_experimental_constrained_fadd : DefaultAttrsIntrinsic<[ 
llvm_anyfloat_ty ],
 [ LLVMMatchType<0>,
   LLVMMatchType<0>,

diff  --git a/llvm/test/Assembler/fp-intrinsics-attr.ll 
b/llvm/test/Assembler/fp-intrinsics-attr.ll
new file mode 100644
index 00..6546d1a275c99f
--- /dev/null
+++ b/llvm/test/Assembler/fp-intrinsics-attr.ll
@@ -0,0 +1,318 @@
+; RUN: llvm-as < %s | llvm-dis | FileCheck %s
+
+; Test to verify that constrained intrinsics all have the strictfp attribute.
+; Ordering is from Intrinsics.td.
+
+define void @func(double %a, double %b, double %c, i32 %i) strictfp {
+; CHECK-LABEL: define void @func
+; CHECK-SAME: (double [[A:%.*]], double [[B:%.*]], double [[C:%.*]], i32 
[[I:%.*]]) #[[ATTR0:[0-9]+]] {
+
+  %add = call double @llvm.experimental.constrained.fadd.f64(
+   double %a, double %b,
+   metadata !"round.dynamic",
+   metadata !"fpexcept.strict")
+
+  %sub = call double @llvm.experimental.constrained.fsub.f64(
+   double %a, double %b,
+   metadata !"round.dynamic",
+   metadata !"fpexcept.strict")
+
+  %mul = call double @llvm.experimental.constrained.fmul.f64(
+   double %a, double %b,
+   metadata !"round.dynamic",
+   metadata !"fpexcept.strict")
+
+  %div = call double @llvm.experimental.constrained.fdiv.f64(
+   double %a, double %b,
+   

[clang] 5eb1fbd - [clang][Docs] Correct typo: "may_trap" is rejected, the value is "maytrap".

2022-10-28 Thread Kevin P. Neal via cfe-commits

Author: Kevin P. Neal
Date: 2022-10-28T11:40:42-04:00
New Revision: 5eb1fbd109734771554465aa307e8205c2a2632e

URL: 
https://github.com/llvm/llvm-project/commit/5eb1fbd109734771554465aa307e8205c2a2632e
DIFF: 
https://github.com/llvm/llvm-project/commit/5eb1fbd109734771554465aa307e8205c2a2632e.diff

LOG: [clang][Docs] Correct typo: "may_trap" is rejected, the value is "maytrap".

Added: 


Modified: 
clang/docs/UsersManual.rst

Removed: 




diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 8d825691721aa..11bc5c9066111 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -1371,7 +1371,7 @@ describes the various floating point semantic modes and 
the corresponding option
   :header: "Mode", "Values"
   :widths: 15, 30, 30
 
-  "ffp-exception-behavior", "{ignore, strict, may_trap}",
+  "ffp-exception-behavior", "{ignore, strict, maytrap}",
   "fenv_access", "{off, on}", "(none)"
   "frounding-math", "{dynamic, tonearest, downward, upward, towardzero}"
   "ffp-contract", "{on, off, fast, fast-honor-pragmas}"



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 81b6987 - [FPEnv][X86] Platform builtins edition: clang should get from the AST the metadata for constrained FP builtins

2021-02-03 Thread Kevin P. Neal via cfe-commits

Author: Kevin P. Neal
Date: 2021-02-03T11:49:17-05:00
New Revision: 81b69879c946533c71cc484bd8d9202bf1e34bfe

URL: 
https://github.com/llvm/llvm-project/commit/81b69879c946533c71cc484bd8d9202bf1e34bfe
DIFF: 
https://github.com/llvm/llvm-project/commit/81b69879c946533c71cc484bd8d9202bf1e34bfe.diff

LOG: [FPEnv][X86] Platform builtins edition: clang should get from the AST the 
metadata for constrained FP builtins

Currently clang is not correctly retrieving from the AST the metadata for
constrained FP builtins. This patch fixes that for the X86 specific builtins.

Differential Revision: https://reviews.llvm.org/D94614

Added: 
clang/test/CodeGen/X86/avx512dq-builtins-constrained.c

Modified: 
clang/lib/CodeGen/CGBuiltin.cpp
clang/test/CodeGen/X86/avx-builtins-constrained-cmp.c
clang/test/CodeGen/X86/avx512f-builtins-constrained.c
clang/test/CodeGen/X86/fma-builtins-constrained.c
clang/test/CodeGen/X86/sse-builtins-constrained.c

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 973a20f2f58c..d8bb1bc84daa 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -11664,7 +11664,7 @@ static Value *EmitX86ConvertToMask(CodeGenFunction 
, Value *In) {
   return EmitX86MaskedCompare(CGF, 1, true, { In, Zero });
 }
 
-static Value *EmitX86ConvertIntToFp(CodeGenFunction ,
+static Value *EmitX86ConvertIntToFp(CodeGenFunction , const CallExpr *E,
 ArrayRef Ops, bool IsSigned) {
   unsigned Rnd = cast(Ops[3])->getZExtValue();
   llvm::Type *Ty = Ops[1]->getType();
@@ -11676,6 +11676,7 @@ static Value *EmitX86ConvertIntToFp(CodeGenFunction 
,
 Function *F = CGF.CGM.getIntrinsic(IID, { Ty, Ops[0]->getType() });
 Res = CGF.Builder.CreateCall(F, { Ops[0], Ops[3] });
   } else {
+CodeGenFunction::CGFPOptionsRAII FPOptsRAII(CGF, E);
 Res = IsSigned ? CGF.Builder.CreateSIToFP(Ops[0], Ty)
: CGF.Builder.CreateUIToFP(Ops[0], Ty);
   }
@@ -11684,8 +11685,9 @@ static Value *EmitX86ConvertIntToFp(CodeGenFunction 
,
 }
 
 // Lowers X86 FMA intrinsics to IR.
-static Value *EmitX86FMAExpr(CodeGenFunction , ArrayRef Ops,
- unsigned BuiltinID, bool IsAddSub) {
+static Value *EmitX86FMAExpr(CodeGenFunction , const CallExpr *E,
+ ArrayRef Ops, unsigned BuiltinID,
+ bool IsAddSub) {
 
   bool Subtract = false;
   Intrinsic::ID IID = Intrinsic::not_intrinsic;
@@ -11742,6 +11744,7 @@ static Value *EmitX86FMAExpr(CodeGenFunction , 
ArrayRef Ops,
 llvm::Type *Ty = A->getType();
 Function *FMA;
 if (CGF.Builder.getIsFPConstrained()) {
+  CodeGenFunction::CGFPOptionsRAII FPOptsRAII(CGF, E);
   FMA = CGF.CGM.getIntrinsic(Intrinsic::experimental_constrained_fma, Ty);
   Res = CGF.Builder.CreateConstrainedFPCall(FMA, {A, B, C});
 } else {
@@ -11783,10 +11786,10 @@ static Value *EmitX86FMAExpr(CodeGenFunction , 
ArrayRef Ops,
   return Res;
 }
 
-static Value *
-EmitScalarFMAExpr(CodeGenFunction , MutableArrayRef Ops,
-  Value *Upper, bool ZeroMask = false, unsigned PTIdx = 0,
-  bool NegAcc = false) {
+static Value *EmitScalarFMAExpr(CodeGenFunction , const CallExpr *E,
+MutableArrayRef Ops, Value *Upper,
+bool ZeroMask = false, unsigned PTIdx = 0,
+bool NegAcc = false) {
   unsigned Rnd = 4;
   if (Ops.size() > 4)
 Rnd = cast(Ops[4])->getZExtValue();
@@ -11805,6 +11808,7 @@ EmitScalarFMAExpr(CodeGenFunction , 
MutableArrayRef Ops,
 Res = CGF.Builder.CreateCall(CGF.CGM.getIntrinsic(IID),
  {Ops[0], Ops[1], Ops[2], Ops[4]});
   } else if (CGF.Builder.getIsFPConstrained()) {
+CodeGenFunction::CGFPOptionsRAII FPOptsRAII(CGF, E);
 Function *FMA = CGF.CGM.getIntrinsic(
 Intrinsic::experimental_constrained_fma, Ops[0]->getType());
 Res = CGF.Builder.CreateConstrainedFPCall(FMA, Ops.slice(0, 3));
@@ -12142,8 +12146,9 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned 
BuiltinID,
   // TODO: The builtins could be removed if the SSE header files used vector
   // extension comparisons directly (vector ordered/unordered may need
   // additional support via __builtin_isnan()).
-  auto getVectorFCmpIR = [this, ](CmpInst::Predicate Pred,
-  bool IsSignaling) {
+  auto getVectorFCmpIR = [this, , E](CmpInst::Predicate Pred,
+ bool IsSignaling) {
+CodeGenFunction::CGFPOptionsRAII FPOptsRAII(*this, E);
 Value *Cmp;
 if (IsSignaling)
   Cmp = Builder.CreateFCmpS(Pred, Ops[0], Ops[1]);
@@ -12385,31 +12390,31 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned 
BuiltinID,
   case X86::BI__builtin_ia32_cvtdq2ps512_mask:

[clang] 7fef551 - Revert "Revert "[FPEnv] Teach the IRBuilder about invoke's correct use of the strictfp attribute.""

2020-12-18 Thread Kevin P. Neal via cfe-commits

Author: Kevin P. Neal
Date: 2020-12-18T12:42:06-05:00
New Revision: 7fef551cb123d9f1956f8ec7a142bd8a63d25fa9

URL: 
https://github.com/llvm/llvm-project/commit/7fef551cb123d9f1956f8ec7a142bd8a63d25fa9
DIFF: 
https://github.com/llvm/llvm-project/commit/7fef551cb123d9f1956f8ec7a142bd8a63d25fa9.diff

LOG: Revert "Revert "[FPEnv] Teach the IRBuilder about invoke's correct use of 
the strictfp attribute.""

Similar to D69312, and documented in D69839, the IRBuilder needs to add
the strictfp attribute to invoke instructions when constrained floating
point is enabled.

This is try 2, with the test corrected.

Differential Revision: https://reviews.llvm.org/D93134

Added: 
clang/test/CodeGen/exceptions-strictfp.c

Modified: 
llvm/include/llvm/IR/IRBuilder.h

Removed: 




diff  --git a/clang/test/CodeGen/exceptions-strictfp.c 
b/clang/test/CodeGen/exceptions-strictfp.c
new file mode 100644
index ..6f9e9f891b6c
--- /dev/null
+++ b/clang/test/CodeGen/exceptions-strictfp.c
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -triple armv7-apple-unknown -ffp-exception-behavior=strict 
-fexperimental-strict-floating-point -emit-llvm -o - %s -fexceptions 
-exception-model=sjlj -fblocks | FileCheck %s
+
+// Verify strictfp attributes on invoke calls (and therefore also on
+// function definitions).
+
+// rdar://problem/8621849
+void test1() {
+  extern void test1_helper(void (^)(int));
+
+  // CHECK: define arm_aapcscc void @test1() [[STRICTFP0:#[0-9]+]] personality 
i8* bitcast (i32 (...)* @__gcc_personality_sj0 to i8*)
+
+  __block int x = 10;
+
+  // CHECK: invoke arm_aapcscc void @test1_helper({{.*}}) [[STRICTFP1:#[0-9]+]]
+  test1_helper(^(int v) { x = v; });
+
+  // CHECK:  landingpad { i8*, i32 }
+  // CHECK-NEXT:   cleanup
+}
+
+void test2_helper();
+void test2() {
+  // CHECK: define arm_aapcscc void @test2() [[STRICTFP0]] personality i8* 
bitcast (i32 (...)* @__gcc_personality_sj0 to i8*) {
+  __block int x = 10;
+  ^{ (void)x; };
+
+  // CHECK: invoke arm_aapcscc void @test2_helper({{.*}}) [[STRICTFP1:#[0-9]+]]
+  test2_helper(5, 6, 7);
+
+  // CHECK:  landingpad { i8*, i32 }
+  // CHECK-NEXT:   cleanup
+}
+void test2_helper(int x, int y) {
+}
+
+// CHECK: attributes [[STRICTFP0]] = { {{.*}}strictfp{{.*}} }
+// CHECK: attributes [[STRICTFP1]] = { strictfp }

diff  --git a/llvm/include/llvm/IR/IRBuilder.h 
b/llvm/include/llvm/IR/IRBuilder.h
index 56005b26a538..6bc5e89453ad 100644
--- a/llvm/include/llvm/IR/IRBuilder.h
+++ b/llvm/include/llvm/IR/IRBuilder.h
@@ -350,7 +350,7 @@ class IRBuilderBase {
 }
   }
 
-  void setConstrainedFPCallAttr(CallInst *I) {
+  void setConstrainedFPCallAttr(CallBase *I) {
 I->addAttribute(AttributeList::FunctionIndex, Attribute::StrictFP);
   }
 
@@ -1088,16 +1088,21 @@ class IRBuilderBase {
ArrayRef Args,
ArrayRef OpBundles,
const Twine  = "") {
-return Insert(
-InvokeInst::Create(Ty, Callee, NormalDest, UnwindDest, Args, 
OpBundles),
-Name);
+InvokeInst *II =
+InvokeInst::Create(Ty, Callee, NormalDest, UnwindDest, Args, 
OpBundles);
+if (IsFPConstrained)
+  setConstrainedFPCallAttr(II);
+return Insert(II, Name);
   }
   InvokeInst *CreateInvoke(FunctionType *Ty, Value *Callee,
BasicBlock *NormalDest, BasicBlock *UnwindDest,
ArrayRef Args = None,
const Twine  = "") {
-return Insert(InvokeInst::Create(Ty, Callee, NormalDest, UnwindDest, Args),
-  Name);
+InvokeInst *II =
+InvokeInst::Create(Ty, Callee, NormalDest, UnwindDest, Args);
+if (IsFPConstrained)
+  setConstrainedFPCallAttr(II);
+return Insert(II, Name);
   }
 
   InvokeInst *CreateInvoke(FunctionCallee Callee, BasicBlock *NormalDest,



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 2ec5973 - Revert "[FPEnv] Teach the IRBuilder about invoke's correct use of the strictfp attribute."

2020-12-15 Thread Kevin P. Neal via cfe-commits

Author: Kevin P. Neal
Date: 2020-12-15T12:58:47-05:00
New Revision: 2ec5973fddb07e66ae0df7d0aac2cda55387b0bd

URL: 
https://github.com/llvm/llvm-project/commit/2ec5973fddb07e66ae0df7d0aac2cda55387b0bd
DIFF: 
https://github.com/llvm/llvm-project/commit/2ec5973fddb07e66ae0df7d0aac2cda55387b0bd.diff

LOG: Revert "[FPEnv] Teach the IRBuilder about invoke's correct use of the 
strictfp attribute."

The test is busted on some hosts that aren't the one I'm using.

This reverts commit 67a1ffd88ac08526bb6cfc7b3f607e6668ba1c70.

Added: 


Modified: 
llvm/include/llvm/IR/IRBuilder.h

Removed: 
clang/test/CodeGen/exceptions-strictfp.c



diff  --git a/clang/test/CodeGen/exceptions-strictfp.c 
b/clang/test/CodeGen/exceptions-strictfp.c
deleted file mode 100644
index f1c279908e45..
--- a/clang/test/CodeGen/exceptions-strictfp.c
+++ /dev/null
@@ -1,37 +0,0 @@
-// RUN: %clang_cc1 -triple armv7-apple-unknown -ffp-exception-behavior=strict 
-fexperimental-strict-floating-point -emit-llvm -o - %s -fexceptions 
-fsjlj-exceptions -fblocks | FileCheck %s
-
-// Verify strictfp attributes on invoke calls (and therefore also on
-// function definitions).
-
-// rdar://problem/8621849
-void test1() {
-  extern void test1_helper(void (^)(int));
-
-  // CHECK: define arm_aapcscc void @test1() [[STRICTFP0:#[0-9]+]] personality 
i8* bitcast (i32 (...)* @__gcc_personality_sj0 to i8*)
-
-  __block int x = 10;
-
-  // CHECK: invoke arm_aapcscc void @test1_helper({{.*}}) [[STRICTFP1:#[0-9]+]]
-  test1_helper(^(int v) { x = v; });
-
-  // CHECK:  landingpad { i8*, i32 }
-  // CHECK-NEXT:   cleanup
-}
-
-void test2_helper();
-void test2() {
-  // CHECK: define arm_aapcscc void @test2() [[STRICTFP0]] personality i8* 
bitcast (i32 (...)* @__gcc_personality_sj0 to i8*) {
-  __block int x = 10;
-  ^{ (void)x; };
-
-  // CHECK: invoke arm_aapcscc void @test2_helper({{.*}}) [[STRICTFP1:#[0-9]+]]
-  test2_helper(5, 6, 7);
-
-  // CHECK:  landingpad { i8*, i32 }
-  // CHECK-NEXT:   cleanup
-}
-void test2_helper(int x, int y) {
-}
-
-// CHECK: attributes [[STRICTFP0]] = { {{.*}}strictfp{{.*}} }
-// CHECK: attributes [[STRICTFP1]] = { strictfp }

diff  --git a/llvm/include/llvm/IR/IRBuilder.h 
b/llvm/include/llvm/IR/IRBuilder.h
index 6010f1a706a3..c2b3446d159f 100644
--- a/llvm/include/llvm/IR/IRBuilder.h
+++ b/llvm/include/llvm/IR/IRBuilder.h
@@ -301,7 +301,7 @@ class IRBuilderBase {
 }
   }
 
-  void setConstrainedFPCallAttr(CallBase *I) {
+  void setConstrainedFPCallAttr(CallInst *I) {
 I->addAttribute(AttributeList::FunctionIndex, Attribute::StrictFP);
   }
 
@@ -1023,21 +1023,16 @@ class IRBuilderBase {
ArrayRef Args,
ArrayRef OpBundles,
const Twine  = "") {
-InvokeInst *II =
-InvokeInst::Create(Ty, Callee, NormalDest, UnwindDest, Args, 
OpBundles);
-if (IsFPConstrained)
-  setConstrainedFPCallAttr(II);
-return Insert(II, Name);
+return Insert(
+InvokeInst::Create(Ty, Callee, NormalDest, UnwindDest, Args, 
OpBundles),
+Name);
   }
   InvokeInst *CreateInvoke(FunctionType *Ty, Value *Callee,
BasicBlock *NormalDest, BasicBlock *UnwindDest,
ArrayRef Args = None,
const Twine  = "") {
-InvokeInst *II =
-InvokeInst::Create(Ty, Callee, NormalDest, UnwindDest, Args);
-if (IsFPConstrained)
-  setConstrainedFPCallAttr(II);
-return Insert(II, Name);
+return Insert(InvokeInst::Create(Ty, Callee, NormalDest, UnwindDest, Args),
+  Name);
   }
 
   InvokeInst *CreateInvoke(FunctionCallee Callee, BasicBlock *NormalDest,



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 67a1ffd - [FPEnv] Teach the IRBuilder about invoke's correct use of the strictfp attribute.

2020-12-15 Thread Kevin P. Neal via cfe-commits

Author: Kevin P. Neal
Date: 2020-12-15T12:38:10-05:00
New Revision: 67a1ffd88ac08526bb6cfc7b3f607e6668ba1c70

URL: 
https://github.com/llvm/llvm-project/commit/67a1ffd88ac08526bb6cfc7b3f607e6668ba1c70
DIFF: 
https://github.com/llvm/llvm-project/commit/67a1ffd88ac08526bb6cfc7b3f607e6668ba1c70.diff

LOG: [FPEnv] Teach the IRBuilder about invoke's correct use of the strictfp 
attribute.

Similar to D69312, and documented in D69839, the IRBuilder needs to add
the strictfp attribute to invoke instructions when constrained floating
point is enabled.

Differential Revision: https://reviews.llvm.org/D93134

Added: 
clang/test/CodeGen/exceptions-strictfp.c

Modified: 
llvm/include/llvm/IR/IRBuilder.h

Removed: 




diff  --git a/clang/test/CodeGen/exceptions-strictfp.c 
b/clang/test/CodeGen/exceptions-strictfp.c
new file mode 100644
index ..f1c279908e45
--- /dev/null
+++ b/clang/test/CodeGen/exceptions-strictfp.c
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -triple armv7-apple-unknown -ffp-exception-behavior=strict 
-fexperimental-strict-floating-point -emit-llvm -o - %s -fexceptions 
-fsjlj-exceptions -fblocks | FileCheck %s
+
+// Verify strictfp attributes on invoke calls (and therefore also on
+// function definitions).
+
+// rdar://problem/8621849
+void test1() {
+  extern void test1_helper(void (^)(int));
+
+  // CHECK: define arm_aapcscc void @test1() [[STRICTFP0:#[0-9]+]] personality 
i8* bitcast (i32 (...)* @__gcc_personality_sj0 to i8*)
+
+  __block int x = 10;
+
+  // CHECK: invoke arm_aapcscc void @test1_helper({{.*}}) [[STRICTFP1:#[0-9]+]]
+  test1_helper(^(int v) { x = v; });
+
+  // CHECK:  landingpad { i8*, i32 }
+  // CHECK-NEXT:   cleanup
+}
+
+void test2_helper();
+void test2() {
+  // CHECK: define arm_aapcscc void @test2() [[STRICTFP0]] personality i8* 
bitcast (i32 (...)* @__gcc_personality_sj0 to i8*) {
+  __block int x = 10;
+  ^{ (void)x; };
+
+  // CHECK: invoke arm_aapcscc void @test2_helper({{.*}}) [[STRICTFP1:#[0-9]+]]
+  test2_helper(5, 6, 7);
+
+  // CHECK:  landingpad { i8*, i32 }
+  // CHECK-NEXT:   cleanup
+}
+void test2_helper(int x, int y) {
+}
+
+// CHECK: attributes [[STRICTFP0]] = { {{.*}}strictfp{{.*}} }
+// CHECK: attributes [[STRICTFP1]] = { strictfp }

diff  --git a/llvm/include/llvm/IR/IRBuilder.h 
b/llvm/include/llvm/IR/IRBuilder.h
index c2b3446d159f..6010f1a706a3 100644
--- a/llvm/include/llvm/IR/IRBuilder.h
+++ b/llvm/include/llvm/IR/IRBuilder.h
@@ -301,7 +301,7 @@ class IRBuilderBase {
 }
   }
 
-  void setConstrainedFPCallAttr(CallInst *I) {
+  void setConstrainedFPCallAttr(CallBase *I) {
 I->addAttribute(AttributeList::FunctionIndex, Attribute::StrictFP);
   }
 
@@ -1023,16 +1023,21 @@ class IRBuilderBase {
ArrayRef Args,
ArrayRef OpBundles,
const Twine  = "") {
-return Insert(
-InvokeInst::Create(Ty, Callee, NormalDest, UnwindDest, Args, 
OpBundles),
-Name);
+InvokeInst *II =
+InvokeInst::Create(Ty, Callee, NormalDest, UnwindDest, Args, 
OpBundles);
+if (IsFPConstrained)
+  setConstrainedFPCallAttr(II);
+return Insert(II, Name);
   }
   InvokeInst *CreateInvoke(FunctionType *Ty, Value *Callee,
BasicBlock *NormalDest, BasicBlock *UnwindDest,
ArrayRef Args = None,
const Twine  = "") {
-return Insert(InvokeInst::Create(Ty, Callee, NormalDest, UnwindDest, Args),
-  Name);
+InvokeInst *II =
+InvokeInst::Create(Ty, Callee, NormalDest, UnwindDest, Args);
+if (IsFPConstrained)
+  setConstrainedFPCallAttr(II);
+return Insert(II, Name);
   }
 
   InvokeInst *CreateInvoke(FunctionCallee Callee, BasicBlock *NormalDest,



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] acd4950 - [FPEnv] Correct constrained metadata in fp16-ops-strict.c

2020-12-08 Thread Kevin P. Neal via cfe-commits

Author: Kevin P. Neal
Date: 2020-12-08T10:18:32-05:00
New Revision: acd4950d4f1e4ef5375a8a894a5b359caf7e844b

URL: 
https://github.com/llvm/llvm-project/commit/acd4950d4f1e4ef5375a8a894a5b359caf7e844b
DIFF: 
https://github.com/llvm/llvm-project/commit/acd4950d4f1e4ef5375a8a894a5b359caf7e844b.diff

LOG: [FPEnv] Correct constrained metadata in fp16-ops-strict.c

This test shows we're in some cases not getting strictfp information from
the AST. Correct that.

Differential Revision: https://reviews.llvm.org/D92596

Added: 


Modified: 
clang/lib/CodeGen/CGExprScalar.cpp
clang/test/CodeGen/fp16-ops-strictfp.c

Removed: 




diff  --git a/clang/lib/CodeGen/CGExprScalar.cpp 
b/clang/lib/CodeGen/CGExprScalar.cpp
index 4210e810acb7..973cefd831e6 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -2550,6 +2550,7 @@ ScalarExprEmitter::EmitScalarPrePostIncDec(const 
UnaryOperator *E, LValue LV,
   } else if (type->isRealFloatingType()) {
 // Add the inc/dec to the real part.
 llvm::Value *amt;
+CodeGenFunction::CGFPOptionsRAII FPOptsRAII(CGF, E);
 
 if (type->isHalfType() && !CGF.getContext().getLangOpts().NativeHalfType) {
   // Another special case: half FP increment should be done via float
@@ -3001,6 +3002,7 @@ LValue ScalarExprEmitter::EmitCompoundAssignLValue(
   else
 OpInfo.LHS = EmitLoadOfLValue(LHSLV, E->getExprLoc());
 
+  CodeGenFunction::CGFPOptionsRAII FPOptsRAII(CGF, OpInfo.FPFeatures);
   SourceLocation Loc = E->getExprLoc();
   OpInfo.LHS =
   EmitScalarConversion(OpInfo.LHS, LHSTy, E->getComputationLHSType(), Loc);

diff  --git a/clang/test/CodeGen/fp16-ops-strictfp.c 
b/clang/test/CodeGen/fp16-ops-strictfp.c
index fd50d56a852c..d81febad0c36 100644
--- a/clang/test/CodeGen/fp16-ops-strictfp.c
+++ b/clang/test/CodeGen/fp16-ops-strictfp.c
@@ -11,7 +11,6 @@
 //
 // Test that the constrained intrinsics are picking up the exception
 // metadata from the AST instead of the global default from the command line.
-// FIXME: All cases of "fpexcept.maytrap" in this test are wrong.
 
 #pragma float_control(except, on)
 
@@ -62,31 +61,31 @@ void foo(void) {
   // NOTNATIVE: store {{.*}} half {{.*}}, half*
   h1 = +h1;
 
-  // NATIVE-HALF: call half @llvm.experimental.constrained.fadd.f16(half 
%{{.*}}, half 0xH3C00, metadata !"round.tonearest", metadata 
!"fpexcept.maytrap")
-  // NOTNATIVE: call float @llvm.experimental.constrained.fpext.f32.f16(half 
%{{.*}}, metadata !"fpexcept.maytrap")
-  // NOTNATIVE: call float @llvm.experimental.constrained.fadd.f32(float 
%{{.*}}, float {{.*}}, metadata !"round.tonearest", metadata 
!"fpexcept.maytrap")
-  // NOTNATIVE: call half @llvm.experimental.constrained.fptrunc.f16.f32(float 
%{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.maytrap")
+  // NATIVE-HALF: call half @llvm.experimental.constrained.fadd.f16(half 
%{{.*}}, half 0xH3C00, metadata !"round.tonearest", metadata !"fpexcept.strict")
+  // NOTNATIVE: call float @llvm.experimental.constrained.fpext.f32.f16(half 
%{{.*}}, metadata !"fpexcept.strict")
+  // NOTNATIVE: call float @llvm.experimental.constrained.fadd.f32(float 
%{{.*}}, float {{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
+  // NOTNATIVE: call half @llvm.experimental.constrained.fptrunc.f16.f32(float 
%{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
   // CHECK: store {{.*}} half {{.*}}, half*
   h1++;
 
-  // NATIVE-HALF: call half @llvm.experimental.constrained.fadd.f16(half 
%{{.*}}, half 0xH3C00, metadata !"round.tonearest", metadata 
!"fpexcept.maytrap")
-  // NOTNATIVE: call float @llvm.experimental.constrained.fpext.f32.f16(half 
%{{.*}}, metadata !"fpexcept.maytrap")
-  // NOTNATIVE: call float @llvm.experimental.constrained.fadd.f32(float 
%{{.*}}, float {{.*}}, metadata !"round.tonearest", metadata 
!"fpexcept.maytrap")
-  // NOTNATIVE: call half @llvm.experimental.constrained.fptrunc.f16.f32(float 
%{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.maytrap")
+  // NATIVE-HALF: call half @llvm.experimental.constrained.fadd.f16(half 
%{{.*}}, half 0xH3C00, metadata !"round.tonearest", metadata !"fpexcept.strict")
+  // NOTNATIVE: call float @llvm.experimental.constrained.fpext.f32.f16(half 
%{{.*}}, metadata !"fpexcept.strict")
+  // NOTNATIVE: call float @llvm.experimental.constrained.fadd.f32(float 
%{{.*}}, float {{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
+  // NOTNATIVE: call half @llvm.experimental.constrained.fptrunc.f16.f32(float 
%{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
   // CHECK: store {{.*}} half {{.*}}, half*
   ++h1;
 
-  // NATIVE-HALF: call half @llvm.experimental.constrained.fadd.f16(half 
%{{.*}}, half 0xHBC00, metadata !"round.tonearest", metadata 
!"fpexcept.maytrap")
-  // NOTNATIVE: call float @llvm.experimental.constrained.fpext.f32.f16(half 
%{{.*}}, 

[clang] abfbc55 - [FPEnv] clang should get from the AST the metadata for constrained FP builtins

2020-11-30 Thread Kevin P. Neal via cfe-commits

Author: Kevin P. Neal
Date: 2020-11-30T11:59:37-05:00
New Revision: abfbc5579bd4507ae286d4f29f8a157de0629372

URL: 
https://github.com/llvm/llvm-project/commit/abfbc5579bd4507ae286d4f29f8a157de0629372
DIFF: 
https://github.com/llvm/llvm-project/commit/abfbc5579bd4507ae286d4f29f8a157de0629372.diff

LOG: [FPEnv] clang should get from the AST the metadata for constrained FP 
builtins

Currently clang is not correctly retrieving from the AST the metadata for
constrained FP builtins. This patch fixes that for the non-target specific
builtins.

Differential Revision: https://reviews.llvm.org/D92122

Added: 
clang/test/CodeGen/strictfp_fpclassify.c

Modified: 
clang/lib/CodeGen/CGBuiltin.cpp
clang/test/CodeGen/builtin_float_strictfp.c
clang/test/CodeGen/constrained-math-builtins.c

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 828d66f83de9..73897a27bd94 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -440,6 +440,7 @@ static Value 
*emitUnaryMaybeConstrainedFPBuiltin(CodeGenFunction ,
   llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0));
 
   if (CGF.Builder.getIsFPConstrained()) {
+CodeGenFunction::CGFPOptionsRAII FPOptsRAII(CGF, E);
 Function *F = CGF.CGM.getIntrinsic(ConstrainedIntrinsicID, 
Src0->getType());
 return CGF.Builder.CreateConstrainedFPCall(F, { Src0 });
   } else {
@@ -457,6 +458,7 @@ static Value 
*emitBinaryMaybeConstrainedFPBuiltin(CodeGenFunction ,
   llvm::Value *Src1 = CGF.EmitScalarExpr(E->getArg(1));
 
   if (CGF.Builder.getIsFPConstrained()) {
+CodeGenFunction::CGFPOptionsRAII FPOptsRAII(CGF, E);
 Function *F = CGF.CGM.getIntrinsic(ConstrainedIntrinsicID, 
Src0->getType());
 return CGF.Builder.CreateConstrainedFPCall(F, { Src0, Src1 });
   } else {
@@ -475,6 +477,7 @@ static Value 
*emitTernaryMaybeConstrainedFPBuiltin(CodeGenFunction ,
   llvm::Value *Src2 = CGF.EmitScalarExpr(E->getArg(2));
 
   if (CGF.Builder.getIsFPConstrained()) {
+CodeGenFunction::CGFPOptionsRAII FPOptsRAII(CGF, E);
 Function *F = CGF.CGM.getIntrinsic(ConstrainedIntrinsicID, 
Src0->getType());
 return CGF.Builder.CreateConstrainedFPCall(F, { Src0, Src1, Src2 });
   } else {
@@ -556,6 +559,7 @@ emitMaybeConstrainedFPToIntRoundBuiltin(CodeGenFunction 
, const CallExpr *E,
   llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0));
 
   if (CGF.Builder.getIsFPConstrained()) {
+CodeGenFunction::CGFPOptionsRAII FPOptsRAII(CGF, E);
 Function *F = CGF.CGM.getIntrinsic(ConstrainedIntrinsicID,
{ResultType, Src0->getType()});
 return CGF.Builder.CreateConstrainedFPCall(F, {Src0});
@@ -2218,6 +,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
 case Builtin::BI__builtin_fmodf16:
 case Builtin::BI__builtin_fmodl:
 case Builtin::BI__builtin_fmodf128: {
+  CodeGenFunction::CGFPOptionsRAII FPOptsRAII(*this, E);
   Value *Arg1 = EmitScalarExpr(E->getArg(0));
   Value *Arg2 = EmitScalarExpr(E->getArg(1));
   return RValue::get(Builder.CreateFRem(Arg1, Arg2, "fmod"));
@@ -2828,6 +2833,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
   case Builtin::BI__builtin_isunordered: {
 // Ordered comparisons: we know the arguments to these are matching scalar
 // floating point values.
+CodeGenFunction::CGFPOptionsRAII FPOptsRAII(*this, E);
+// FIXME: for strictfp/IEEE-754 we need to not trap on SNaN here.
 Value *LHS = EmitScalarExpr(E->getArg(0));
 Value *RHS = EmitScalarExpr(E->getArg(1));
 
@@ -2856,6 +2863,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
 return RValue::get(Builder.CreateZExt(LHS, ConvertType(E->getType(;
   }
   case Builtin::BI__builtin_isnan: {
+CodeGenFunction::CGFPOptionsRAII FPOptsRAII(*this, E);
+// FIXME: for strictfp/IEEE-754 we need to not trap on SNaN here.
 Value *V = EmitScalarExpr(E->getArg(0));
 V = Builder.CreateFCmpUNO(V, V, "cmp");
 return RValue::get(Builder.CreateZExt(V, ConvertType(E->getType(;
@@ -2919,6 +2928,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
 // isinf(x)--> fabs(x) == infinity
 // isfinite(x) --> fabs(x) != infinity
 // x != NaN via the ordered compare in either case.
+CodeGenFunction::CGFPOptionsRAII FPOptsRAII(*this, E);
+// FIXME: for strictfp/IEEE-754 we need to not trap on SNaN here.
 Value *V = EmitScalarExpr(E->getArg(0));
 Value *Fabs = EmitFAbs(*this, V);
 Constant *Infinity = ConstantFP::getInfinity(V->getType());
@@ -2931,6 +2942,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
 
   case Builtin::BI__builtin_isinf_sign: {
 // isinf_sign(x) -> fabs(x) == infinity ? (signbit(x) ? -1 : 

[clang] ac523d2 - [FPEnv][Clang][Driver] Use MarshallingInfoFlag for -fexperimental-strict-floating-point

2020-11-12 Thread Kevin P. Neal via cfe-commits

Author: Kevin P. Neal
Date: 2020-11-12T12:51:35-05:00
New Revision: ac523d2de51c4119ae6233200af07599d61de1fc

URL: 
https://github.com/llvm/llvm-project/commit/ac523d2de51c4119ae6233200af07599d61de1fc
DIFF: 
https://github.com/llvm/llvm-project/commit/ac523d2de51c4119ae6233200af07599d61de1fc.diff

LOG: [FPEnv][Clang][Driver] Use MarshallingInfoFlag for 
-fexperimental-strict-floating-point

As of D80952 we are disabling strict floating point on all hosts except
those that are explicitly listed as supported. Use of strict floating point
on other hosts requires use of the -fexperimental-strict-floating-point
flag. This is to avoid bugs like "https://bugs.llvm.org/show_bug.cgi?id=45329;
(which has an incorrect link in the previous review).

In the review for D80952 I was asked to mark the -fexperimental option as
a MarshallingInfoFlag. This patch does exactly that.

Differential Revision: https://reviews.llvm.org/D88987

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 6df4a0222484..245e6765d613 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1308,7 +1308,8 @@ def fexperimental_new_pass_manager : Flag<["-"], 
"fexperimental-new-pass-manager
   HelpText<"Enables an experimental new pass manager in LLVM.">;
 def fexperimental_strict_floating_point : Flag<["-"], 
"fexperimental-strict-floating-point">,
   Group, Flags<[CC1Option]>,
-  HelpText<"Enables experimental strict floating point in LLVM.">;
+  HelpText<"Enables experimental strict floating point in LLVM.">,
+  MarshallingInfoFlag<"LangOpts->ExpStrictFP">;
 def finput_charset_EQ : Joined<["-"], "finput-charset=">, Group;
 def fexec_charset_EQ : Joined<["-"], "fexec-charset=">, Group;
 def finstrument_functions : Flag<["-"], "finstrument-functions">, 
Group, Flags<[CC1Option]>,

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index b2ce88f6cf6b..ffcc3d359e62 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -3335,9 +3335,6 @@ static void ParseLangArgs(LangOptions , ArgList 
, InputKind IK,
   Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Val;
   }
 
-  if (Args.hasArg(OPT_fexperimental_strict_floating_point))
-Opts.ExpStrictFP = true;
-
   auto FPRM = llvm::RoundingMode::NearestTiesToEven;
   if (Args.hasArg(OPT_frounding_math)) {
 FPRM = llvm::RoundingMode::Dynamic;



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 523a851 - [FPEnv][Clang][Driver] Disable constrained floating point on targets lacking support."

2020-07-10 Thread Kevin P. Neal via cfe-commits

Author: Kevin P. Neal
Date: 2020-07-10T10:34:15-04:00
New Revision: 523a8513f8ba4d6b111496c541b9ba9f4d5f0261

URL: 
https://github.com/llvm/llvm-project/commit/523a8513f8ba4d6b111496c541b9ba9f4d5f0261
DIFF: 
https://github.com/llvm/llvm-project/commit/523a8513f8ba4d6b111496c541b9ba9f4d5f0261.diff

LOG: [FPEnv][Clang][Driver] Disable constrained floating point on targets 
lacking support."

Use the new -fexperimental-strict-floating-point flag in more cases to
fix the arm and aarch64 bots.

Differential Revision: https://reviews.llvm.org/D80952

Added: 


Modified: 
clang/test/CodeGen/fpconstrained-cmp-double.c
clang/test/CodeGen/fpconstrained-cmp-float.c

Removed: 




diff  --git a/clang/test/CodeGen/fpconstrained-cmp-double.c 
b/clang/test/CodeGen/fpconstrained-cmp-double.c
index 6f19db2099db..335b7e49b01d 100644
--- a/clang/test/CodeGen/fpconstrained-cmp-double.c
+++ b/clang/test/CodeGen/fpconstrained-cmp-double.c
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -ffp-exception-behavior=ignore -emit-llvm -o - %s | 
FileCheck %s -check-prefix=CHECK -check-prefix=FCMP
 // RUN: %clang_cc1 -ffp-exception-behavior=strict 
-fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s 
-check-prefix=CHECK -check-prefix=EXCEPT
 // RUN: %clang_cc1 -ffp-exception-behavior=maytrap 
-fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s 
-check-prefix=CHECK -check-prefix=MAYTRAP
-// RUN: %clang_cc1 -frounding-math -ffp-exception-behavior=ignore -emit-llvm 
-o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=IGNORE
+// RUN: %clang_cc1 -frounding-math -ffp-exception-behavior=ignore 
-fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s 
-check-prefix=CHECK -check-prefix=IGNORE
 // RUN: %clang_cc1 -frounding-math -ffp-exception-behavior=strict 
-fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s 
-check-prefix=CHECK -check-prefix=EXCEPT
 // RUN: %clang_cc1 -frounding-math -ffp-exception-behavior=maytrap 
-fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s 
-check-prefix=CHECK -check-prefix=MAYTRAP
 

diff  --git a/clang/test/CodeGen/fpconstrained-cmp-float.c 
b/clang/test/CodeGen/fpconstrained-cmp-float.c
index bca0cdb7eda4..e9667904122b 100644
--- a/clang/test/CodeGen/fpconstrained-cmp-float.c
+++ b/clang/test/CodeGen/fpconstrained-cmp-float.c
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -ffp-exception-behavior=ignore -emit-llvm -o - %s | 
FileCheck %s -check-prefix=CHECK -check-prefix=FCMP
+// RUN: %clang_cc1 -ffp-exception-behavior=ignore 
-fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s 
-check-prefix=CHECK -check-prefix=FCMP
 // RUN: %clang_cc1 -ffp-exception-behavior=strict 
-fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s 
-check-prefix=CHECK -check-prefix=EXCEPT
 // RUN: %clang_cc1 -ffp-exception-behavior=maytrap 
-fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s 
-check-prefix=CHECK -check-prefix=MAYTRAP
-// RUN: %clang_cc1 -frounding-math -ffp-exception-behavior=ignore -emit-llvm 
-o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=IGNORE
+// RUN: %clang_cc1 -frounding-math -ffp-exception-behavior=ignore 
-fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s 
-check-prefix=CHECK -check-prefix=IGNORE
 // RUN: %clang_cc1 -frounding-math -ffp-exception-behavior=strict 
-fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s 
-check-prefix=CHECK -check-prefix=EXCEPT
 // RUN: %clang_cc1 -frounding-math -ffp-exception-behavior=maytrap 
-fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s 
-check-prefix=CHECK -check-prefix=MAYTRAP
 



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] d4ce862 - Reland "[FPEnv][Clang][Driver] Disable constrained floating point on targets lacking support."

2020-07-10 Thread Kevin P. Neal via cfe-commits

Author: Kevin P. Neal
Date: 2020-07-10T08:49:45-04:00
New Revision: d4ce862f2aa8b7e4b11462bd72014b08ab9468b3

URL: 
https://github.com/llvm/llvm-project/commit/d4ce862f2aa8b7e4b11462bd72014b08ab9468b3
DIFF: 
https://github.com/llvm/llvm-project/commit/d4ce862f2aa8b7e4b11462bd72014b08ab9468b3.diff

LOG: Reland "[FPEnv][Clang][Driver] Disable constrained floating point on 
targets lacking support."

We currently have strict floating point/constrained floating point enabled
for all targets. Constrained SDAG nodes get converted to the regular ones
before reaching the target layer. In theory this should be fine.

However, the changes are exposed to users through multiple clang options
already in use in the field, and the changes are _completely_ _untested_
on almost all of our targets. Bugs have already been found, like
"https://bugs.llvm.org/show_bug.cgi?id=45274;.

This patch disables constrained floating point options in clang everywhere
except X86 and SystemZ. A warning will be printed when this happens.

Use the new -fexperimental-strict-floating-point flag to force allowing
strict floating point on hosts that aren't already marked as supporting
it (X86 and SystemZ).

Differential Revision: https://reviews.llvm.org/D80952

Added: 
clang/test/CodeGen/fp-strictfp-exp.cpp
clang/test/CodeGen/fp-strictfp.cpp

Modified: 
clang/docs/ClangCommandLineReference.rst
clang/include/clang/Basic/CodeGenOptions.def
clang/include/clang/Basic/DiagnosticFrontendKinds.td
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/LangOptions.def
clang/include/clang/Basic/TargetInfo.h
clang/include/clang/Driver/Options.td
clang/lib/Basic/TargetInfo.cpp
clang/lib/Basic/Targets/SystemZ.h
clang/lib/Basic/Targets/X86.h
clang/lib/Frontend/CompilerInstance.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/CodeGen/aarch64-neon-misc-constrained.c
clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem-constrained.c
clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c
clang/test/CodeGen/arm-neon-directed-rounding-constrained.c
clang/test/CodeGen/arm64-vrnd-constrained.c
clang/test/CodeGen/builtins-ppc-fpconstrained.c
clang/test/CodeGen/fpconstrained-cmp-double.c
clang/test/CodeGen/fpconstrained-cmp-float.c
clang/test/CodeGen/fpconstrained.c
clang/test/CodeGen/fpconstrained.cpp

Removed: 




diff  --git a/clang/docs/ClangCommandLineReference.rst 
b/clang/docs/ClangCommandLineReference.rst
index 0b56b7ac4206..1613c8e45318 100644
--- a/clang/docs/ClangCommandLineReference.rst
+++ b/clang/docs/ClangCommandLineReference.rst
@@ -818,6 +818,10 @@ Discard value names in LLVM IR
 
 Enables an experimental new pass manager in LLVM.
 
+.. option:: -fexperimental-strict-floating-point
+
+Enables the use of non-default rounding modes and non-default exception 
handling on targets that are not currently ready.
+
 .. option:: -ffine-grained-bitfield-accesses, 
-fno-fine-grained-bitfield-accesses
 
 Use separate accesses for consecutive bitfield runs with legal widths and 
alignments.

diff  --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index d465e00d4c70..67c0b4203420 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -58,6 +58,8 @@ CODEGENOPT(DisableLLVMPasses , 1, 0) ///< Don't run any LLVM 
IR passes to get
  ///< frontend.
 CODEGENOPT(DisableLifetimeMarkers, 1, 0) ///< Don't emit any lifetime markers
 CODEGENOPT(DisableO0ImplyOptNone , 1, 0) ///< Don't annonate function with 
optnone at O0
+CODEGENOPT(ExperimentalStrictFloatingPoint, 1, 0) ///< Enables the new, 
experimental
+  ///< strict floating point.
 CODEGENOPT(ExperimentalNewPassManager, 1, 0) ///< Enables the new, experimental
  ///< pass manager.
 CODEGENOPT(DebugPassManager, 1, 0) ///< Prints debug information for the new

diff  --git a/clang/include/clang/Basic/DiagnosticFrontendKinds.td 
b/clang/include/clang/Basic/DiagnosticFrontendKinds.td
index ceb24bce5978..b202d2abffa0 100644
--- a/clang/include/clang/Basic/DiagnosticFrontendKinds.td
+++ b/clang/include/clang/Basic/DiagnosticFrontendKinds.td
@@ -37,6 +37,12 @@ def note_fe_backend_plugin: Note<"%0">, BackendInfo;
 def warn_fe_override_module : Warning<
 "overriding the module target triple with %0">,
 InGroup>;
+def warn_fe_backend_unsupported_fp_rounding : Warning<
+"overriding currently unsupported rounding mode on this target">,
+InGroup;
+def warn_fe_backend_unsupported_fp_exceptions : Warning<
+"overriding currently unsupported use of floating point exceptions "
+"on this target">, InGroup;
 
 def remark_fe_backend_optimization_remark : Remark<"%0">, 

[clang] 916e2ca - Revert "[FPEnv][Clang][Driver] Disable constrained floating point on targets lacking support."

2020-07-06 Thread Kevin P. Neal via cfe-commits

Author: Kevin P. Neal
Date: 2020-07-06T14:57:45-04:00
New Revision: 916e2ca99785d34db73945940923a487efad32ad

URL: 
https://github.com/llvm/llvm-project/commit/916e2ca99785d34db73945940923a487efad32ad
DIFF: 
https://github.com/llvm/llvm-project/commit/916e2ca99785d34db73945940923a487efad32ad.diff

LOG: Revert "[FPEnv][Clang][Driver] Disable constrained floating point on 
targets lacking support."

My mistake, I had a blocking reviewer.

This reverts commit 39d2ae0afb2312a15e4d15a0855b35b4e1c49fc4.
This reverts commit bfdafa32a0fa4b2745627fe57dd253db10ac3fcf.
This reverts commit 2b35511350454dd22997f129ee529e3fdb129ac2.

Differential Revision: https://reviews.llvm.org/D80952

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticFrontendKinds.td
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/TargetInfo.h
clang/lib/Basic/TargetInfo.cpp
clang/lib/Basic/Targets/SystemZ.h
clang/lib/Basic/Targets/X86.h
clang/lib/Frontend/CompilerInstance.cpp
clang/test/CodeGen/aarch64-neon-misc-constrained.c
clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem-constrained.c
clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c
clang/test/CodeGen/arm-neon-directed-rounding-constrained.c
clang/test/CodeGen/arm64-vrnd-constrained.c
clang/test/CodeGen/builtins-ppc-fpconstrained.c
clang/test/CodeGen/fpconstrained-cmp-double.c
clang/test/CodeGen/fpconstrained-cmp-float.c
clang/test/CodeGen/fpconstrained.c
clang/test/CodeGen/fpconstrained.cpp

Removed: 
clang/test/CodeGen/fp-strictfp.cpp



diff  --git a/clang/include/clang/Basic/DiagnosticFrontendKinds.td 
b/clang/include/clang/Basic/DiagnosticFrontendKinds.td
index db334a7899c4..83c13e0dbbe0 100644
--- a/clang/include/clang/Basic/DiagnosticFrontendKinds.td
+++ b/clang/include/clang/Basic/DiagnosticFrontendKinds.td
@@ -37,12 +37,6 @@ def note_fe_backend_plugin: Note<"%0">, BackendInfo;
 def warn_fe_override_module : Warning<
 "overriding the module target triple with %0">,
 InGroup>;
-def warn_fe_backend_unsupported_fp_rounding : Warning<
-"overriding currently unsupported rounding mode on this target">,
-InGroup;
-def warn_fe_backend_unsupported_fp_exceptions : Warning<
-"overriding currently unsupported use of floating point exceptions "
-"on this target">, InGroup;
 
 def remark_fe_backend_optimization_remark : Remark<"%0">, BackendInfo,
 InGroup;

diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index ff07608c81e4..37e0b77e79ed 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -107,7 +107,6 @@ def DoublePromotion : DiagGroup<"double-promotion">;
 def EnumTooLarge : DiagGroup<"enum-too-large">;
 def UnsupportedNan : DiagGroup<"unsupported-nan">;
 def UnsupportedAbs : DiagGroup<"unsupported-abs">;
-def UnsupportedFPOpt : DiagGroup<"unsupported-floating-point-opt">;
 def UnsupportedCB : DiagGroup<"unsupported-cb">;
 def UnsupportedGPOpt : DiagGroup<"unsupported-gpopt">;
 def UnsupportedTargetOpt : DiagGroup<"unsupported-target-opt">;

diff  --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index 2ee3b1659630..140f55ff66b1 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -192,7 +192,6 @@ class TargetInfo : public virtual TransferrableTargetInfo,
   bool HasFloat128;
   bool HasFloat16;
   bool HasBFloat16;
-  bool HasStrictFP;
 
   unsigned char MaxAtomicPromoteWidth, MaxAtomicInlineWidth;
   unsigned short SimdDefaultAlign;
@@ -578,9 +577,6 @@ class TargetInfo : public virtual TransferrableTargetInfo,
   /// Determine whether the _BFloat16 type is supported on this target.
   virtual bool hasBFloat16Type() const { return HasBFloat16; }
 
-  /// Determine whether constrained floating point is supported on this target.
-  virtual bool hasStrictFP() const { return HasStrictFP; }
-
   /// Return the alignment that is suitable for storing any
   /// object with a fundamental alignment requirement.
   unsigned getSuitableAlign() const { return SuitableAlign; }

diff  --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp
index eccdc21d724a..7f360b715da9 100644
--- a/clang/lib/Basic/TargetInfo.cpp
+++ b/clang/lib/Basic/TargetInfo.cpp
@@ -37,7 +37,6 @@ TargetInfo::TargetInfo(const llvm::Triple ) : TargetOpts(), 
Triple(T) {
   HasFloat128 = false;
   HasFloat16 = false;
   HasBFloat16 = false;
-  HasStrictFP = false;
   PointerWidth = PointerAlign = 32;
   BoolWidth = BoolAlign = 8;
   IntWidth = IntAlign = 32;

diff  --git a/clang/lib/Basic/Targets/SystemZ.h 
b/clang/lib/Basic/Targets/SystemZ.h
index d7869e3754a8..134b0313b86a 100644
--- a/clang/lib/Basic/Targets/SystemZ.h
+++ b/clang/lib/Basic/Targets/SystemZ.h
@@ -48,7 +48,6 @@ class 

[clang] 2b35511 - [FPEnv][Clang][Driver] Failing tests are now expected failures only on PowerPC

2020-07-06 Thread Kevin P. Neal via cfe-commits

Author: Kevin P. Neal
Date: 2020-07-06T14:44:06-04:00
New Revision: 2b35511350454dd22997f129ee529e3fdb129ac2

URL: 
https://github.com/llvm/llvm-project/commit/2b35511350454dd22997f129ee529e3fdb129ac2
DIFF: 
https://github.com/llvm/llvm-project/commit/2b35511350454dd22997f129ee529e3fdb129ac2.diff

LOG: [FPEnv][Clang][Driver] Failing tests are now expected failures only on 
PowerPC

Mark these tests as only failing on PowerPC. Avoids unexpected passes on
other bots.

Fingers crossed.

Differential Revision: https://reviews.llvm.org/D80952

Added: 


Modified: 
clang/test/CodeGen/fpconstrained-cmp-double.c
clang/test/CodeGen/fpconstrained-cmp-float.c
clang/test/CodeGen/fpconstrained.c
clang/test/CodeGen/fpconstrained.cpp

Removed: 




diff  --git a/clang/test/CodeGen/fpconstrained-cmp-double.c 
b/clang/test/CodeGen/fpconstrained-cmp-double.c
index d2744d283c84..7c4d04677842 100644
--- a/clang/test/CodeGen/fpconstrained-cmp-double.c
+++ b/clang/test/CodeGen/fpconstrained-cmp-double.c
@@ -6,7 +6,7 @@
 // RUN: %clang_cc1 -frounding-math -ffp-exception-behavior=maytrap -emit-llvm 
-o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=MAYTRAP
 
 // Disabled until constrained floating point is completed for PowerPC.
-// XFAIL: *
+// XFAIL: powerpc, powerpc64, powerpc64le
 
 _Bool QuietEqual(double f1, double f2) {
   // CHECK-LABEL: define {{.*}}i1 @QuietEqual(double %f1, double %f2)

diff  --git a/clang/test/CodeGen/fpconstrained-cmp-float.c 
b/clang/test/CodeGen/fpconstrained-cmp-float.c
index 2403e542b929..964725080a7e 100644
--- a/clang/test/CodeGen/fpconstrained-cmp-float.c
+++ b/clang/test/CodeGen/fpconstrained-cmp-float.c
@@ -6,7 +6,7 @@
 // RUN: %clang_cc1 -frounding-math -ffp-exception-behavior=maytrap -emit-llvm 
-o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=MAYTRAP
 
 // Disabled until constrained floating point is completed for PowerPC.
-// XFAIL: *
+// XFAIL: powerpc, powerpc64, powerpc64le
 
 _Bool QuietEqual(float f1, float f2) {
   // CHECK-LABEL: define {{.*}}i1 @QuietEqual(float %f1, float %f2)

diff  --git a/clang/test/CodeGen/fpconstrained.c 
b/clang/test/CodeGen/fpconstrained.c
index e268af46a2de..3ce9b6fa1a55 100644
--- a/clang/test/CodeGen/fpconstrained.c
+++ b/clang/test/CodeGen/fpconstrained.c
@@ -7,7 +7,7 @@
 // RUN: %clang_cc1 -ffast-math -ffp-contract=fast 
-ffp-exception-behavior=maytrap -emit-llvm -o - %s | FileCheck %s 
-check-prefix=MAYTRAP
 
 // Disabled until constrained floating point is completed for PowerPC.
-// XFAIL: *
+// XFAIL: powerpc, powerpc64, powerpc664le
 
 float f0, f1, f2;
 

diff  --git a/clang/test/CodeGen/fpconstrained.cpp 
b/clang/test/CodeGen/fpconstrained.cpp
index 8db68533d37c..39634dd96994 100644
--- a/clang/test/CodeGen/fpconstrained.cpp
+++ b/clang/test/CodeGen/fpconstrained.cpp
@@ -7,7 +7,7 @@
 // RUN: %clang_cc1 -x c++ -ffast-math -fexceptions -fcxx-exceptions 
-ffp-contract=fast -ffp-exception-behavior=maytrap -emit-llvm -o - %s | 
FileCheck %s -check-prefix=MAYTRAP
 
 // Disabled until constrained floating point is completed for PowerPC.
-// XFAIL: *
+// XFAIL: powerpc, powerpc64, powerpc64le
 
 float f0, f1, f2;
 



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] bfdafa3 - [FPEnv][Clang][Driver] Failing tests are now expected failures.

2020-07-06 Thread Kevin P. Neal via cfe-commits

Author: Kevin P. Neal
Date: 2020-07-06T14:20:49-04:00
New Revision: bfdafa32a0fa4b2745627fe57dd253db10ac3fcf

URL: 
https://github.com/llvm/llvm-project/commit/bfdafa32a0fa4b2745627fe57dd253db10ac3fcf
DIFF: 
https://github.com/llvm/llvm-project/commit/bfdafa32a0fa4b2745627fe57dd253db10ac3fcf.diff

LOG: [FPEnv][Clang][Driver] Failing tests are now expected failures.

These are now expected failures on PowerPC. They can be reenabled when
PowerPC is ready.

Differential Revision: https://reviews.llvm.org/D80952

Added: 


Modified: 
clang/test/CodeGen/fpconstrained-cmp-double.c
clang/test/CodeGen/fpconstrained-cmp-float.c
clang/test/CodeGen/fpconstrained.c
clang/test/CodeGen/fpconstrained.cpp

Removed: 




diff  --git a/clang/test/CodeGen/fpconstrained-cmp-double.c 
b/clang/test/CodeGen/fpconstrained-cmp-double.c
index 2819970a3fcf..d2744d283c84 100644
--- a/clang/test/CodeGen/fpconstrained-cmp-double.c
+++ b/clang/test/CodeGen/fpconstrained-cmp-double.c
@@ -5,6 +5,9 @@
 // RUN: %clang_cc1 -frounding-math -ffp-exception-behavior=strict -emit-llvm 
-o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=EXCEPT
 // RUN: %clang_cc1 -frounding-math -ffp-exception-behavior=maytrap -emit-llvm 
-o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=MAYTRAP
 
+// Disabled until constrained floating point is completed for PowerPC.
+// XFAIL: *
+
 _Bool QuietEqual(double f1, double f2) {
   // CHECK-LABEL: define {{.*}}i1 @QuietEqual(double %f1, double %f2)
 

diff  --git a/clang/test/CodeGen/fpconstrained-cmp-float.c 
b/clang/test/CodeGen/fpconstrained-cmp-float.c
index 0265fc54c02b..2403e542b929 100644
--- a/clang/test/CodeGen/fpconstrained-cmp-float.c
+++ b/clang/test/CodeGen/fpconstrained-cmp-float.c
@@ -5,6 +5,9 @@
 // RUN: %clang_cc1 -frounding-math -ffp-exception-behavior=strict -emit-llvm 
-o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=EXCEPT
 // RUN: %clang_cc1 -frounding-math -ffp-exception-behavior=maytrap -emit-llvm 
-o - %s | FileCheck %s -check-prefix=CHECK -check-prefix=MAYTRAP
 
+// Disabled until constrained floating point is completed for PowerPC.
+// XFAIL: *
+
 _Bool QuietEqual(float f1, float f2) {
   // CHECK-LABEL: define {{.*}}i1 @QuietEqual(float %f1, float %f2)
 

diff  --git a/clang/test/CodeGen/fpconstrained.c 
b/clang/test/CodeGen/fpconstrained.c
index 902d6b5baf49..e268af46a2de 100644
--- a/clang/test/CodeGen/fpconstrained.c
+++ b/clang/test/CodeGen/fpconstrained.c
@@ -5,6 +5,10 @@
 // RUN: %clang_cc1 -ffast-math -ffp-contract=fast 
-ffp-exception-behavior=ignore -emit-llvm -o - %s | FileCheck %s 
-check-prefix=FAST
 // RUN: %clang_cc1 -ffast-math -ffp-contract=fast 
-ffp-exception-behavior=strict -emit-llvm -o - %s | FileCheck %s 
-check-prefix=EXCEPT
 // RUN: %clang_cc1 -ffast-math -ffp-contract=fast 
-ffp-exception-behavior=maytrap -emit-llvm -o - %s | FileCheck %s 
-check-prefix=MAYTRAP
+
+// Disabled until constrained floating point is completed for PowerPC.
+// XFAIL: *
+
 float f0, f1, f2;
 
 void foo() {

diff  --git a/clang/test/CodeGen/fpconstrained.cpp 
b/clang/test/CodeGen/fpconstrained.cpp
index e914abcc6926..8db68533d37c 100644
--- a/clang/test/CodeGen/fpconstrained.cpp
+++ b/clang/test/CodeGen/fpconstrained.cpp
@@ -5,6 +5,10 @@
 // RUN: %clang_cc1 -x c++ -ffast-math -fexceptions -fcxx-exceptions 
-ffp-contract=fast -ffp-exception-behavior=ignore -emit-llvm -o - %s | 
FileCheck %s -check-prefix=FAST
 // RUN: %clang_cc1 -x c++ -ffast-math -fexceptions -fcxx-exceptions 
-ffp-contract=fast -ffp-exception-behavior=strict -emit-llvm -o - %s | 
FileCheck %s -check-prefix=EXCEPT
 // RUN: %clang_cc1 -x c++ -ffast-math -fexceptions -fcxx-exceptions 
-ffp-contract=fast -ffp-exception-behavior=maytrap -emit-llvm -o - %s | 
FileCheck %s -check-prefix=MAYTRAP
+
+// Disabled until constrained floating point is completed for PowerPC.
+// XFAIL: *
+
 float f0, f1, f2;
 
   template 



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 39d2ae0 - [FPEnv][Clang][Driver] Disable constrained floating point on targets lacking support.

2020-07-06 Thread Kevin P. Neal via cfe-commits

Author: Kevin P. Neal
Date: 2020-07-06T13:32:49-04:00
New Revision: 39d2ae0afb2312a15e4d15a0855b35b4e1c49fc4

URL: 
https://github.com/llvm/llvm-project/commit/39d2ae0afb2312a15e4d15a0855b35b4e1c49fc4
DIFF: 
https://github.com/llvm/llvm-project/commit/39d2ae0afb2312a15e4d15a0855b35b4e1c49fc4.diff

LOG: [FPEnv][Clang][Driver] Disable constrained floating point on targets 
lacking support.

We currently have strict floating point/constrained floating point enabled
for all targets. Constrained SDAG nodes get converted to the regular ones
before reaching the target layer. In theory this should be fine.

However, the changes are exposed to users through multiple clang options
already in use in the field, and the changes are _completely_ _untested_
on almost all of our targets. Bugs have already been found, like
"https://bugs.llvm.org/show_bug.cgi?id=45274;.

This patch disables constrained floating point options in clang everywhere
except X86 and SystemZ. A warning will be printed when this happens.

Differential Revision: https://reviews.llvm.org/D80952

Added: 
clang/test/CodeGen/fp-strictfp.cpp

Modified: 
clang/include/clang/Basic/DiagnosticFrontendKinds.td
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/TargetInfo.h
clang/lib/Basic/TargetInfo.cpp
clang/lib/Basic/Targets/SystemZ.h
clang/lib/Basic/Targets/X86.h
clang/lib/Frontend/CompilerInstance.cpp
clang/test/CodeGen/aarch64-neon-misc-constrained.c
clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem-constrained.c
clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c
clang/test/CodeGen/arm-neon-directed-rounding-constrained.c
clang/test/CodeGen/arm64-vrnd-constrained.c
clang/test/CodeGen/builtins-ppc-fpconstrained.c

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticFrontendKinds.td 
b/clang/include/clang/Basic/DiagnosticFrontendKinds.td
index 83c13e0dbbe0..db334a7899c4 100644
--- a/clang/include/clang/Basic/DiagnosticFrontendKinds.td
+++ b/clang/include/clang/Basic/DiagnosticFrontendKinds.td
@@ -37,6 +37,12 @@ def note_fe_backend_plugin: Note<"%0">, BackendInfo;
 def warn_fe_override_module : Warning<
 "overriding the module target triple with %0">,
 InGroup>;
+def warn_fe_backend_unsupported_fp_rounding : Warning<
+"overriding currently unsupported rounding mode on this target">,
+InGroup;
+def warn_fe_backend_unsupported_fp_exceptions : Warning<
+"overriding currently unsupported use of floating point exceptions "
+"on this target">, InGroup;
 
 def remark_fe_backend_optimization_remark : Remark<"%0">, BackendInfo,
 InGroup;

diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 37e0b77e79ed..ff07608c81e4 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -107,6 +107,7 @@ def DoublePromotion : DiagGroup<"double-promotion">;
 def EnumTooLarge : DiagGroup<"enum-too-large">;
 def UnsupportedNan : DiagGroup<"unsupported-nan">;
 def UnsupportedAbs : DiagGroup<"unsupported-abs">;
+def UnsupportedFPOpt : DiagGroup<"unsupported-floating-point-opt">;
 def UnsupportedCB : DiagGroup<"unsupported-cb">;
 def UnsupportedGPOpt : DiagGroup<"unsupported-gpopt">;
 def UnsupportedTargetOpt : DiagGroup<"unsupported-target-opt">;

diff  --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index 140f55ff66b1..2ee3b1659630 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -192,6 +192,7 @@ class TargetInfo : public virtual TransferrableTargetInfo,
   bool HasFloat128;
   bool HasFloat16;
   bool HasBFloat16;
+  bool HasStrictFP;
 
   unsigned char MaxAtomicPromoteWidth, MaxAtomicInlineWidth;
   unsigned short SimdDefaultAlign;
@@ -577,6 +578,9 @@ class TargetInfo : public virtual TransferrableTargetInfo,
   /// Determine whether the _BFloat16 type is supported on this target.
   virtual bool hasBFloat16Type() const { return HasBFloat16; }
 
+  /// Determine whether constrained floating point is supported on this target.
+  virtual bool hasStrictFP() const { return HasStrictFP; }
+
   /// Return the alignment that is suitable for storing any
   /// object with a fundamental alignment requirement.
   unsigned getSuitableAlign() const { return SuitableAlign; }

diff  --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp
index 7f360b715da9..eccdc21d724a 100644
--- a/clang/lib/Basic/TargetInfo.cpp
+++ b/clang/lib/Basic/TargetInfo.cpp
@@ -37,6 +37,7 @@ TargetInfo::TargetInfo(const llvm::Triple ) : TargetOpts(), 
Triple(T) {
   HasFloat128 = false;
   HasFloat16 = false;
   HasBFloat16 = false;
+  HasStrictFP = false;
   PointerWidth = PointerAlign = 32;
   BoolWidth = BoolAlign = 8;
   IntWidth = IntAlign = 32;

diff  --git 

[clang] e91c4b2 - [NFC] Eliminate an unneeded -vv used in test development.

2020-06-26 Thread Kevin P. Neal via cfe-commits

Author: Kevin P. Neal
Date: 2020-06-26T11:09:16-04:00
New Revision: e91c4b2af2c03ef599623243e625f347e166673d

URL: 
https://github.com/llvm/llvm-project/commit/e91c4b2af2c03ef599623243e625f347e166673d
DIFF: 
https://github.com/llvm/llvm-project/commit/e91c4b2af2c03ef599623243e625f347e166673d.diff

LOG: [NFC] Eliminate an unneeded -vv used in test development.

Added: 


Modified: 
clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics-constrained.c

Removed: 




diff  --git a/clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics-constrained.c 
b/clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics-constrained.c
index 473d3ba53e96..d42fb1e02cad 100644
--- a/clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics-constrained.c
+++ b/clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics-constrained.c
@@ -12,7 +12,7 @@
 // RUN: %clang_cc1 -triple arm64-none-linux-gnu -target-feature +fullfp16 \
 // RUN: -ffp-exception-behavior=strict \
 // RUN: -fallow-half-arguments-and-returns -S -disable-O0-optnone -o - %s \
-// RUN: | FileCheck -vv --check-prefix=COMMON --check-prefix=CHECK-ASM %s
+// RUN: | FileCheck --check-prefix=COMMON --check-prefix=CHECK-ASM %s
 
 // REQUIRES: aarch64-registered-target
 



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 15edd7a - [FPEnv] PowerPC-specific builtin constrained FP enablement

2020-06-25 Thread Kevin P. Neal via cfe-commits

Author: Andrew Wock
Date: 2020-06-25T11:42:58-04:00
New Revision: 15edd7aaa7142e5db2a6cf9b81e4514967431824

URL: 
https://github.com/llvm/llvm-project/commit/15edd7aaa7142e5db2a6cf9b81e4514967431824
DIFF: 
https://github.com/llvm/llvm-project/commit/15edd7aaa7142e5db2a6cf9b81e4514967431824.diff

LOG: [FPEnv] PowerPC-specific builtin constrained FP enablement

This change enables PowerPC compiler builtins to generate constrained
floating point operations when clang is indicated to do so.

A couple of possibly unexpected backend divergences between constrained
floating point and regular behavior are highlighted under the test tag
FIXME-CHECK. This may be something for those on the PPC backend to look
at.

Patch by: Drew Wock 

Differential Revision: https://reviews.llvm.org/D82020

Added: 
clang/test/CodeGen/builtins-ppc-fpconstrained.c

Modified: 
clang/lib/CodeGen/CGBuiltin.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 89ab1a3c2cb0..c43877e117eb 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -14235,9 +14235,14 @@ Value *CodeGenFunction::EmitPPCBuiltinExpr(unsigned 
BuiltinID,
   case PPC::BI__builtin_vsx_xvsqrtdp: {
 llvm::Type *ResultType = ConvertType(E->getType());
 Value *X = EmitScalarExpr(E->getArg(0));
-ID = Intrinsic::sqrt;
-llvm::Function *F = CGM.getIntrinsic(ID, ResultType);
-return Builder.CreateCall(F, X);
+if (Builder.getIsFPConstrained()) {
+  llvm::Function *F = CGM.getIntrinsic(
+  Intrinsic::experimental_constrained_sqrt, ResultType);
+  return Builder.CreateConstrainedFPCall(F, X);
+} else {
+  llvm::Function *F = CGM.getIntrinsic(Intrinsic::sqrt, ResultType);
+  return Builder.CreateCall(F, X);
+}
   }
   // Count leading zeros
   case PPC::BI__builtin_altivec_vclzb:
@@ -14294,21 +14299,32 @@ Value *CodeGenFunction::EmitPPCBuiltinExpr(unsigned 
BuiltinID,
 Value *X = EmitScalarExpr(E->getArg(0));
 if (BuiltinID == PPC::BI__builtin_vsx_xvrdpim ||
 BuiltinID == PPC::BI__builtin_vsx_xvrspim)
-  ID = Intrinsic::floor;
+  ID = Builder.getIsFPConstrained()
+   ? Intrinsic::experimental_constrained_floor
+   : Intrinsic::floor;
 else if (BuiltinID == PPC::BI__builtin_vsx_xvrdpi ||
  BuiltinID == PPC::BI__builtin_vsx_xvrspi)
-  ID = Intrinsic::round;
+  ID = Builder.getIsFPConstrained()
+   ? Intrinsic::experimental_constrained_round
+   : Intrinsic::round;
 else if (BuiltinID == PPC::BI__builtin_vsx_xvrdpic ||
  BuiltinID == PPC::BI__builtin_vsx_xvrspic)
-  ID = Intrinsic::nearbyint;
+  ID = Builder.getIsFPConstrained()
+   ? Intrinsic::experimental_constrained_nearbyint
+   : Intrinsic::nearbyint;
 else if (BuiltinID == PPC::BI__builtin_vsx_xvrdpip ||
  BuiltinID == PPC::BI__builtin_vsx_xvrspip)
-  ID = Intrinsic::ceil;
+  ID = Builder.getIsFPConstrained()
+   ? Intrinsic::experimental_constrained_ceil
+   : Intrinsic::ceil;
 else if (BuiltinID == PPC::BI__builtin_vsx_xvrdpiz ||
  BuiltinID == PPC::BI__builtin_vsx_xvrspiz)
-  ID = Intrinsic::trunc;
+  ID = Builder.getIsFPConstrained()
+   ? Intrinsic::experimental_constrained_trunc
+   : Intrinsic::trunc;
 llvm::Function *F = CGM.getIntrinsic(ID, ResultType);
-return Builder.CreateCall(F, X);
+return Builder.getIsFPConstrained() ? Builder.CreateConstrainedFPCall(F, X)
+: Builder.CreateCall(F, X);
   }
 
   // Absolute value
@@ -14333,21 +14349,43 @@ Value *CodeGenFunction::EmitPPCBuiltinExpr(unsigned 
BuiltinID,
 Value *X = EmitScalarExpr(E->getArg(0));
 Value *Y = EmitScalarExpr(E->getArg(1));
 Value *Z = EmitScalarExpr(E->getArg(2));
-llvm::Function *F = CGM.getIntrinsic(Intrinsic::fma, ResultType);
+llvm::Function *F;
+if (Builder.getIsFPConstrained())
+  F = CGM.getIntrinsic(Intrinsic::experimental_constrained_fma, 
ResultType);
+else
+  F = CGM.getIntrinsic(Intrinsic::fma, ResultType);
 switch (BuiltinID) {
   case PPC::BI__builtin_vsx_xvmaddadp:
   case PPC::BI__builtin_vsx_xvmaddasp:
-return Builder.CreateCall(F, {X, Y, Z});
+if (Builder.getIsFPConstrained())
+  return Builder.CreateConstrainedFPCall(F, {X, Y, Z});
+else
+  return Builder.CreateCall(F, {X, Y, Z});
   case PPC::BI__builtin_vsx_xvnmaddadp:
   case PPC::BI__builtin_vsx_xvnmaddasp:
-return Builder.CreateFNeg(Builder.CreateCall(F, {X, Y, Z}), "neg");
+if (Builder.getIsFPConstrained())
+  return Builder.CreateFNeg(
+  Builder.CreateConstrainedFPCall(F, {X, Y, Z}), "neg");
+else
+  return 

[clang] 15a1780 - [PowerPC] Replace subtract-from-zero float in version with fneg in PowerPC special fma compiler builtins

2020-06-03 Thread Kevin P. Neal via cfe-commits

Author: Andrew Wock
Date: 2020-06-03T09:45:27-04:00
New Revision: 15a1780a10e3ba4573b8c1e02e24d3f0a785e199

URL: 
https://github.com/llvm/llvm-project/commit/15a1780a10e3ba4573b8c1e02e24d3f0a785e199
DIFF: 
https://github.com/llvm/llvm-project/commit/15a1780a10e3ba4573b8c1e02e24d3f0a785e199.diff

LOG: [PowerPC] Replace subtract-from-zero float in version with fneg in PowerPC 
special fma compiler builtins

This is a re-revert with a corrected test.

This patch adds a test for the PowerPC fma compiler builtins, some variations
of which negate inputs and outputs. The code to generate IR for these
builtins was untested before this patch.

Originally, the code used the outdated method of subtracting floating point
values from -0.0 as floating point negation. This patch remedies that.

Patch by: Drew Wock 
Differential Revision: https://reviews.llvm.org/D76949

Added: 
clang/test/CodeGen/builtins-ppc-fma.c

Modified: 
clang/lib/CodeGen/CGBuiltin.cpp
clang/test/CodeGen/builtins-ppc-vsx.c

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 13c24a5d2686..948d31312bd8 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -14056,7 +14056,6 @@ Value *CodeGenFunction::EmitPPCBuiltinExpr(unsigned 
BuiltinID,
 Value *X = EmitScalarExpr(E->getArg(0));
 Value *Y = EmitScalarExpr(E->getArg(1));
 Value *Z = EmitScalarExpr(E->getArg(2));
-Value *Zero = llvm::ConstantFP::getZeroValueForNegation(ResultType);
 llvm::Function *F = CGM.getIntrinsic(Intrinsic::fma, ResultType);
 switch (BuiltinID) {
   case PPC::BI__builtin_vsx_xvmaddadp:
@@ -14064,17 +14063,14 @@ Value *CodeGenFunction::EmitPPCBuiltinExpr(unsigned 
BuiltinID,
 return Builder.CreateCall(F, {X, Y, Z});
   case PPC::BI__builtin_vsx_xvnmaddadp:
   case PPC::BI__builtin_vsx_xvnmaddasp:
-return Builder.CreateFSub(Zero,
-  Builder.CreateCall(F, {X, Y, Z}), "sub");
+return Builder.CreateFNeg(Builder.CreateCall(F, {X, Y, Z}), "neg");
   case PPC::BI__builtin_vsx_xvmsubadp:
   case PPC::BI__builtin_vsx_xvmsubasp:
-return Builder.CreateCall(F,
-  {X, Y, Builder.CreateFSub(Zero, Z, "sub")});
+return Builder.CreateCall(F, {X, Y, Builder.CreateFNeg(Z, "neg")});
   case PPC::BI__builtin_vsx_xvnmsubadp:
   case PPC::BI__builtin_vsx_xvnmsubasp:
-Value *FsubRes =
-  Builder.CreateCall(F, {X, Y, Builder.CreateFSub(Zero, Z, "sub")});
-return Builder.CreateFSub(Zero, FsubRes, "sub");
+return Builder.CreateFNeg(
+Builder.CreateCall(F, {X, Y, Builder.CreateFNeg(Z, "neg")}), 
"neg");
 }
 llvm_unreachable("Unknown FMA operation");
 return nullptr; // Suppress no-return warning

diff  --git a/clang/test/CodeGen/builtins-ppc-fma.c 
b/clang/test/CodeGen/builtins-ppc-fma.c
new file mode 100644
index ..3f124e8c8299
--- /dev/null
+++ b/clang/test/CodeGen/builtins-ppc-fma.c
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -triple powerpc64le-gnu-linux \
+// RUN: -target-feature +altivec -Wall -Wno-unused -Werror -emit-llvm %s -o - 
| FileCheck  \
+// RUN: %s
+
+typedef __attribute__((vector_size(4 * sizeof(float float vec_float;
+typedef __attribute__((vector_size(2 * sizeof(double double vec_double;
+
+volatile vec_double vd;
+volatile vec_float vf;
+
+void test_fma(void) {
+  vf = __builtin_vsx_xvmaddasp(vf, vf, vf);
+  // CHECK: @llvm.fma.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x 
float> %{{.*}})
+
+  vd = __builtin_vsx_xvmaddadp(vd, vd, vd);
+  // CHECK: @llvm.fma.v2f64(<2 x double> %{{.*}}, <2 x double> %{{.*}}, <2 x 
double> %{{.*}})
+
+  vf = __builtin_vsx_xvnmaddasp(vf, vf, vf);
+  // CHECK: [[RESULT:%[^ ]+]] = call <4 x float> @llvm.fma.v4f32(<4 x float> 
%{{.*}}, <4 x float> %{{.*}}, <4 x float> %{{.*}})
+  // CHECK: fneg <4 x float> [[RESULT]]
+
+  vd = __builtin_vsx_xvnmaddadp(vd, vd, vd);
+  // CHECK: [[RESULT:%[^ ]+]] = call <2 x double> @llvm.fma.v2f64(<2 x double> 
%{{.*}}, <2 x double> %{{.*}}, <2 x double> %{{.*}})
+  // CHECK: fneg <2 x double> [[RESULT]]
+
+  vf = __builtin_vsx_xvmsubasp(vf, vf, vf);
+  // CHECK: [[RESULT:%[^ ]+]] = fneg <4 x float> %{{.*}}
+  // CHECK: @llvm.fma.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x 
float> [[RESULT]])
+
+  vd = __builtin_vsx_xvmsubadp(vd, vd, vd);
+  // CHECK: [[RESULT:%[^ ]+]] = fneg <2 x double> %{{.*}}
+  // CHECK: <2 x double> @llvm.fma.v2f64(<2 x double> %{{.*}}, <2 x double> 
%{{.*}}, <2 x double> [[RESULT]])
+
+  vf = __builtin_vsx_xvnmsubasp(vf, vf, vf);
+  // CHECK: [[RESULT:%[^ ]+]] = fneg <4 x float> %{{.*}}
+  // CHECK: [[RESULT2:%[^ ]+]] = call <4 x float> @llvm.fma.v4f32(<4 x float> 
%{{.*}}, <4 x float> %{{.*}}, <4 x float> [[RESULT]])
+  // CHECK: fneg <4 x float> [[RESULT2]]
+
+  vd = 

[clang] 9f1c35d - Revert "[PowerPC] Replace subtract-from-zero float in version with fneg in PowerPC special fma compiler builtins"

2020-04-03 Thread Kevin P. Neal via cfe-commits

Author: Kevin P. Neal
Date: 2020-04-03T15:47:19-04:00
New Revision: 9f1c35d8b14f026b7bc4b21b9eecafbbb42c42a2

URL: 
https://github.com/llvm/llvm-project/commit/9f1c35d8b14f026b7bc4b21b9eecafbbb42c42a2
DIFF: 
https://github.com/llvm/llvm-project/commit/9f1c35d8b14f026b7bc4b21b9eecafbbb42c42a2.diff

LOG: Revert "[PowerPC] Replace subtract-from-zero float in version with fneg in 
PowerPC special fma compiler builtins"

The new test case causes bot failures.

This reverts commit ba87430cadb2d5d0ee8e4b75101d7abcf6b321bf.

Added: 


Modified: 
clang/lib/CodeGen/CGBuiltin.cpp

Removed: 
clang/test/CodeGen/builtins-ppc-fma.c



diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 3545ccda5d4d..880fe0e271f5 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -13214,24 +13214,25 @@ Value *CodeGenFunction::EmitPPCBuiltinExpr(unsigned 
BuiltinID,
 Value *X = EmitScalarExpr(E->getArg(0));
 Value *Y = EmitScalarExpr(E->getArg(1));
 Value *Z = EmitScalarExpr(E->getArg(2));
+Value *Zero = llvm::ConstantFP::getZeroValueForNegation(ResultType);
 llvm::Function *F = CGM.getIntrinsic(Intrinsic::fma, ResultType);
 switch (BuiltinID) {
   case PPC::BI__builtin_vsx_xvmaddadp:
   case PPC::BI__builtin_vsx_xvmaddasp:
 return Builder.CreateCall(F, {X, Y, Z});
-
   case PPC::BI__builtin_vsx_xvnmaddadp:
   case PPC::BI__builtin_vsx_xvnmaddasp:
-return Builder.CreateFNeg(Builder.CreateCall(F, {X, Y, Z}), "neg");
-
+return Builder.CreateFSub(Zero,
+  Builder.CreateCall(F, {X, Y, Z}), "sub");
   case PPC::BI__builtin_vsx_xvmsubadp:
   case PPC::BI__builtin_vsx_xvmsubasp:
-return Builder.CreateCall(F, {X, Y, Builder.CreateFNeg(Z, "neg")});
-
+return Builder.CreateCall(F,
+  {X, Y, Builder.CreateFSub(Zero, Z, "sub")});
   case PPC::BI__builtin_vsx_xvnmsubadp:
   case PPC::BI__builtin_vsx_xvnmsubasp:
-return Builder.CreateFNeg(
-Builder.CreateCall(F, {X, Y, Builder.CreateFNeg(Z, "neg")}), 
"neg");
+Value *FsubRes =
+  Builder.CreateCall(F, {X, Y, Builder.CreateFSub(Zero, Z, "sub")});
+return Builder.CreateFSub(Zero, FsubRes, "sub");
 }
 llvm_unreachable("Unknown FMA operation");
 return nullptr; // Suppress no-return warning

diff  --git a/clang/test/CodeGen/builtins-ppc-fma.c 
b/clang/test/CodeGen/builtins-ppc-fma.c
deleted file mode 100644
index e91b45b0daa7..
--- a/clang/test/CodeGen/builtins-ppc-fma.c
+++ /dev/null
@@ -1,43 +0,0 @@
-// RUN: %clang_cc1 -triple powerpc64le-gnu-linux \
-// RUN: -target-feature +altivec -Wall -Wno-unused -Werror -emit-llvm %s -o - 
| FileCheck  \
-// RUN: %s
-
-typedef __attribute__((vector_size(4 * sizeof(float float vec_float;
-typedef __attribute__((vector_size(2 * sizeof(double double vec_double;
-
-volatile vec_double vd;
-volatile vec_float vf;
-
-void test_fma(void) {
-  vf = __builtin_vsx_xvmaddasp(vf, vf, vf);
-  // CHECK: @llvm.fma.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x 
float> %{{.*}})
-
-  vd = __builtin_vsx_xvmaddadp(vd, vd, vd);
-  // CHECK: @llvm.fma.v2f64(<2 x double> %{{.*}}, <2 x double> %{{.*}}, <2 x 
double> %{{.*}})
-
-  vf = __builtin_vsx_xvnmaddasp(vf, vf, vf);
-  // CHECK: [[RESULT:%[^ ]+]] = call <4 x float> @llvm.fma.v4f32(<4 x float> 
%{{.*}}, <4 x float> %{{.*}}, <4 x float> %{{.*}})
-  // CHECK: fneg <4 x float> [[RESULT]]
-
-  vd = __builtin_vsx_xvnmaddadp(vd, vd, vd);
-  // CHECK: [[RESULT:%[^ ]+]] = call <2 x double> @llvm.fma.v2f64(<2 x double> 
%{{.*}}, <2 x double> %{{.*}}, <2 x double> %{{.*}})
-  // CHECK: fneg <2 x double> [[RESULT]]
-
-  vf = __builtin_vsx_xvmsubasp(vf, vf, vf);
-  // CHECK: [[RESULT:%[^ ]+]] = fneg <4 x float> %{{.*}}
-  // CHECK: @llvm.fma.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x 
float> [[RESULT]])
-
-  vd = __builtin_vsx_xvmsubadp(vd, vd, vd);
-  // CHECK: fneg <2 x double> [[RESULT]]
-  // CHECK: [[RESULT:%[^ ]+]] = call <2 x double> @llvm.fma.v2f64(<2 x double> 
%{{.*}}, <2 x double> %{{.*}}, <2 x double> %{{.*}})
-
-  vf = __builtin_vsx_xvnmsubasp(vf, vf, vf);
-  // CHECK: [[RESULT:%[^ ]+]] = fneg <4 x float> %{{.*}}
-  // CHECK: [[RESULT2:%[^ ]+]] = call <4 x float> @llvm.fma.v2f64(<4 x float> 
%{{.*}}, <4 x float> %{{.*}}, <4 x float> [[RESULT]])
-  // CHECK: fneg <4 x float> [[RESULT2]]
-
-  vd = __builtin_vsx_xvnmsubadp(vd, vd, vd);
-  // CHECK: [[RESULT:%[^ ]+]] = fneg <2 x double> %{{.*}}
-  // CHECK: [[RESULT2:%[^ ]+]] = call <2 x double> @llvm.fma.v2f64(<2 x 
double> %{{.*}}, <2 x double> %{{.*}}, <2 x double> [[RESULT]])
-  // CHECK: fneg <2 x double> [[RESULT2]]
-}



___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[clang] d7a0516 - Fix typo in test.

2020-04-03 Thread Kevin P. Neal via cfe-commits

Author: Kevin P. Neal
Date: 2020-04-03T15:23:49-04:00
New Revision: d7a0516ddcfe373bb780d6fc19d76fe74ecc0061

URL: 
https://github.com/llvm/llvm-project/commit/d7a0516ddcfe373bb780d6fc19d76fe74ecc0061
DIFF: 
https://github.com/llvm/llvm-project/commit/d7a0516ddcfe373bb780d6fc19d76fe74ecc0061.diff

LOG: Fix typo in test.

Differential Revision: https://reviews.llvm.org/D76949

Added: 


Modified: 
clang/test/CodeGen/builtins-ppc-fma.c

Removed: 




diff  --git a/clang/test/CodeGen/builtins-ppc-fma.c 
b/clang/test/CodeGen/builtins-ppc-fma.c
index 3a628f7613b5..e91b45b0daa7 100644
--- a/clang/test/CodeGen/builtins-ppc-fma.c
+++ b/clang/test/CodeGen/builtins-ppc-fma.c
@@ -24,7 +24,7 @@ void test_fma(void) {
   // CHECK: fneg <2 x double> [[RESULT]]
 
   vf = __builtin_vsx_xvmsubasp(vf, vf, vf);
-  // CHECK: [[RESULT:%[^ ]+]] fneg <4 x float> %{{.*}}
+  // CHECK: [[RESULT:%[^ ]+]] = fneg <4 x float> %{{.*}}
   // CHECK: @llvm.fma.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x 
float> [[RESULT]])
 
   vd = __builtin_vsx_xvmsubadp(vd, vd, vd);



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] ba87430 - [PowerPC] Replace subtract-from-zero float in version with fneg in PowerPC special fma compiler builtins

2020-04-03 Thread Kevin P. Neal via cfe-commits

Author: Andrew Wock
Date: 2020-04-03T14:59:33-04:00
New Revision: ba87430cadb2d5d0ee8e4b75101d7abcf6b321bf

URL: 
https://github.com/llvm/llvm-project/commit/ba87430cadb2d5d0ee8e4b75101d7abcf6b321bf
DIFF: 
https://github.com/llvm/llvm-project/commit/ba87430cadb2d5d0ee8e4b75101d7abcf6b321bf.diff

LOG: [PowerPC] Replace subtract-from-zero float in version with fneg in PowerPC 
special fma compiler builtins

This patch adds a test for the PowerPC fma compiler builtins, some variations
of which negate inputs and outputs. The code to generate IR for these
builtins was untested before this patch.

Originally, the code used the outdated method of subtracting floating point
values from -0.0 as floating point negation. This patch remedies that.

Patch by: Drew Wock 
Differential Revision: https://reviews.llvm.org/D76949

Added: 
clang/test/CodeGen/builtins-ppc-fma.c

Modified: 
clang/lib/CodeGen/CGBuiltin.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 880fe0e271f5..3545ccda5d4d 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -13214,25 +13214,24 @@ Value *CodeGenFunction::EmitPPCBuiltinExpr(unsigned 
BuiltinID,
 Value *X = EmitScalarExpr(E->getArg(0));
 Value *Y = EmitScalarExpr(E->getArg(1));
 Value *Z = EmitScalarExpr(E->getArg(2));
-Value *Zero = llvm::ConstantFP::getZeroValueForNegation(ResultType);
 llvm::Function *F = CGM.getIntrinsic(Intrinsic::fma, ResultType);
 switch (BuiltinID) {
   case PPC::BI__builtin_vsx_xvmaddadp:
   case PPC::BI__builtin_vsx_xvmaddasp:
 return Builder.CreateCall(F, {X, Y, Z});
+
   case PPC::BI__builtin_vsx_xvnmaddadp:
   case PPC::BI__builtin_vsx_xvnmaddasp:
-return Builder.CreateFSub(Zero,
-  Builder.CreateCall(F, {X, Y, Z}), "sub");
+return Builder.CreateFNeg(Builder.CreateCall(F, {X, Y, Z}), "neg");
+
   case PPC::BI__builtin_vsx_xvmsubadp:
   case PPC::BI__builtin_vsx_xvmsubasp:
-return Builder.CreateCall(F,
-  {X, Y, Builder.CreateFSub(Zero, Z, "sub")});
+return Builder.CreateCall(F, {X, Y, Builder.CreateFNeg(Z, "neg")});
+
   case PPC::BI__builtin_vsx_xvnmsubadp:
   case PPC::BI__builtin_vsx_xvnmsubasp:
-Value *FsubRes =
-  Builder.CreateCall(F, {X, Y, Builder.CreateFSub(Zero, Z, "sub")});
-return Builder.CreateFSub(Zero, FsubRes, "sub");
+return Builder.CreateFNeg(
+Builder.CreateCall(F, {X, Y, Builder.CreateFNeg(Z, "neg")}), 
"neg");
 }
 llvm_unreachable("Unknown FMA operation");
 return nullptr; // Suppress no-return warning

diff  --git a/clang/test/CodeGen/builtins-ppc-fma.c 
b/clang/test/CodeGen/builtins-ppc-fma.c
new file mode 100644
index ..3a628f7613b5
--- /dev/null
+++ b/clang/test/CodeGen/builtins-ppc-fma.c
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -triple powerpc64le-gnu-linux \
+// RUN: -target-feature +altivec -Wall -Wno-unused -Werror -emit-llvm %s -o - 
| FileCheck  \
+// RUN: %s
+
+typedef __attribute__((vector_size(4 * sizeof(float float vec_float;
+typedef __attribute__((vector_size(2 * sizeof(double double vec_double;
+
+volatile vec_double vd;
+volatile vec_float vf;
+
+void test_fma(void) {
+  vf = __builtin_vsx_xvmaddasp(vf, vf, vf);
+  // CHECK: @llvm.fma.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x 
float> %{{.*}})
+
+  vd = __builtin_vsx_xvmaddadp(vd, vd, vd);
+  // CHECK: @llvm.fma.v2f64(<2 x double> %{{.*}}, <2 x double> %{{.*}}, <2 x 
double> %{{.*}})
+
+  vf = __builtin_vsx_xvnmaddasp(vf, vf, vf);
+  // CHECK: [[RESULT:%[^ ]+]] = call <4 x float> @llvm.fma.v4f32(<4 x float> 
%{{.*}}, <4 x float> %{{.*}}, <4 x float> %{{.*}})
+  // CHECK: fneg <4 x float> [[RESULT]]
+
+  vd = __builtin_vsx_xvnmaddadp(vd, vd, vd);
+  // CHECK: [[RESULT:%[^ ]+]] = call <2 x double> @llvm.fma.v2f64(<2 x double> 
%{{.*}}, <2 x double> %{{.*}}, <2 x double> %{{.*}})
+  // CHECK: fneg <2 x double> [[RESULT]]
+
+  vf = __builtin_vsx_xvmsubasp(vf, vf, vf);
+  // CHECK: [[RESULT:%[^ ]+]] fneg <4 x float> %{{.*}}
+  // CHECK: @llvm.fma.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x 
float> [[RESULT]])
+
+  vd = __builtin_vsx_xvmsubadp(vd, vd, vd);
+  // CHECK: fneg <2 x double> [[RESULT]]
+  // CHECK: [[RESULT:%[^ ]+]] = call <2 x double> @llvm.fma.v2f64(<2 x double> 
%{{.*}}, <2 x double> %{{.*}}, <2 x double> %{{.*}})
+
+  vf = __builtin_vsx_xvnmsubasp(vf, vf, vf);
+  // CHECK: [[RESULT:%[^ ]+]] = fneg <4 x float> %{{.*}}
+  // CHECK: [[RESULT2:%[^ ]+]] = call <4 x float> @llvm.fma.v2f64(<4 x float> 
%{{.*}}, <4 x float> %{{.*}}, <4 x float> [[RESULT]])
+  // CHECK: fneg <4 x float> [[RESULT2]]
+
+  vd = __builtin_vsx_xvnmsubadp(vd, vd, vd);
+  // CHECK: [[RESULT:%[^ ]+]] = fneg <2 x double> %{{.*}}
+  // CHECK: [[RESULT2:%[^ ]+]] = call <2 

[clang] ad0e03f - Revert "[FPEnv][X86] Platform-specific builtin constrained FP enablement"

2020-02-06 Thread Kevin P. Neal via cfe-commits

Author: Kevin P. Neal
Date: 2020-02-06T19:17:14-05:00
New Revision: ad0e03fd4c8066843f4138e44661ee0287ceb631

URL: 
https://github.com/llvm/llvm-project/commit/ad0e03fd4c8066843f4138e44661ee0287ceb631
DIFF: 
https://github.com/llvm/llvm-project/commit/ad0e03fd4c8066843f4138e44661ee0287ceb631.diff

LOG: Revert "[FPEnv][X86] Platform-specific builtin constrained FP enablement"

This reverts commit 208470dd5d0a46bc3c24b66489b687eda4954262.

Tests fail:
error: unable to create target: 'No available targets are compatible with 
triple "x86_64-apple-darwin"'

This happens on clang-hexagon-elf, clang-cmake-armv7-quick, and
clang-cmake-armv7-quick bots.

If anyone has any suggestions on why then I'm all ears.

Differential Revision: https://reviews.llvm.org/D73570

Revert "[FPEnv][X86] Speculative fix for failures introduced by eda495426."

This reverts commit 80e17e5fcc09dc5baa940022e6988fcb08c5d92d.

The speculative fix didn't solve the test failures on Hexagon, ARMv6, and
MSVC AArch64.

Added: 


Modified: 
clang/lib/CodeGen/CGBuiltin.cpp

Removed: 
clang/test/CodeGen/avx512f-builtins-constrained.c
clang/test/CodeGen/fma-builtins-constrained.c
clang/test/CodeGen/sse-builtins-constrained.c



diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index ca41413ae278..44947b4b1d64 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -10094,14 +10094,8 @@ static Value *EmitX86FMAExpr(CodeGenFunction , 
ArrayRef Ops,
 Res = CGF.Builder.CreateCall(Intr, {A, B, C, Ops.back() });
   } else {
 llvm::Type *Ty = A->getType();
-Function *FMA;
-if (CGF.Builder.getIsFPConstrained()) {
-  FMA = CGF.CGM.getIntrinsic(Intrinsic::experimental_constrained_fma, Ty);
-  Res = CGF.Builder.CreateConstrainedFPCall(FMA, {A, B, C});
-} else {
-  FMA = CGF.CGM.getIntrinsic(Intrinsic::fma, Ty);
-  Res = CGF.Builder.CreateCall(FMA, {A, B, C});
-}
+Function *FMA = CGF.CGM.getIntrinsic(Intrinsic::fma, Ty);
+Res = CGF.Builder.CreateCall(FMA, {A, B, C} );
 
 if (IsAddSub) {
   // Negate even elts in C using a mask.
@@ -10111,11 +10105,7 @@ static Value *EmitX86FMAExpr(CodeGenFunction , 
ArrayRef Ops,
 Indices[i] = i + (i % 2) * NumElts;
 
   Value *NegC = CGF.Builder.CreateFNeg(C);
-  Value *FMSub;
-  if (CGF.Builder.getIsFPConstrained())
-FMSub = CGF.Builder.CreateConstrainedFPCall(FMA, {A, B, NegC} );
-  else
-FMSub = CGF.Builder.CreateCall(FMA, {A, B, NegC} );
+  Value *FMSub = CGF.Builder.CreateCall(FMA, {A, B, NegC} );
   Res = CGF.Builder.CreateShuffleVector(FMSub, Res, Indices);
 }
   }
@@ -10174,10 +10164,6 @@ EmitScalarFMAExpr(CodeGenFunction , 
MutableArrayRef Ops,
 Intrinsic::x86_avx512_vfmadd_f64;
 Res = CGF.Builder.CreateCall(CGF.CGM.getIntrinsic(IID),
  {Ops[0], Ops[1], Ops[2], Ops[4]});
-  } else if (CGF.Builder.getIsFPConstrained()) {
-Function *FMA = CGF.CGM.getIntrinsic(
-Intrinsic::experimental_constrained_fma, Ops[0]->getType());
-Res = CGF.Builder.CreateConstrainedFPCall(FMA, Ops.slice(0, 3));
   } else {
 Function *FMA = CGF.CGM.getIntrinsic(Intrinsic::fma, Ops[0]->getType());
 Res = CGF.Builder.CreateCall(FMA, Ops.slice(0, 3));
@@ -11906,15 +11892,8 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned 
BuiltinID,
   case X86::BI__builtin_ia32_sqrtss:
   case X86::BI__builtin_ia32_sqrtsd: {
 Value *A = Builder.CreateExtractElement(Ops[0], (uint64_t)0);
-Function *F;
-if (Builder.getIsFPConstrained()) {
-  F = CGM.getIntrinsic(Intrinsic::experimental_constrained_sqrt,
-   A->getType());
-  A = Builder.CreateConstrainedFPCall(F, {A});
-} else {
-  F = CGM.getIntrinsic(Intrinsic::sqrt, A->getType());
-  A = Builder.CreateCall(F, {A});
-}
+Function *F = CGM.getIntrinsic(Intrinsic::sqrt, A->getType());
+A = Builder.CreateCall(F, {A});
 return Builder.CreateInsertElement(Ops[0], A, (uint64_t)0);
   }
   case X86::BI__builtin_ia32_sqrtsd_round_mask:
@@ -11929,15 +11908,8 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned 
BuiltinID,
   return Builder.CreateCall(CGM.getIntrinsic(IID), Ops);
 }
 Value *A = Builder.CreateExtractElement(Ops[1], (uint64_t)0);
-Function *F;
-if (Builder.getIsFPConstrained()) {
-  F = CGM.getIntrinsic(Intrinsic::experimental_constrained_sqrt,
-   A->getType());
-  A = Builder.CreateConstrainedFPCall(F, A);
-} else {
-  F = CGM.getIntrinsic(Intrinsic::sqrt, A->getType());
-  A = Builder.CreateCall(F, A);
-}
+Function *F = CGM.getIntrinsic(Intrinsic::sqrt, A->getType());
+A = Builder.CreateCall(F, A);
 Value *Src = Builder.CreateExtractElement(Ops[2], (uint64_t)0);
 A = EmitX86ScalarSelect(*this, 

[clang] 80e17e5 - [FPEnv][X86] Speculative fix for failures introduced by eda495426.

2020-02-06 Thread Kevin P. Neal via cfe-commits

Author: Kevin P. Neal
Date: 2020-02-06T15:28:36-05:00
New Revision: 80e17e5fcc09dc5baa940022e6988fcb08c5d92d

URL: 
https://github.com/llvm/llvm-project/commit/80e17e5fcc09dc5baa940022e6988fcb08c5d92d
DIFF: 
https://github.com/llvm/llvm-project/commit/80e17e5fcc09dc5baa940022e6988fcb08c5d92d.diff

LOG: [FPEnv][X86] Speculative fix for failures introduced by eda495426.

Differential Revision: https://reviews.llvm.org/D73570

Added: 


Modified: 
clang/test/CodeGen/avx512f-builtins-constrained.c
clang/test/CodeGen/fma-builtins-constrained.c
clang/test/CodeGen/sse-builtins-constrained.c

Removed: 




diff  --git a/clang/test/CodeGen/avx512f-builtins-constrained.c 
b/clang/test/CodeGen/avx512f-builtins-constrained.c
index 1a8df1a85c7c..75fad73d60f6 100644
--- a/clang/test/CodeGen/avx512f-builtins-constrained.c
+++ b/clang/test/CodeGen/avx512f-builtins-constrained.c
@@ -1,9 +1,9 @@
-// RUN: %clang_cc1 -fexperimental-new-pass-manager 
-flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin 
-target-feature +avx512f -emit-llvm -o - -Wall -Werror | FileCheck 
--check-prefix=COMMON --check-prefix=COMMONIR --check-prefix=UNCONSTRAINED %s
+// RUN: %clang_cc1 -fexperimental-new-pass-manager 
-flax-vector-conversions=none -ffreestanding %s 
-triple=x86_64-unknown-linux-gnu -target-feature +avx512f -emit-llvm -o - -Wall 
-Werror | FileCheck --check-prefix=COMMON --check-prefix=COMMONIR 
--check-prefix=UNCONSTRAINED %s
 // RUN: %clang_cc1 -fexperimental-new-pass-manager 
-flax-vector-conversions=none -fms-extensions -fms-compatibility -ffreestanding 
%s -triple=x86_64-windows-msvc -target-feature +avx512f -emit-llvm -o - -Wall 
-Werror | FileCheck --check-prefix=COMMON --check-prefix=COMMONIR 
--check-prefix=UNCONSTRAINED %s
-// RUN: %clang_cc1 -fexperimental-new-pass-manager 
-flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin 
-target-feature +avx512f -ffp-exception-behavior=strict -emit-llvm -o - -Wall 
-Werror | FileCheck --check-prefix=COMMON --check-prefix=COMMONIR 
--check-prefix=CONSTRAINED %s
-// RUN: %clang_cc1 -fexperimental-new-pass-manager 
-flax-vector-conversions=none -fms-compatibility -ffreestanding %s 
-triple=x86_64-apple-darwin -target-feature +avx512f 
-ffp-exception-behavior=strict -emit-llvm -o - -Wall -Werror | FileCheck 
--check-prefix=COMMON --check-prefix=COMMONIR --check-prefix=CONSTRAINED %s
-// RUN: %clang_cc1 -fexperimental-new-pass-manager 
-flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin 
-target-feature +avx512f -S -o - -Wall -Werror | FileCheck 
--check-prefix=COMMON --check-prefix=CHECK-ASM %s
-// RUN: %clang_cc1 -fexperimental-new-pass-manager 
-flax-vector-conversions=none -ffreestanding %s -triple=x86_64-apple-darwin 
-target-feature +avx512f -ffp-exception-behavior=strict -S -o - -Wall -Werror | 
FileCheck --check-prefix=COMMON --check-prefix=CHECK-ASM %s
+// RUN: %clang_cc1 -fexperimental-new-pass-manager 
-flax-vector-conversions=none -ffreestanding %s 
-triple=x86_64-unknown-linux-gnu -target-feature +avx512f 
-ffp-exception-behavior=strict -emit-llvm -o - -Wall -Werror | FileCheck 
--check-prefix=COMMON --check-prefix=COMMONIR --check-prefix=CONSTRAINED %s
+// RUN: %clang_cc1 -fexperimental-new-pass-manager 
-flax-vector-conversions=none -fms-compatibility -ffreestanding %s 
-triple=x86_64-unknown-linux-gnu -target-feature +avx512f 
-ffp-exception-behavior=strict -emit-llvm -o - -Wall -Werror | FileCheck 
--check-prefix=COMMON --check-prefix=COMMONIR --check-prefix=CONSTRAINED %s
+// RUN: %clang_cc1 -fexperimental-new-pass-manager 
-flax-vector-conversions=none -ffreestanding %s 
-triple=x86_64-unknown-linux-gnu -target-feature +avx512f -S -o - -Wall -Werror 
| FileCheck --check-prefix=COMMON --check-prefix=CHECK-ASM %s
+// RUN: %clang_cc1 -fexperimental-new-pass-manager 
-flax-vector-conversions=none -ffreestanding %s 
-triple=x86_64-unknown-linux-gnu -target-feature +avx512f 
-ffp-exception-behavior=strict -S -o - -Wall -Werror | FileCheck 
--check-prefix=COMMON --check-prefix=CHECK-ASM %s
 
 #include 
 

diff  --git a/clang/test/CodeGen/fma-builtins-constrained.c 
b/clang/test/CodeGen/fma-builtins-constrained.c
index 91e2d25c4d46..8a3ce821a568 100644
--- a/clang/test/CodeGen/fma-builtins-constrained.c
+++ b/clang/test/CodeGen/fma-builtins-constrained.c
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin 
-target-feature +fma -O -emit-llvm -o - | FileCheck --check-prefix=COMMON 
--check-prefix=COMMONIR --check-prefix=UNCONSTRAINED %s
-// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin 
-target-feature +fma -ffp-exception-behavior=strict -O -emit-llvm -o - | 
FileCheck --check-prefix=COMMON --check-prefix=COMMONIR 
--check-prefix=CONSTRAINED %s
-// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin 
-target-feature +fma -O -S -o - | FileCheck 

[clang] 208470d - [FPEnv][X86] Platform-specific builtin constrained FP enablement

2020-02-06 Thread Kevin P. Neal via cfe-commits

Author: Kevin P. Neal
Date: 2020-02-06T14:20:44-05:00
New Revision: 208470dd5d0a46bc3c24b66489b687eda4954262

URL: 
https://github.com/llvm/llvm-project/commit/208470dd5d0a46bc3c24b66489b687eda4954262
DIFF: 
https://github.com/llvm/llvm-project/commit/208470dd5d0a46bc3c24b66489b687eda4954262.diff

LOG: [FPEnv][X86] Platform-specific builtin constrained FP enablement

When constrained floating point is enabled the X86-specific builtins don't
use constrained intrinsics in some cases. Fix that.

Differential Revision: https://reviews.llvm.org/D73570

Added: 
clang/test/CodeGen/avx512f-builtins-constrained.c
clang/test/CodeGen/fma-builtins-constrained.c
clang/test/CodeGen/sse-builtins-constrained.c

Modified: 
clang/lib/CodeGen/CGBuiltin.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 44947b4b1d64..ca41413ae278 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -10094,8 +10094,14 @@ static Value *EmitX86FMAExpr(CodeGenFunction , 
ArrayRef Ops,
 Res = CGF.Builder.CreateCall(Intr, {A, B, C, Ops.back() });
   } else {
 llvm::Type *Ty = A->getType();
-Function *FMA = CGF.CGM.getIntrinsic(Intrinsic::fma, Ty);
-Res = CGF.Builder.CreateCall(FMA, {A, B, C} );
+Function *FMA;
+if (CGF.Builder.getIsFPConstrained()) {
+  FMA = CGF.CGM.getIntrinsic(Intrinsic::experimental_constrained_fma, Ty);
+  Res = CGF.Builder.CreateConstrainedFPCall(FMA, {A, B, C});
+} else {
+  FMA = CGF.CGM.getIntrinsic(Intrinsic::fma, Ty);
+  Res = CGF.Builder.CreateCall(FMA, {A, B, C});
+}
 
 if (IsAddSub) {
   // Negate even elts in C using a mask.
@@ -10105,7 +10111,11 @@ static Value *EmitX86FMAExpr(CodeGenFunction , 
ArrayRef Ops,
 Indices[i] = i + (i % 2) * NumElts;
 
   Value *NegC = CGF.Builder.CreateFNeg(C);
-  Value *FMSub = CGF.Builder.CreateCall(FMA, {A, B, NegC} );
+  Value *FMSub;
+  if (CGF.Builder.getIsFPConstrained())
+FMSub = CGF.Builder.CreateConstrainedFPCall(FMA, {A, B, NegC} );
+  else
+FMSub = CGF.Builder.CreateCall(FMA, {A, B, NegC} );
   Res = CGF.Builder.CreateShuffleVector(FMSub, Res, Indices);
 }
   }
@@ -10164,6 +10174,10 @@ EmitScalarFMAExpr(CodeGenFunction , 
MutableArrayRef Ops,
 Intrinsic::x86_avx512_vfmadd_f64;
 Res = CGF.Builder.CreateCall(CGF.CGM.getIntrinsic(IID),
  {Ops[0], Ops[1], Ops[2], Ops[4]});
+  } else if (CGF.Builder.getIsFPConstrained()) {
+Function *FMA = CGF.CGM.getIntrinsic(
+Intrinsic::experimental_constrained_fma, Ops[0]->getType());
+Res = CGF.Builder.CreateConstrainedFPCall(FMA, Ops.slice(0, 3));
   } else {
 Function *FMA = CGF.CGM.getIntrinsic(Intrinsic::fma, Ops[0]->getType());
 Res = CGF.Builder.CreateCall(FMA, Ops.slice(0, 3));
@@ -11892,8 +11906,15 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned 
BuiltinID,
   case X86::BI__builtin_ia32_sqrtss:
   case X86::BI__builtin_ia32_sqrtsd: {
 Value *A = Builder.CreateExtractElement(Ops[0], (uint64_t)0);
-Function *F = CGM.getIntrinsic(Intrinsic::sqrt, A->getType());
-A = Builder.CreateCall(F, {A});
+Function *F;
+if (Builder.getIsFPConstrained()) {
+  F = CGM.getIntrinsic(Intrinsic::experimental_constrained_sqrt,
+   A->getType());
+  A = Builder.CreateConstrainedFPCall(F, {A});
+} else {
+  F = CGM.getIntrinsic(Intrinsic::sqrt, A->getType());
+  A = Builder.CreateCall(F, {A});
+}
 return Builder.CreateInsertElement(Ops[0], A, (uint64_t)0);
   }
   case X86::BI__builtin_ia32_sqrtsd_round_mask:
@@ -11908,8 +11929,15 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned 
BuiltinID,
   return Builder.CreateCall(CGM.getIntrinsic(IID), Ops);
 }
 Value *A = Builder.CreateExtractElement(Ops[1], (uint64_t)0);
-Function *F = CGM.getIntrinsic(Intrinsic::sqrt, A->getType());
-A = Builder.CreateCall(F, A);
+Function *F;
+if (Builder.getIsFPConstrained()) {
+  F = CGM.getIntrinsic(Intrinsic::experimental_constrained_sqrt,
+   A->getType());
+  A = Builder.CreateConstrainedFPCall(F, A);
+} else {
+  F = CGM.getIntrinsic(Intrinsic::sqrt, A->getType());
+  A = Builder.CreateCall(F, A);
+}
 Value *Src = Builder.CreateExtractElement(Ops[2], (uint64_t)0);
 A = EmitX86ScalarSelect(*this, Ops[3], A, Src);
 return Builder.CreateInsertElement(Ops[0], A, (uint64_t)0);
@@ -11931,8 +11959,14 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned 
BuiltinID,
 return Builder.CreateCall(CGM.getIntrinsic(IID), Ops);
   }
 }
-Function *F = CGM.getIntrinsic(Intrinsic::sqrt, Ops[0]->getType());
-return Builder.CreateCall(F, Ops[0]);
+if (Builder.getIsFPConstrained()) {
+  Function *F = 

[clang] 2e667d0 - [FPEnv][SystemZ] Platform-specific builtin constrained FP enablement

2020-01-21 Thread Kevin P. Neal via cfe-commits

Author: Kevin P. Neal
Date: 2020-01-21T12:44:39-05:00
New Revision: 2e667d07c773f684ea893b9ce5d9b73e9f23b438

URL: 
https://github.com/llvm/llvm-project/commit/2e667d07c773f684ea893b9ce5d9b73e9f23b438
DIFF: 
https://github.com/llvm/llvm-project/commit/2e667d07c773f684ea893b9ce5d9b73e9f23b438.diff

LOG: [FPEnv][SystemZ] Platform-specific builtin constrained FP enablement

When constrained floating point is enabled the SystemZ-specific builtins
don't use constrained intrinsics in some cases. Fix that.

Differential Revision: https://reviews.llvm.org/D72722

Added: 
clang/test/CodeGen/builtins-systemz-vector-constrained.c
clang/test/CodeGen/builtins-systemz-vector2-constrained.c
clang/test/CodeGen/builtins-systemz-zvector-constrained.c
clang/test/CodeGen/builtins-systemz-zvector2-constrained.c
clang/test/CodeGen/builtins-systemz-zvector3-constrained.c

Modified: 
clang/lib/CodeGen/CGBuiltin.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 8d00d3d64f5c..29eebbb403ea 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -13310,8 +13310,13 @@ Value 
*CodeGenFunction::EmitSystemZBuiltinExpr(unsigned BuiltinID,
   case SystemZ::BI__builtin_s390_vfsqdb: {
 llvm::Type *ResultType = ConvertType(E->getType());
 Value *X = EmitScalarExpr(E->getArg(0));
-Function *F = CGM.getIntrinsic(Intrinsic::sqrt, ResultType);
-return Builder.CreateCall(F, X);
+if (Builder.getIsFPConstrained()) {
+  Function *F = CGM.getIntrinsic(Intrinsic::experimental_constrained_sqrt, 
ResultType);
+  return Builder.CreateConstrainedFPCall(F, { X });
+} else {
+  Function *F = CGM.getIntrinsic(Intrinsic::sqrt, ResultType);
+  return Builder.CreateCall(F, X);
+}
   }
   case SystemZ::BI__builtin_s390_vfmasb:
   case SystemZ::BI__builtin_s390_vfmadb: {
@@ -13319,8 +13324,13 @@ Value 
*CodeGenFunction::EmitSystemZBuiltinExpr(unsigned BuiltinID,
 Value *X = EmitScalarExpr(E->getArg(0));
 Value *Y = EmitScalarExpr(E->getArg(1));
 Value *Z = EmitScalarExpr(E->getArg(2));
-Function *F = CGM.getIntrinsic(Intrinsic::fma, ResultType);
-return Builder.CreateCall(F, {X, Y, Z});
+if (Builder.getIsFPConstrained()) {
+  Function *F = CGM.getIntrinsic(Intrinsic::experimental_constrained_fma, 
ResultType);
+  return Builder.CreateConstrainedFPCall(F, {X, Y, Z});
+} else {
+  Function *F = CGM.getIntrinsic(Intrinsic::fma, ResultType);
+  return Builder.CreateCall(F, {X, Y, Z});
+}
   }
   case SystemZ::BI__builtin_s390_vfmssb:
   case SystemZ::BI__builtin_s390_vfmsdb: {
@@ -13328,8 +13338,13 @@ Value 
*CodeGenFunction::EmitSystemZBuiltinExpr(unsigned BuiltinID,
 Value *X = EmitScalarExpr(E->getArg(0));
 Value *Y = EmitScalarExpr(E->getArg(1));
 Value *Z = EmitScalarExpr(E->getArg(2));
-Function *F = CGM.getIntrinsic(Intrinsic::fma, ResultType);
-return Builder.CreateCall(F, {X, Y, Builder.CreateFNeg(Z, "neg")});
+if (Builder.getIsFPConstrained()) {
+  Function *F = CGM.getIntrinsic(Intrinsic::experimental_constrained_fma, 
ResultType);
+  return Builder.CreateConstrainedFPCall(F, {X, Y, Builder.CreateFNeg(Z, 
"neg")});
+} else {
+  Function *F = CGM.getIntrinsic(Intrinsic::fma, ResultType);
+  return Builder.CreateCall(F, {X, Y, Builder.CreateFNeg(Z, "neg")});
+}
   }
   case SystemZ::BI__builtin_s390_vfnmasb:
   case SystemZ::BI__builtin_s390_vfnmadb: {
@@ -13337,8 +13352,13 @@ Value 
*CodeGenFunction::EmitSystemZBuiltinExpr(unsigned BuiltinID,
 Value *X = EmitScalarExpr(E->getArg(0));
 Value *Y = EmitScalarExpr(E->getArg(1));
 Value *Z = EmitScalarExpr(E->getArg(2));
-Function *F = CGM.getIntrinsic(Intrinsic::fma, ResultType);
-return Builder.CreateFNeg(Builder.CreateCall(F, {X, Y, Z}), "neg");
+if (Builder.getIsFPConstrained()) {
+  Function *F = CGM.getIntrinsic(Intrinsic::experimental_constrained_fma, 
ResultType);
+  return Builder.CreateFNeg(Builder.CreateConstrainedFPCall(F, {X, Y,  
Z}), "neg");
+} else {
+  Function *F = CGM.getIntrinsic(Intrinsic::fma, ResultType);
+  return Builder.CreateFNeg(Builder.CreateCall(F, {X, Y, Z}), "neg");
+}
   }
   case SystemZ::BI__builtin_s390_vfnmssb:
   case SystemZ::BI__builtin_s390_vfnmsdb: {
@@ -13346,9 +13366,15 @@ Value 
*CodeGenFunction::EmitSystemZBuiltinExpr(unsigned BuiltinID,
 Value *X = EmitScalarExpr(E->getArg(0));
 Value *Y = EmitScalarExpr(E->getArg(1));
 Value *Z = EmitScalarExpr(E->getArg(2));
-Function *F = CGM.getIntrinsic(Intrinsic::fma, ResultType);
-Value *NegZ = Builder.CreateFNeg(Z, "neg");
-return Builder.CreateFNeg(Builder.CreateCall(F, {X, Y, NegZ}));
+if (Builder.getIsFPConstrained()) {
+  Function *F = CGM.getIntrinsic(Intrinsic::experimental_constrained_fma, 
ResultType);
+  

[clang] 89d6c28 - [SystemZ] Use FNeg in s390x clang builtins

2020-01-02 Thread Kevin P. Neal via cfe-commits

Author: Kevin P. Neal
Date: 2020-01-02T12:14:43-05:00
New Revision: 89d6c288ba5adb20d92142e9425f7ab79b8f159e

URL: 
https://github.com/llvm/llvm-project/commit/89d6c288ba5adb20d92142e9425f7ab79b8f159e
DIFF: 
https://github.com/llvm/llvm-project/commit/89d6c288ba5adb20d92142e9425f7ab79b8f159e.diff

LOG: [SystemZ] Use FNeg in s390x clang builtins

The s390x builtins are still using FSub instead of FNeg. Correct that.

Added: 


Modified: 
clang/lib/CodeGen/CGBuiltin.cpp
clang/test/CodeGen/builtins-systemz-vector.c
clang/test/CodeGen/builtins-systemz-vector2.c
clang/test/CodeGen/builtins-systemz-zvector.c
clang/test/CodeGen/builtins-systemz-zvector2.c

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index be02004bf54b..12517709573a 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -13292,9 +13292,8 @@ Value *CodeGenFunction::EmitSystemZBuiltinExpr(unsigned 
BuiltinID,
 Value *X = EmitScalarExpr(E->getArg(0));
 Value *Y = EmitScalarExpr(E->getArg(1));
 Value *Z = EmitScalarExpr(E->getArg(2));
-Value *Zero = llvm::ConstantFP::getZeroValueForNegation(ResultType);
 Function *F = CGM.getIntrinsic(Intrinsic::fma, ResultType);
-return Builder.CreateCall(F, {X, Y, Builder.CreateFSub(Zero, Z, "sub")});
+return Builder.CreateCall(F, {X, Y, Builder.CreateFNeg(Z, "neg")});
   }
   case SystemZ::BI__builtin_s390_vfnmasb:
   case SystemZ::BI__builtin_s390_vfnmadb: {
@@ -13302,9 +13301,8 @@ Value *CodeGenFunction::EmitSystemZBuiltinExpr(unsigned 
BuiltinID,
 Value *X = EmitScalarExpr(E->getArg(0));
 Value *Y = EmitScalarExpr(E->getArg(1));
 Value *Z = EmitScalarExpr(E->getArg(2));
-Value *Zero = llvm::ConstantFP::getZeroValueForNegation(ResultType);
 Function *F = CGM.getIntrinsic(Intrinsic::fma, ResultType);
-return Builder.CreateFSub(Zero, Builder.CreateCall(F, {X, Y, Z}), "sub");
+return Builder.CreateFNeg(Builder.CreateCall(F, {X, Y, Z}), "neg");
   }
   case SystemZ::BI__builtin_s390_vfnmssb:
   case SystemZ::BI__builtin_s390_vfnmsdb: {
@@ -13312,10 +13310,9 @@ Value 
*CodeGenFunction::EmitSystemZBuiltinExpr(unsigned BuiltinID,
 Value *X = EmitScalarExpr(E->getArg(0));
 Value *Y = EmitScalarExpr(E->getArg(1));
 Value *Z = EmitScalarExpr(E->getArg(2));
-Value *Zero = llvm::ConstantFP::getZeroValueForNegation(ResultType);
 Function *F = CGM.getIntrinsic(Intrinsic::fma, ResultType);
-Value *NegZ = Builder.CreateFSub(Zero, Z, "sub");
-return Builder.CreateFSub(Zero, Builder.CreateCall(F, {X, Y, NegZ}));
+Value *NegZ = Builder.CreateFNeg(Z, "neg");
+return Builder.CreateFNeg(Builder.CreateCall(F, {X, Y, NegZ}));
   }
   case SystemZ::BI__builtin_s390_vflpsb:
   case SystemZ::BI__builtin_s390_vflpdb: {
@@ -13328,9 +13325,8 @@ Value *CodeGenFunction::EmitSystemZBuiltinExpr(unsigned 
BuiltinID,
   case SystemZ::BI__builtin_s390_vflndb: {
 llvm::Type *ResultType = ConvertType(E->getType());
 Value *X = EmitScalarExpr(E->getArg(0));
-Value *Zero = llvm::ConstantFP::getZeroValueForNegation(ResultType);
 Function *F = CGM.getIntrinsic(Intrinsic::fabs, ResultType);
-return Builder.CreateFSub(Zero, Builder.CreateCall(F, X), "sub");
+return Builder.CreateFNeg(Builder.CreateCall(F, X), "neg");
   }
   case SystemZ::BI__builtin_s390_vfisb:
   case SystemZ::BI__builtin_s390_vfidb: {

diff  --git a/clang/test/CodeGen/builtins-systemz-vector.c 
b/clang/test/CodeGen/builtins-systemz-vector.c
index 85cdc30aa54c..116bd8fa492a 100644
--- a/clang/test/CodeGen/builtins-systemz-vector.c
+++ b/clang/test/CodeGen/builtins-systemz-vector.c
@@ -584,14 +584,14 @@ void test_float(void) {
   vd = __builtin_s390_vfmadb(vd, vd, vd);
   // CHECK: call <2 x double> @llvm.fma.v2f64(<2 x double> %{{.*}}, <2 x 
double> %{{.*}}, <2 x double> %{{.*}})
   vd = __builtin_s390_vfmsdb(vd, vd, vd);
-  // CHECK: [[NEG:%[^ ]+]] = fsub <2 x double> , %{{.*}}
+  // CHECK: [[NEG:%[^ ]+]] = fneg <2 x double> %{{.*}}
   // CHECK: call <2 x double> @llvm.fma.v2f64(<2 x double> %{{.*}}, <2 x 
double> %{{.*}}, <2 x double> [[NEG]])
 
   vd = __builtin_s390_vflpdb(vd);
   // CHECK: call <2 x double> @llvm.fabs.v2f64(<2 x double> %{{.*}})
   vd = __builtin_s390_vflndb(vd);
   // CHECK: [[ABS:%[^ ]+]] = call <2 x double> @llvm.fabs.v2f64(<2 x double> 
%{{.*}})
-  // CHECK: fsub <2 x double> , 
[[ABS]]
+  // CHECK: fneg <2 x double> [[ABS]]
 
   vd = __builtin_s390_vfidb(vd, 0, 0);
   // CHECK: call <2 x double> @llvm.rint.v2f64(<2 x double> %{{.*}})

diff  --git a/clang/test/CodeGen/builtins-systemz-vector2.c 
b/clang/test/CodeGen/builtins-systemz-vector2.c
index a17cdf0a5ae6..0a9906002f2b 100644
--- a/clang/test/CodeGen/builtins-systemz-vector2.c
+++ b/clang/test/CodeGen/builtins-systemz-vector2.c
@@ -64,11 +64,11 @@ void test_float(void) {
 
   vd = 

[clang] 0293b5d - [NFC] Remove some dead code from CGBuiltin.cpp.

2019-12-24 Thread Kevin P. Neal via cfe-commits

Author: Kevin P. Neal
Date: 2019-12-24T09:38:34-05:00
New Revision: 0293b5d67123786daf80528af9ef356b7bd9d2f6

URL: 
https://github.com/llvm/llvm-project/commit/0293b5d67123786daf80528af9ef356b7bd9d2f6
DIFF: 
https://github.com/llvm/llvm-project/commit/0293b5d67123786daf80528af9ef356b7bd9d2f6.diff

LOG: [NFC] Remove some dead code from CGBuiltin.cpp.

Added: 


Modified: 
clang/lib/CodeGen/CGBuiltin.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 3b35fc23a1b9..17b8cab71294 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -2297,20 +2297,6 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
   case Builtin::BI__builtin_powil:
 return RValue::get(emitBinaryMaybeConstrainedFPBuiltin(
 *this, E, Intrinsic::powi, Intrinsic::experimental_constrained_powi));
-#if 0
-Value *Base = EmitScalarExpr(E->getArg(0));
-Value *Exponent = EmitScalarExpr(E->getArg(1));
-llvm::Type *ArgType = Base->getType();
-// XXX Maybe
-if (Builder.getIsFPConstrained()) {
-  Function *F = CGM.getIntrinsic(Intrinsic::experimental_constrained_powi, 
ArgType);
-  return RValue::get(Builder.CreateConstrainedFPCall(F, {Base, Exponent}));
-}
-else {
-  Function *F = CGM.getIntrinsic(Intrinsic::powi, ArgType);
-  return RValue::get(Builder.CreateCall(F, {Base, Exponent}));
-}
-#endif
 
   case Builtin::BI__builtin_isgreater:
   case Builtin::BI__builtin_isgreaterequal:



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 6515c52 - [FPEnv] clang support for constrained FP builtins

2019-12-10 Thread Kevin P. Neal via cfe-commits

Author: Kevin P. Neal
Date: 2019-12-10T13:09:12-05:00
New Revision: 6515c524b0ae50dd5bb052558afa8c81d3a75780

URL: 
https://github.com/llvm/llvm-project/commit/6515c524b0ae50dd5bb052558afa8c81d3a75780
DIFF: 
https://github.com/llvm/llvm-project/commit/6515c524b0ae50dd5bb052558afa8c81d3a75780.diff

LOG: [FPEnv] clang support for constrained FP builtins

Change the IRBuilder and clang so that constrained FP intrinsics will be
emitted for builtins when appropriate. Only non-target-specific builtins
are affected in this patch.

Differential Revision: https://reviews.llvm.org/D70256

Added: 
clang/test/CodeGen/constrained-math-builtins.c

Modified: 
clang/lib/CodeGen/CGBuiltin.cpp
llvm/include/llvm/IR/IRBuilder.h

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 2b2738252a05..68c956a98637 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -348,6 +348,58 @@ static Value *EmitISOVolatileStore(CodeGenFunction , 
const CallExpr *E) {
   return Store;
 }
 
+// Emit a simple mangled intrinsic that has 1 argument and a return type
+// matching the argument type. Depending on mode, this may be a constrained
+// floating-point intrinsic.
+static Value *emitUnaryMaybeConstrainedFPBuiltin(CodeGenFunction ,
+const CallExpr *E, unsigned IntrinsicID,
+unsigned ConstrainedIntrinsicID) {
+  llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0));
+
+  if (CGF.Builder.getIsFPConstrained()) {
+Value *F = CGF.CGM.getIntrinsic(ConstrainedIntrinsicID, Src0->getType());
+return CGF.Builder.CreateConstrainedFPCall(F, { Src0 });
+  } else {
+Value *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType());
+return CGF.Builder.CreateCall(F, Src0);
+  }
+}
+  
+// Emit an intrinsic that has 2 operands of the same type as its result.
+// Depending on mode, this may be a constrained floating-point intrinsic.
+static Value *emitBinaryMaybeConstrainedFPBuiltin(CodeGenFunction ,
+const CallExpr *E, unsigned IntrinsicID,
+unsigned ConstrainedIntrinsicID) {
+  llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0));
+  llvm::Value *Src1 = CGF.EmitScalarExpr(E->getArg(1));
+
+  if (CGF.Builder.getIsFPConstrained()) {
+Value *F = CGF.CGM.getIntrinsic(ConstrainedIntrinsicID, Src0->getType());
+return CGF.Builder.CreateConstrainedFPCall(F, { Src0, Src1 });
+  } else {
+Value *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType());
+return CGF.Builder.CreateCall(F, { Src0, Src1 });
+  }
+}
+
+// Emit an intrinsic that has 3 operands of the same type as its result.
+// Depending on mode, this may be a constrained floating-point intrinsic.
+static Value *emitTernaryMaybeConstrainedFPBuiltin(CodeGenFunction ,
+ const CallExpr *E, unsigned IntrinsicID,
+ unsigned ConstrainedIntrinsicID) {
+  llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0));
+  llvm::Value *Src1 = CGF.EmitScalarExpr(E->getArg(1));
+  llvm::Value *Src2 = CGF.EmitScalarExpr(E->getArg(2));
+
+  if (CGF.Builder.getIsFPConstrained()) {
+Value *F = CGF.CGM.getIntrinsic(ConstrainedIntrinsicID, Src0->getType());
+return CGF.Builder.CreateConstrainedFPCall(F, { Src0, Src1, Src2 });
+  } else {
+Value *F = CGF.CGM.getIntrinsic(IntrinsicID, Src0->getType());
+return CGF.Builder.CreateCall(F, { Src0, Src1, Src2 });
+  }
+}
+
 // Emit a simple mangled intrinsic that has 1 argument and a return type
 // matching the argument type.
 static Value *emitUnaryBuiltin(CodeGenFunction ,
@@ -394,15 +446,22 @@ static Value *emitFPIntBuiltin(CodeGenFunction ,
 }
 
 // Emit an intrinsic that has overloaded integer result and fp operand.
-static Value *emitFPToIntRoundBuiltin(CodeGenFunction ,
-  const CallExpr *E,
-  unsigned IntrinsicID) {
-   llvm::Type *ResultType = CGF.ConvertType(E->getType());
-   llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0));
+static Value *
+emitMaybeConstrainedFPToIntRoundBuiltin(CodeGenFunction , const CallExpr 
*E,
+unsigned IntrinsicID,
+unsigned ConstrainedIntrinsicID) {
+  llvm::Type *ResultType = CGF.ConvertType(E->getType());
+  llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0));
 
-   Function *F = CGF.CGM.getIntrinsic(IntrinsicID,
-  {ResultType, Src0->getType()});
-   return CGF.Builder.CreateCall(F, Src0);
+  if (CGF.Builder.getIsFPConstrained()) {
+Function *F = CGF.CGM.getIntrinsic(ConstrainedIntrinsicID,
+   {ResultType, Src0->getType()});
+return CGF.Builder.CreateConstrainedFPCall(F, {Src0});
+  } else {
+Function *F =

r339693 - We have in place support for parsing #pragma FENV_ACCESS, but that

2018-08-14 Thread Kevin P. Neal via cfe-commits
Author: kpn
Date: Tue Aug 14 10:06:56 2018
New Revision: 339693

URL: http://llvm.org/viewvc/llvm-project?rev=339693=rev
Log:

We have in place support for parsing #pragma FENV_ACCESS, but that 
information is then discarded with a warning to the user that we don't 
support it.

This patch gets us one step closer by getting the info down into the 
AST in most cases.

Reviewed by:rsmith
Differential Revision:  https://reviews.llvm.org/D49865

Modified:
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/include/clang/Basic/LangOptions.h
cfe/trunk/include/clang/Basic/TokenKinds.def
cfe/trunk/include/clang/Parse/Parser.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Parse/ParsePragma.cpp
cfe/trunk/lib/Parse/ParseStmt.cpp
cfe/trunk/lib/Parse/Parser.cpp
cfe/trunk/lib/Sema/SemaAttr.cpp

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=339693=339692=339693=diff
==
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Tue Aug 14 10:06:56 2018
@@ -3269,7 +3269,7 @@ private:
 
   // This is only meaningful for operations on floating point types and 0
   // otherwise.
-  unsigned FPFeatures : 2;
+  unsigned FPFeatures : 3;
   SourceLocation OpLoc;
 
   enum { LHS, RHS, END_EXPR };
@@ -3448,6 +3448,12 @@ public:
 return FPOptions(FPFeatures).allowFPContractWithinStatement();
   }
 
+  // Get the FENV_ACCESS status of this operator. Only meaningful for
+  // operations on floating point types.
+  bool isFEnvAccessOn() const {
+return FPOptions(FPFeatures).allowFEnvAccess();
+  }
+
 protected:
   BinaryOperator(Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy,
  ExprValueKind VK, ExprObjectKind OK,

Modified: cfe/trunk/include/clang/Basic/LangOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.h?rev=339693=339692=339693=diff
==
--- cfe/trunk/include/clang/Basic/LangOptions.h (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.h Tue Aug 14 10:06:56 2018
@@ -137,6 +137,14 @@ public:
 FPC_Fast
   };
 
+  // TODO: merge FEnvAccessModeKind and FPContractModeKind
+  enum FEnvAccessModeKind {
+FEA_Off,
+
+FEA_On
+  };
+
+
 public:
   /// Set of enabled sanitizers.
   SanitizerSet Sanitize;
@@ -262,14 +270,19 @@ public:
 /// Floating point control options
 class FPOptions {
 public:
-  FPOptions() : fp_contract(LangOptions::FPC_Off) {}
+  FPOptions() : fp_contract(LangOptions::FPC_Off), 
+fenv_access(LangOptions::FEA_Off) {}
 
   // Used for serializing.
   explicit FPOptions(unsigned I)
-  : fp_contract(static_cast(I)) {}
+  : fp_contract(static_cast(I & 3)),
+fenv_access(static_cast((I >> 2) & 1))
+{}
 
   explicit FPOptions(const LangOptions )
-  : fp_contract(LangOpts.getDefaultFPContractMode()) {}
+  : fp_contract(LangOpts.getDefaultFPContractMode()),
+fenv_access(LangOptions::FEA_Off) {}
+  // FIXME: Use getDefaultFEnvAccessMode() when available.
 
   bool allowFPContractWithinStatement() const {
 return fp_contract == LangOptions::FPC_On;
@@ -289,12 +302,24 @@ public:
 
   void setDisallowFPContract() { fp_contract = LangOptions::FPC_Off; }
 
+  bool allowFEnvAccess() const {
+return fenv_access == LangOptions::FEA_On;
+  }
+
+  void setAllowFEnvAccess() {
+fenv_access = LangOptions::FEA_On;
+  }
+
+  void setDisallowFEnvAccess() { fenv_access = LangOptions::FEA_Off; }
+
   /// Used to serialize this.
-  unsigned getInt() const { return fp_contract; }
+  unsigned getInt() const { return fp_contract | (fenv_access << 2); }
 
 private:
-  /// Adjust BinaryOperator::FPFeatures to match the bit-field size of this.
+  /// Adjust BinaryOperator::FPFeatures to match the total bit-field size 
+  /// of these two.
   unsigned fp_contract : 2;
+  unsigned fenv_access : 1;
 };
 
 /// Describes the kind of translation unit being processed.

Modified: cfe/trunk/include/clang/Basic/TokenKinds.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TokenKinds.def?rev=339693=339692=339693=diff
==
--- cfe/trunk/include/clang/Basic/TokenKinds.def (original)
+++ cfe/trunk/include/clang/Basic/TokenKinds.def Tue Aug 14 10:06:56 2018
@@ -780,6 +780,11 @@ ANNOTATION(pragma_redefine_extname)
 // handles them.
 ANNOTATION(pragma_fp_contract)
 
+// Annotation for #pragma STDC FENV_ACCESS
+// The lexer produces these so that they only take effect when the parser
+// handles them.
+ANNOTATION(pragma_fenv_access)
+
 // Annotation for #pragma pointers_to_members...
 // The lexer produces these so that they only take effect when the parser
 // handles them.

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: 

r339691 - Revert test commit

2018-08-14 Thread Kevin P. Neal via cfe-commits
Author: kpn
Date: Tue Aug 14 09:57:10 2018
New Revision: 339691

URL: http://llvm.org/viewvc/llvm-project?rev=339691=rev
Log:
Revert test commit


Modified:
cfe/trunk/lib/Parse/ParseAST.cpp

Modified: cfe/trunk/lib/Parse/ParseAST.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseAST.cpp?rev=339691=339690=339691=diff
==
--- cfe/trunk/lib/Parse/ParseAST.cpp (original)
+++ cfe/trunk/lib/Parse/ParseAST.cpp Tue Aug 14 09:57:10 2018
@@ -26,7 +26,6 @@
 #include 
 #include 
 
-
 using namespace clang;
 
 namespace {


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r339690 - Test commit

2018-08-14 Thread Kevin P. Neal via cfe-commits
Author: kpn
Date: Tue Aug 14 09:56:25 2018
New Revision: 339690

URL: http://llvm.org/viewvc/llvm-project?rev=339690=rev
Log:
Test commit


Modified:
cfe/trunk/lib/Parse/ParseAST.cpp

Modified: cfe/trunk/lib/Parse/ParseAST.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseAST.cpp?rev=339690=339689=339690=diff
==
--- cfe/trunk/lib/Parse/ParseAST.cpp (original)
+++ cfe/trunk/lib/Parse/ParseAST.cpp Tue Aug 14 09:56:25 2018
@@ -26,6 +26,7 @@
 #include 
 #include 
 
+
 using namespace clang;
 
 namespace {


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits