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

2023-07-12 Thread Kevin P. Neal via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG91f886a40d3f: [FPEnv][TableGen] Add strictfp attribute to 
constrained intrinsics by default. (authored by kpn).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D154991/new/

https://reviews.llvm.org/D154991

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

Index: llvm/utils/TableGen/IntrinsicEmitter.cpp
===
--- llvm/utils/TableGen/IntrinsicEmitter.cpp
+++ llvm/utils/TableGen/IntrinsicEmitter.cpp
@@ -388,6 +388,9 @@
   if (L->hasSideEffects != R->hasSideEffects)
 return R->hasSideEffects;
 
+  if (L->isStrictFP != R->isStrictFP)
+return R->isStrictFP;
+
   // Try to order by readonly/readnone attribute.
   uint32_t LK = L->ME.toIntValue();
   uint32_t RK = R->ME.toIntValue();
@@ -522,6 +525,8 @@
   OS << "  Attribute::get(C, Attribute::Convergent),\n";
 if (Intrinsic.isSpeculatable)
   OS << "  Attribute::get(C, Attribute::Speculatable),\n";
+if (Intrinsic.isStrictFP)
+  OS << "  Attribute::get(C, Attribute::StrictFP),\n";
 
 MemoryEffects ME = Intrinsic.ME;
 // TODO: IntrHasSideEffects should affect not only readnone intrinsics.
@@ -594,7 +599,8 @@
 Intrinsic.isNoReturn || Intrinsic.isNoCallback || Intrinsic.isNoSync ||
 Intrinsic.isNoFree || Intrinsic.isWillReturn || Intrinsic.isCold ||
 Intrinsic.isNoDuplicate || Intrinsic.isNoMerge ||
-Intrinsic.isConvergent || Intrinsic.isSpeculatable) {
+Intrinsic.isConvergent || Intrinsic.isSpeculatable ||
+Intrinsic.isStrictFP) {
   unsigned ID = UniqFnAttributes.find(&Intrinsic)->second;
   OS << "  AS[" << numAttrs++ << "] = {AttributeList::FunctionIndex, "
  << "getIntrinsicFnAttributeSet(C, " << ID << ")};\n";
Index: llvm/utils/TableGen/CodeGenIntrinsics.h
===
--- llvm/utils/TableGen/CodeGenIntrinsics.h
+++ llvm/utils/TableGen/CodeGenIntrinsics.h
@@ -103,6 +103,9 @@
   // True if the intrinsic is marked as speculatable.
   bool isSpeculatable;
 
+  // True if the intrinsic is marked as strictfp.
+  bool isStrictFP;
+
   enum ArgAttrKind {
 NoCapture,
 NoAlias,
Index: llvm/utils/TableGen/CodeGenIntrinsics.cpp
===
--- llvm/utils/TableGen/CodeGenIntrinsics.cpp
+++ llvm/utils/TableGen/CodeGenIntrinsics.cpp
@@ -74,6 +74,7 @@
   isConvergent = false;
   isSpeculatable = false;
   hasSideEffects = false;
+  isStrictFP = false;
 
   if (DefName.size() <= 4 || DefName.substr(0, 4) != "int_")
 PrintFatalError(DefLoc,
@@ -203,6 +204,8 @@
 isSpeculatable = true;
   else if (R->getName() == "IntrHasSideEffects")
 hasSideEffects = true;
+  else if (R->getName() == "IntrStrictFP")
+isStrictFP = true;
   else if (R->isSubClassOf("NoCapture")) {
 unsigned ArgNo = R->getValueAsInt("ArgNo");
 addArgAttribute(ArgNo, NoCapture);
Index: llvm/test/Verifier/fp-intrinsics-pass.ll
===
--- llvm/test/Verifier/fp-intrinsics-pass.ll
+++ llvm/test/Verifier/fp-intrinsics-pass.ll
@@ -1,7 +1,7 @@
 ; RUN: opt -passes=verify -S < %s 2>&1 | FileCheck %s
 
-declare double @llvm.experimental.constrained.fadd.f64(double, double, metadata, metadata) #0
-declare double @llvm.experimental.constrained.sqrt.f64(double, metadata, metadata) #0
+declare double @llvm.experimental.constrained.fadd.f64(double, double, metadata, metadata)
+declare double @llvm.experimental.constrained.sqrt.f64(double, metadata, metadata)
 
 ; Test that the verifier accepts legal code, and that the correct attributes are
 ; attached to the FP intrinsic. The attributes are checked at the bottom.
@@ -9,35 +9,34 @@
 ; CHECK: declare double @llvm.experimental.constrained.sqrt.f64(double, metadata, metadata) #[[ATTR]]
 ; Note: FP exceptions aren't usually caught through normal unwind mechanisms,
 ;   but we may want to revisit this for asynchronous exception handling.
-define double @f1(double %a, double %b) #0 {
+define double @f1(double %a, double %b) strictfp {
 ; CHECK-LABEL: define double @f1
-; CHECK-SAME: (double [[A:%.*]], double [[B:%.*]]) #[[ATTR1:[0-9]+]] {
+; CHECK-SAME: (double [[A:%.*]], double [[B:%.*]]) #[[STRICTFP:[0-9]+]] {
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:[[FADD:%.*]] = call double @llvm.experimental.constrained.fadd.f64(double [[A]], double [[B]], metadata !"round.dynamic", metadata !"fpexcept.strict") #[[ATTR1]]
+; CHECK-NEXT:[[FADD:%.*]] 

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

2023-07-11 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn updated this revision to Diff 539204.
kpn added a comment.

Move test and change to round-tripping as requested.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D154991/new/

https://reviews.llvm.org/D154991

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

Index: llvm/utils/TableGen/IntrinsicEmitter.cpp
===
--- llvm/utils/TableGen/IntrinsicEmitter.cpp
+++ llvm/utils/TableGen/IntrinsicEmitter.cpp
@@ -388,6 +388,9 @@
   if (L->hasSideEffects != R->hasSideEffects)
 return R->hasSideEffects;
 
+  if (L->isStrictFP != R->isStrictFP)
+return R->isStrictFP;
+
   // Try to order by readonly/readnone attribute.
   uint32_t LK = L->ME.toIntValue();
   uint32_t RK = R->ME.toIntValue();
@@ -522,6 +525,8 @@
   OS << "  Attribute::get(C, Attribute::Convergent),\n";
 if (Intrinsic.isSpeculatable)
   OS << "  Attribute::get(C, Attribute::Speculatable),\n";
+if (Intrinsic.isStrictFP)
+  OS << "  Attribute::get(C, Attribute::StrictFP),\n";
 
 MemoryEffects ME = Intrinsic.ME;
 // TODO: IntrHasSideEffects should affect not only readnone intrinsics.
@@ -594,7 +599,8 @@
 Intrinsic.isNoReturn || Intrinsic.isNoCallback || Intrinsic.isNoSync ||
 Intrinsic.isNoFree || Intrinsic.isWillReturn || Intrinsic.isCold ||
 Intrinsic.isNoDuplicate || Intrinsic.isNoMerge ||
-Intrinsic.isConvergent || Intrinsic.isSpeculatable) {
+Intrinsic.isConvergent || Intrinsic.isSpeculatable ||
+Intrinsic.isStrictFP) {
   unsigned ID = UniqFnAttributes.find(&Intrinsic)->second;
   OS << "  AS[" << numAttrs++ << "] = {AttributeList::FunctionIndex, "
  << "getIntrinsicFnAttributeSet(C, " << ID << ")};\n";
Index: llvm/utils/TableGen/CodeGenIntrinsics.h
===
--- llvm/utils/TableGen/CodeGenIntrinsics.h
+++ llvm/utils/TableGen/CodeGenIntrinsics.h
@@ -103,6 +103,9 @@
   // True if the intrinsic is marked as speculatable.
   bool isSpeculatable;
 
+  // True if the intrinsic is marked as strictfp.
+  bool isStrictFP;
+
   enum ArgAttrKind {
 NoCapture,
 NoAlias,
Index: llvm/utils/TableGen/CodeGenIntrinsics.cpp
===
--- llvm/utils/TableGen/CodeGenIntrinsics.cpp
+++ llvm/utils/TableGen/CodeGenIntrinsics.cpp
@@ -74,6 +74,7 @@
   isConvergent = false;
   isSpeculatable = false;
   hasSideEffects = false;
+  isStrictFP = false;
 
   if (DefName.size() <= 4 || DefName.substr(0, 4) != "int_")
 PrintFatalError(DefLoc,
@@ -203,6 +204,8 @@
 isSpeculatable = true;
   else if (R->getName() == "IntrHasSideEffects")
 hasSideEffects = true;
+  else if (R->getName() == "IntrStrictFP")
+isStrictFP = true;
   else if (R->isSubClassOf("NoCapture")) {
 unsigned ArgNo = R->getValueAsInt("ArgNo");
 addArgAttribute(ArgNo, NoCapture);
Index: llvm/test/Verifier/fp-intrinsics-pass.ll
===
--- llvm/test/Verifier/fp-intrinsics-pass.ll
+++ llvm/test/Verifier/fp-intrinsics-pass.ll
@@ -1,7 +1,7 @@
 ; RUN: opt -passes=verify -S < %s 2>&1 | FileCheck %s
 
-declare double @llvm.experimental.constrained.fadd.f64(double, double, metadata, metadata) #0
-declare double @llvm.experimental.constrained.sqrt.f64(double, metadata, metadata) #0
+declare double @llvm.experimental.constrained.fadd.f64(double, double, metadata, metadata)
+declare double @llvm.experimental.constrained.sqrt.f64(double, metadata, metadata)
 
 ; Test that the verifier accepts legal code, and that the correct attributes are
 ; attached to the FP intrinsic. The attributes are checked at the bottom.
@@ -9,35 +9,34 @@
 ; CHECK: declare double @llvm.experimental.constrained.sqrt.f64(double, metadata, metadata) #[[ATTR]]
 ; Note: FP exceptions aren't usually caught through normal unwind mechanisms,
 ;   but we may want to revisit this for asynchronous exception handling.
-define double @f1(double %a, double %b) #0 {
+define double @f1(double %a, double %b) strictfp {
 ; CHECK-LABEL: define double @f1
-; CHECK-SAME: (double [[A:%.*]], double [[B:%.*]]) #[[ATTR1:[0-9]+]] {
+; CHECK-SAME: (double [[A:%.*]], double [[B:%.*]]) #[[STRICTFP:[0-9]+]] {
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:[[FADD:%.*]] = call double @llvm.experimental.constrained.fadd.f64(double [[A]], double [[B]], metadata !"round.dynamic", metadata !"fpexcept.strict") #[[ATTR1]]
+; CHECK-NEXT:[[FADD:%.*]] = call double @llvm.experimental.constrained.fadd.f64(double [[A]], double [[B]], metadata !"round.dynamic", metadata !"fpexcept.strict")
 ; CHECK-NEXT:ret double [[FADD]]
 entry:

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

2023-07-11 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn created this revision.
kpn added reviewers: pengfei, chapuni, akshaykhadse, craig.topper, arsenm.
Herald added a subscriber: jdoerfert.
Herald added a project: All.
kpn requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, wdng.
Herald added projects: clang, LLVM.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154991

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

Index: llvm/utils/TableGen/IntrinsicEmitter.cpp
===
--- llvm/utils/TableGen/IntrinsicEmitter.cpp
+++ llvm/utils/TableGen/IntrinsicEmitter.cpp
@@ -388,6 +388,9 @@
   if (L->hasSideEffects != R->hasSideEffects)
 return R->hasSideEffects;
 
+  if (L->isStrictFP != R->isStrictFP)
+return R->isStrictFP;
+
   // Try to order by readonly/readnone attribute.
   uint32_t LK = L->ME.toIntValue();
   uint32_t RK = R->ME.toIntValue();
@@ -522,6 +525,8 @@
   OS << "  Attribute::get(C, Attribute::Convergent),\n";
 if (Intrinsic.isSpeculatable)
   OS << "  Attribute::get(C, Attribute::Speculatable),\n";
+if (Intrinsic.isStrictFP)
+  OS << "  Attribute::get(C, Attribute::StrictFP),\n";
 
 MemoryEffects ME = Intrinsic.ME;
 // TODO: IntrHasSideEffects should affect not only readnone intrinsics.
@@ -594,7 +599,8 @@
 Intrinsic.isNoReturn || Intrinsic.isNoCallback || Intrinsic.isNoSync ||
 Intrinsic.isNoFree || Intrinsic.isWillReturn || Intrinsic.isCold ||
 Intrinsic.isNoDuplicate || Intrinsic.isNoMerge ||
-Intrinsic.isConvergent || Intrinsic.isSpeculatable) {
+Intrinsic.isConvergent || Intrinsic.isSpeculatable ||
+Intrinsic.isStrictFP) {
   unsigned ID = UniqFnAttributes.find(&Intrinsic)->second;
   OS << "  AS[" << numAttrs++ << "] = {AttributeList::FunctionIndex, "
  << "getIntrinsicFnAttributeSet(C, " << ID << ")};\n";
Index: llvm/utils/TableGen/CodeGenIntrinsics.h
===
--- llvm/utils/TableGen/CodeGenIntrinsics.h
+++ llvm/utils/TableGen/CodeGenIntrinsics.h
@@ -103,6 +103,9 @@
   // True if the intrinsic is marked as speculatable.
   bool isSpeculatable;
 
+  // True if the intrinsic is marked as strictfp.
+  bool isStrictFP;
+
   enum ArgAttrKind {
 NoCapture,
 NoAlias,
Index: llvm/utils/TableGen/CodeGenIntrinsics.cpp
===
--- llvm/utils/TableGen/CodeGenIntrinsics.cpp
+++ llvm/utils/TableGen/CodeGenIntrinsics.cpp
@@ -74,6 +74,7 @@
   isConvergent = false;
   isSpeculatable = false;
   hasSideEffects = false;
+  isStrictFP = false;
 
   if (DefName.size() <= 4 || DefName.substr(0, 4) != "int_")
 PrintFatalError(DefLoc,
@@ -203,6 +204,8 @@
 isSpeculatable = true;
   else if (R->getName() == "IntrHasSideEffects")
 hasSideEffects = true;
+  else if (R->getName() == "IntrStrictFP")
+isStrictFP = true;
   else if (R->isSubClassOf("NoCapture")) {
 unsigned ArgNo = R->getValueAsInt("ArgNo");
 addArgAttribute(ArgNo, NoCapture);
Index: llvm/test/Verifier/fp-intrinsics-pass.ll
===
--- llvm/test/Verifier/fp-intrinsics-pass.ll
+++ llvm/test/Verifier/fp-intrinsics-pass.ll
@@ -1,7 +1,7 @@
 ; RUN: opt -passes=verify -S < %s 2>&1 | FileCheck %s
 
-declare double @llvm.experimental.constrained.fadd.f64(double, double, metadata, metadata) #0
-declare double @llvm.experimental.constrained.sqrt.f64(double, metadata, metadata) #0
+declare double @llvm.experimental.constrained.fadd.f64(double, double, metadata, metadata)
+declare double @llvm.experimental.constrained.sqrt.f64(double, metadata, metadata)
 
 ; Test that the verifier accepts legal code, and that the correct attributes are
 ; attached to the FP intrinsic. The attributes are checked at the bottom.
@@ -9,35 +9,34 @@
 ; CHECK: declare double @llvm.experimental.constrained.sqrt.f64(double, metadata, metadata) #[[ATTR]]
 ; Note: FP exceptions aren't usually caught through normal unwind mechanisms,
 ;   but we may want to revisit this for asynchronous exception handling.
-define double @f1(double %a, double %b) #0 {
+define double @f1(double %a, double %b) strictfp {
 ; CHECK-LABEL: define double @f1
-; CHECK-SAME: (double [[A:%.*]], double [[B:%.*]])

[PATCH] D144447: [Clang] Teach buildFMulAdd to peek through fneg to find fmul.

2023-02-23 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn accepted this revision.
kpn added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D17/new/

https://reviews.llvm.org/D17

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


[PATCH] D144447: [Clang] Teach buildFMulAdd to peek through fneg to find fmul.

2023-02-21 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added inline comments.



Comment at: clang/lib/CodeGen/CGExprScalar.cpp:3738
-  assert(!(negMul && negAdd) && "Only one of negMul and negAdd should be 
set.");
-
   Value *MulOp0 = MulOp->getOperand(0);

If I'm reading this right it looks like the assert() wasn't needed before. Do 
we know why it was added in the first place?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D17/new/

https://reviews.llvm.org/D17

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


[PATCH] D142907: LangRef: Add "dynamic" option to "denormal-fp-math"

2023-02-16 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added a comment.

What's the plan for tying this to strictfp? Because I don't it should be tied 
to cases where we use the constrained intrinsics but the exceptions are ignored 
and the default rounding is in stated. Those instructions are supposed to 
behave the same as the non-constrained instructions. So keying off the presence 
of the strictfp attribute on the function definition, or the (equivalent) 
presence of constrained intrinsics, would be too simple.

I don't see an obvious connection between denormals and exception behavior, and 
the rounding mode has the same problem. It would be surprising if changing the 
rounding mode changed denormal handling or optimization even when the new 
rounding mode would have identical results. It would also be surprising if 
changing the rounding mode back to the default round-to-nearest changed how 
denormals are handled.

Would we get different denormal behavior with a clang flag vs using a #pragma 
at the top of a source file? That seems surprising as well.

In the abstract I can see lumping in denormal handing with the rest of the FP 
environment handling. But in the LLVM context I don't see how we can tie use of 
the constrained intrinsics to denormals.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142907/new/

https://reviews.llvm.org/D142907

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


[PATCH] D142907: LangRef: Add "dynamic" option to "denormal-fp-math"

2023-02-01 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added inline comments.



Comment at: llvm/test/Transforms/Inline/AMDGPU/inline-denormal-fp-math.ll:78
+; CHECK-NEXT:[[CALL:%.*]] = call i32 @func_default()
+; CHECK-NEXT:ret i32 [[CALL]]
 ;

arsenm wrote:
> kpn wrote:
> > Are we changing the behavior in a way that may cause regressions? It looks 
> > like we've changed behavior in the absence of "dynamic".
> This case is broken to begin with, calling ieee from daz code. This makes the 
> inlining more conservative / noticeable for debugging
Can I talk you into mentioning this in your commit message?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142907/new/

https://reviews.llvm.org/D142907

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


[PATCH] D142907: LangRef: Add "dynamic" option to "denormal-fp-math"

2023-02-01 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added a comment.

We use "dynamic" for the constrained intrinsics. I'd stay consistent with our 
terminology and stick with "dynamic" here.

I like the amount of testing. You may have gotten every single combination of 
cases, but I didn't go far enough to check.




Comment at: llvm/test/Transforms/Inline/AMDGPU/inline-denormal-fp-math.ll:78
+; CHECK-NEXT:[[CALL:%.*]] = call i32 @func_default()
+; CHECK-NEXT:ret i32 [[CALL]]
 ;

Are we changing the behavior in a way that may cause regressions? It looks like 
we've changed behavior in the absence of "dynamic".


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142907/new/

https://reviews.llvm.org/D142907

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


[PATCH] D141765: [FPEnv] Fix complex operations in strictfp mode

2023-01-17 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added inline comments.



Comment at: clang/test/CodeGen/complex-strictfp.c:8-9
 // Include rounding metadata in the testing.
-// FIXME: All cases of "fpexcept.maytrap" in this test are wrong.
-// FIXME: All cases of "round.tonearest" in this test are wrong.
+// All cases of "fpexcept.maytrap" in this test are wrong.
+// All cases of "round.tonearest" in this test are wrong.
 

arsenm wrote:
> So the tests are wrong but should no longer be fixed?
The tests were wrong and are now correct. He left the comment to tell the 
future that if either "fpexcept.maytrap" or "round.tonearest" reappear then it 
means a regression in clang.

How about changing "all' to "any"? And change "wrong" to "clang bugs"? As in 
'Any cases of "fpexcept.maytrap" in this test are clang bugs.'?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141765/new/

https://reviews.llvm.org/D141765

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


[PATCH] D141765: [FPEnv] Fix complex operations in strictfp mode

2023-01-17 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added a comment.

Are we testing _Complex multiply or subtraction anywhere? I have a vague memory 
of multiply not working correctly.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141765/new/

https://reviews.llvm.org/D141765

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


[PATCH] D139629: clang: Stop emitting "strictfp"

2022-12-19 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:2135
-llvm::AttrBuilder FuncAttrs(F->getContext());
-FuncAttrs.addAttribute("strictfp");
-F->addFnAttrs(FuncAttrs);

arsenm wrote:
> kpn wrote:
> > arsenm wrote:
> > > andrew.w.kaylor wrote:
> > > > arsenm wrote:
> > > > > zahiraam wrote:
> > > > > > I think it would better to fix this function instead of removing it 
> > > > > > entirely? The issue here is that there is the "strictfp" attribute 
> > > > > > and the llvm::Attribute::StrictFP. We could replace  
> > > > > > FuncAttrs.addAttribute("strictfp"); with
> > > > > >  FuncAttrs.addAttribute(llvm::Attribute::StrictFP); 
> > > > > > This function ensures that the function attribute is set when the 
> > > > > > FunctionDecl attribute is set. I am concerned that when it's 
> > > > > > removed, we will wind up with cases where the function attribute is 
> > > > > > missing! The only place where this function attribute is in 
> > > > > > CodeGenFunction::StartFunction. Is that enough? @andrew.w.kaylor 
> > > > > > Can you please weigh in on this?
> > > > > I currently don't have evidence that making this use the correct 
> > > > > attribute would fix anything. If something was depending on this 
> > > > > emission in this context, it's already broken
> > > > It may be that anything depending on this is already broken, but the 
> > > > code was written for a reason, even if it was always broken. I'm not 
> > > > sure I understand what that reason was, and unfortunately the person 
> > > > who wrote the code (@mibintc) is no longer actively contributing to 
> > > > LLVM. It was added here: https://reviews.llvm.org/D87528
> > > > 
> > > > It does seem like the llvm::Attribute::StrictFP is being added any time 
> > > > the string attribute is added, but they're coming from different 
> > > > places. The proper attribute seems to be coming from 
> > > > CodeGenFunction::StartFunction() which is effectively copying it from 
> > > > the function declaration. It's not clear to me whether there are 
> > > > circumstances where we get to setLLVMFunctionFEnvAttributes() through 
> > > > EmitGlobalFunctionDefinition() without ever having gone through 
> > > > CodeGenFunction::StartFunction(). It looks like maybe there are 
> > > > multiversioning cases that do that, but I couldn't come up with an 
> > > > example that does. @erichkeane wrote a lot of the multi-versioning 
> > > > code, so he might know more, but he's on vacation through the end of 
> > > > the month.
> > > > 
> > > > Eliminating this extra string attribute seems obviously good. In this 
> > > > particular location, though, I'd be inclined to set the enumerated 
> > > > attribute here, even though that might be redundant in most cases. On 
> > > > the other hand, if one of our front end experts can look at this code 
> > > > and say definitively that it's //always// redundant, I'd be fine with 
> > > > this code being deleted.
> > > I think code that can be deleted that doesn't manifest in test failures 
> > > should be immediately deleted. We shouldn't leave things around just in 
> > > case 
> > The Verifier changes that would detect the error and fail tests never made 
> > it into the tree. The lack of failures therefore tells us nothing in this 
> > case here.
> The verifier never would have checked the string form
Ah, true statement.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D139629/new/

https://reviews.llvm.org/D139629

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


[PATCH] D139629: clang: Stop emitting "strictfp"

2022-12-19 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:2135
-llvm::AttrBuilder FuncAttrs(F->getContext());
-FuncAttrs.addAttribute("strictfp");
-F->addFnAttrs(FuncAttrs);

arsenm wrote:
> andrew.w.kaylor wrote:
> > arsenm wrote:
> > > zahiraam wrote:
> > > > I think it would better to fix this function instead of removing it 
> > > > entirely? The issue here is that there is the "strictfp" attribute and 
> > > > the llvm::Attribute::StrictFP. We could replace  
> > > > FuncAttrs.addAttribute("strictfp"); with
> > > >  FuncAttrs.addAttribute(llvm::Attribute::StrictFP); 
> > > > This function ensures that the function attribute is set when the 
> > > > FunctionDecl attribute is set. I am concerned that when it's removed, 
> > > > we will wind up with cases where the function attribute is missing! The 
> > > > only place where this function attribute is in 
> > > > CodeGenFunction::StartFunction. Is that enough? @andrew.w.kaylor Can 
> > > > you please weigh in on this?
> > > I currently don't have evidence that making this use the correct 
> > > attribute would fix anything. If something was depending on this emission 
> > > in this context, it's already broken
> > It may be that anything depending on this is already broken, but the code 
> > was written for a reason, even if it was always broken. I'm not sure I 
> > understand what that reason was, and unfortunately the person who wrote the 
> > code (@mibintc) is no longer actively contributing to LLVM. It was added 
> > here: https://reviews.llvm.org/D87528
> > 
> > It does seem like the llvm::Attribute::StrictFP is being added any time the 
> > string attribute is added, but they're coming from different places. The 
> > proper attribute seems to be coming from CodeGenFunction::StartFunction() 
> > which is effectively copying it from the function declaration. It's not 
> > clear to me whether there are circumstances where we get to 
> > setLLVMFunctionFEnvAttributes() through EmitGlobalFunctionDefinition() 
> > without ever having gone through CodeGenFunction::StartFunction(). It looks 
> > like maybe there are multiversioning cases that do that, but I couldn't 
> > come up with an example that does. @erichkeane wrote a lot of the 
> > multi-versioning code, so he might know more, but he's on vacation through 
> > the end of the month.
> > 
> > Eliminating this extra string attribute seems obviously good. In this 
> > particular location, though, I'd be inclined to set the enumerated 
> > attribute here, even though that might be redundant in most cases. On the 
> > other hand, if one of our front end experts can look at this code and say 
> > definitively that it's //always// redundant, I'd be fine with this code 
> > being deleted.
> I think code that can be deleted that doesn't manifest in test failures 
> should be immediately deleted. We shouldn't leave things around just in case 
The Verifier changes that would detect the error and fail tests never made it 
into the tree. The lack of failures therefore tells us nothing in this case 
here.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D139629/new/

https://reviews.llvm.org/D139629

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


[PATCH] D112932: Use llvm.is_fpclass to implement FP classification functions

2022-12-13 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added inline comments.



Comment at: clang/test/CodeGen/strictfp_builtins.c:160
+// CHECK-NEXT:[[TMP1:%.*]] = call double @llvm.fabs.f64(double [[TMP0]]) 
#[[ATTR5]]
+// CHECK-NEXT:[[ISINF:%.*]] = call i1 
@llvm.experimental.constrained.fcmp.f64(double [[TMP1]], double 
0x7FF0, metadata !"oeq", metadata !"fpexcept.strict") #[[ATTR4]]
 // CHECK-NEXT:[[TMP2:%.*]] = bitcast double [[TMP0]] to i64

Is there a way to test that we're using llvm.is.fpclass() in this case?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112932/new/

https://reviews.llvm.org/D112932

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


[PATCH] D139629: clang: Stop emitting "strictfp"

2022-12-08 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added a comment.

It looks like clang does have at least one test that checks for the strictfp 
attribute on function definitions. We also have a number that test for the 
strictfp attribute on function calls. So I think our test coverage is in good 
shape.

LGTM.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D139629/new/

https://reviews.llvm.org/D139629

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


[PATCH] D126364: Fix interaction of pragma FENV_ACCESS with other pragmas

2022-06-01 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added a comment.

>> On targets that support static rounding mode (like RISCV) dynamic and 
>> constant rounding modes may be different and the behavior changes if default 
>> mode is replaced by dynamic.
>
> Whether a target supports static rounding modes on floating-point 
> instructions is completely irrelevant.  The user-visible behavior must be the 
> same either way.  If a target doesn't have specialized instructions, the code 
> generator can save/restore the rounding mode.  This should be transparent to 
> the user; the user can't read the rounding mode in between the save and 
> restore.  (We already do this sort of rounding mode manipulation on x86, to 
> implement float-to-int conversion on targets without SSE.)

The rounding mode argument to the constrained intrinsic is a hint; it tells the 
intrinsic what rounding mode has been set via the normal rounding mode changing 
mechanism. Constrained intrinsics don't change the rounding mode. I guess we 
could weaken that by adding "... except if absolutely required" to account for 
the float-to-int sans SSE case, but the principle applies.

Because of the requirement that the rounding mode be changed already, I don't 
see how instructions with static rounding modes are generally interesting. 
Perhaps a target will learn to recognize that a sequence of instructions can 
use the static rounding in the instructions and elide a change of rounding mode 
around the sequence? I don't know how common that would be in practice.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126364/new/

https://reviews.llvm.org/D126364

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


[PATCH] D118259: [AArch64] Adjust aarch64 constrained intrinsics tests and un-XFAIL

2022-04-12 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn accepted this revision.
kpn added a comment.
This revision is now accepted and ready to land.

I trust you on the instruction set changes. LGTM.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D118259/new/

https://reviews.llvm.org/D118259

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


[PATCH] D118259: [AArch64] Adjust aarch64-neon-intrinsics-constrained test and un-XFAIL

2022-03-17 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added a comment.

In D118259#3389246 , @fhahn wrote:

> In D118259#3389235 , @kpn wrote:
>
>> It's been a while, but I think the aarch64-neon-intrinsics-constrained.c 
>> test is trimmed down from the aarch64-neon-intrinsics.c test. Shouldn't the 
>> constrained and non-constrained end-to-end tests be treated the same?
>
> Are you referring to 
> https://github.com/llvm/llvm-project/blob/main/clang/test/CodeGen/aarch64-neon-intrinsics.c?
>  This one doesn't check assembly.

Ah, well, I guess that wasn't it, then. It's been a while, and I've been all 
over the place.

A clang-only test that just tests for the correct IR being emitted won't 
trigger the failures in the backend. An LLVM-only test that starts from that IR 
can show those failures, but it also runs the risk over time of getting out of 
sync with the IR emitted by clang. An end-to-end test will always be in sync, 
and it will show those failures that I ran into plus anything else that crops 
up over time. If there's another way, or if there is another approach, then it 
might be possible there's a way to get all the testing done without running 
into those issues. I just don't know what it is.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D118259/new/

https://reviews.llvm.org/D118259

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


[PATCH] D118259: [AArch64] Adjust aarch64-neon-intrinsics-constrained test and un-XFAIL

2022-03-17 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added a comment.

It's been a while, but I think the aarch64-neon-intrinsics-constrained.c test 
is trimmed down from the aarch64-neon-intrinsics.c test. Shouldn't the 
constrained and non-constrained end-to-end tests be treated the same?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D118259/new/

https://reviews.llvm.org/D118259

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


[PATCH] D115804: [CodeGen] use saturating FP casts when compiling with "no-strict-float-cast-overflow"

2021-12-21 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added a comment.

In D115804#3202479 , @sepavloff wrote:

> In D115804#3201681 , @spatel wrote:
>
>> In D115804#3201044 , @craig.topper 
>> wrote:
>>
>>> What's the plan for constrained intrinsics versions of these intrinsics? 
>>> The IRBuilder calls for CreateFPToSI and CreateFPToUI are strict FP aware, 
>>> but this new code isn't.
>>
>> Not sure. cc'ing @kpn @sepavloff @andrew.w.kaylor  
>> The saturating intrinsics implement non-standard behavior for C languages 
>> AFAIK, so we might want to warn if someone tries to use 
>> "-fno-strict-float-cast-overflow" and "-ffp-exception-behavior=strict" at 
>> the same time? Or we try to support that corner case by adding even more FP 
>> intrinsics?
>
> Conversion `float`->`int` depends on rounding mode. At least on some ML cores 
> this conversion is made with saturating semantics. So ability to specify 
> rounding mode would be useful for such targets.

What about the idea of using operand bundles? I think the idea there was to 
avoid having to add new intrinsics for every target-specific floating point 
intrinsic. But maybe the idea will work here as well?

I think we definitely need to warn when -ffp-exception-behavior=strict or 
=maytrap is given and incompatible options are also used with it. In that case 
we should also be disabling the -ffp-exception-behavior option and the related 
#pragmas plus warning about the disabling. We already disable+warn when our 
backend doesn't support strictfp, we can do the same here.

If someone in the future wants to implement the support then that'll be nice. 
But in the meantime we shouldn't be silently letting people use strictfp plus a 
contradictory option.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115804/new/

https://reviews.llvm.org/D115804

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


[PATCH] D104854: Introduce intrinsic llvm.isnan

2021-08-23 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added a comment.

In D104854#2959680 , @thopre wrote:

> In D104854#2957735 , @kpn wrote:
>
>> In D104854#2957490 , @lebedev.ri 
>> wrote:
>>
>>> In D104854#2957471 , @sepavloff 
>>> wrote:
>>>
 In D104854#2957423 , @spatel 
 wrote:

> Is it intentional that we are not canonicalizing the intrinsic call back 
> to `fcmp uno` in the default FP environment?

 It is lowered to unordered comparison by default. Changing `llvm.isnan` to 
  `fcmp uno` somewhere in IR would make it possible to optimize out the 
 latter if fast-math mode is on. Preserving semantics of `isnan` when 
 fast-math is in effect was one of the goals of this change.
>>>
>>> Eeek. Was there an RFC about this?
>>> This does not sound good to me at all,
>>> much like "let's not apply fast-math flags to x86 vector intrinsics".
>>
>> We can switch into and out of the default FP environment inside a single 
>> function.
>
> Really? The constrained intrinsic documentation claims the reverse 
> (https://llvm.org/docs/LangRef.html#constrainedfp):
>
>> If any FP operation in a function is constrained then they all must be 
>> constrained. This is required for correct LLVM IR. Optimizations that move 
>> code around can create miscompiles if mixing of constrained and normal 
>> operations is done. The correct way to mix constrained and less constrained 
>> operations is to use the rounding mode and exception handling metadata to 
>> mark constrained intrinsics as having LLVM’s default behavior.

Use of constrained intrinsics does not mean that we are automatically in an 
alternate FP environment.

When constrained intrinsics are used and the metadata says the rounding mode is 
"tonearest" with exceptions set to "ignore" then that's the default FP 
environment. If, for example, #pragma STDC FENV_ACCESS is used in only a part 
of a function then the constrained intrinsics will be used in the entire 
function but the metadata will specify different exception or rounding behavior 
in the part covered by the FENV_ACCESS.

That the constrained intrinsics can state that they are in the default FP 
environment is what makes it safe for EarlyCSE to treat them the same as a 
normal FP instruction (which is assumed to be in the default FP environment). 
For example.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104854/new/

https://reviews.llvm.org/D104854

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


[PATCH] D104854: Introduce intrinsic llvm.isnan

2021-08-20 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added a comment.

In D104854#2957490 , @lebedev.ri 
wrote:

> In D104854#2957471 , @sepavloff 
> wrote:
>
>> In D104854#2957423 , @spatel wrote:
>>
>>> Is it intentional that we are not canonicalizing the intrinsic call back to 
>>> `fcmp uno` in the default FP environment?
>>
>> It is lowered to unordered comparison by default. Changing `llvm.isnan` to  
>> `fcmp uno` somewhere in IR would make it possible to optimize out the latter 
>> if fast-math mode is on. Preserving semantics of `isnan` when fast-math is 
>> in effect was one of the goals of this change.
>
> Eeek. Was there an RFC about this?
> This does not sound good to me at all,
> much like "let's not apply fast-math flags to x86 vector intrinsics".

We can switch into and out of the default FP environment inside a single 
function. If we want different behavior based on the FP environment then this 
should be a constrained intrinsic. Then the intrinsic would know the FP 
environment, or at least enough about it to know if traps and FP status bits 
are relevant.

I think the distinction is constrained vs non-constrained because FMF can 
optionally be used in both cases.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104854/new/

https://reviews.llvm.org/D104854

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


[PATCH] D99675: RFC [llvm][clang] Create new intrinsic llvm.arith.fence to control FP optimization at expression level

2021-05-18 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added a comment.

In D99675#2696327 , @pengfei wrote:

> In D99675#2695424 , @kpn wrote:
>
>> What changes are needed for a backend, and what happens if they aren't done?
>
> As far as I understand it, backend does optimizations based on patterns of 
> the known nodes and MIs. Inserting a new node/MI will block any optimizations 
> across the fence. So it respects the semantics of the intrinsic without 
> target special chenges.
> I'm not sure if there's room for optimization cross the `arithmetic.fence`. 
> If there is and no changes for it, backend may have some performance loss 
> under these circumstances.
>
>> Having something needed for correctness silently not work seems ... 
>> sub-optimal.
>
> I think backend is conservative for optimizations when use the intrinsic. It 
> won't have correctness issue silently, but performance loss might.

OK, that sounds fine, then.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D99675/new/

https://reviews.llvm.org/D99675

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


[PATCH] D100834: Bug 49739 - [Matrix] Support #pragma clang fp

2021-04-20 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added a comment.

I don't know the matrix implementation so I can't swear this hits every place 
needed, but the uses of CGFPOptionsRAII in this patch look correct at least.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100834/new/

https://reviews.llvm.org/D100834

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


[PATCH] D100118: [clang] RFC Support new builtin __arithmetic_fence to control floating point optimization, and new clang option fprotect-parens

2021-04-20 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:2844
+  return RValue::get(
+  Builder.CreateArithmeticFence(ArgValue, ConvertType(ArgType)));
+return RValue::get(ArgValue);

Does this say that the fence will be silently dropped if any of the fast math 
flags are disabled? Silently dropping something used for correctness makes me 
nervous. Is there a case where all of these flags are required for correct 
behavior of the fence?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100118/new/

https://reviews.llvm.org/D100118

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


[PATCH] D99675: RFC [llvm][clang] Create new intrinsic llvm.arith.fence to control FP optimization at expression level

2021-04-16 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added a comment.

In D99675#2695480 , @mibintc wrote:

> In D99675#2695424 , @kpn wrote:
>
>> What changes are needed for a backend, and what happens if they aren't done?
>
> In the clang patch, I'm planning to add into TargetInfo a function like "does 
> the target support __arithmetic_fence"?
> In the llvm patch, the fallback implementation could be to merely ignore the 
> call, and pass through the operand value. Is that adequate?

If clang is the only compiler to ever emit this new intrinsic then, yes, that's 
perfectly fine.

If a front-end other than clang uses the new fence then I'm nervous about 
having the fence just vanish. If the fence is used then it must be for 
correctness, right? Having something needed for correctness silently not work 
seems ... sub-optimal. It's the sort of thing that might not get caught in 
testing, and then you've got end-users running software that silently lacks 
something needed for correctness. That makes me nervous. I'd rather LLVM bomb 
instead of silently dropping this fence. Then developers know they have a 
problem before a product goes out the door.

But if I'm the only one that's nervous then that's OK and clang rejecting the 
compile would be sufficient.

Has this sort of issue come up in the past? How was it handled?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D99675/new/

https://reviews.llvm.org/D99675

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


[PATCH] D99675: RFC [llvm][clang] Create new intrinsic llvm.arith.fence to control FP optimization at expression level

2021-04-16 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added a comment.

What changes are needed for a backend, and what happens if they aren't done?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D99675/new/

https://reviews.llvm.org/D99675

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


[PATCH] D100118: [clang] RFC Support new builtin __arithmetic_fence to control floating point optimization, and new clang option fprotect-parens

2021-04-16 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added a comment.

In D100118#2695365 , @kpn wrote:

> I thought that adding a new fence required changing every optimization pass 
> in LLVM. That's why the constrained intrinsics were implemented they way they 
> are where no fence is needed.
>
> Aren't you going to have miscompiles using this new fence until all that 
> optimization work is done? Or am I wrong? @andrew.w.kaylor?

Perhaps there is no problem. I'm looking at D99675 
 now.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100118/new/

https://reviews.llvm.org/D100118

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


[PATCH] D100118: [clang] RFC Support new builtin __arithmetic_fence to control floating point optimization, and new clang option fprotect-parens

2021-04-16 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added a comment.

I thought that adding a new fence required changing every optimization pass in 
LLVM. That's why the constrained intrinsics were implemented they way they are 
where no fence is needed.

Aren't you going to have miscompiles using this new fence until all that 
optimization work is done? Or am I wrong? @andrew.w.kaylor?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100118/new/

https://reviews.llvm.org/D100118

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


[PATCH] D98923: [Driver] Pass -fexperimental-strict-floating-point to cc1 if it is specified

2021-03-19 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added a comment.

Test case?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D98923/new/

https://reviews.llvm.org/D98923

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


[PATCH] D97125: Stop traping on sNaN in __builtin_isinf

2021-02-22 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added a comment.

System/Z's TEST DATA CLASS instruction covers most (all?) of the possible FP 
value states. You might want to subscribe, or add as a reviewer, jonpa just to 
make sure everyone stays in sync.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97125/new/

https://reviews.llvm.org/D97125

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


[PATCH] D95948: Stop traping on sNaN in __builtin_isnan

2021-02-05 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn accepted this revision.
kpn added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95948/new/

https://reviews.llvm.org/D95948

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


[PATCH] D95948: Stop traping on sNaN in __builtin_isnan

2021-02-04 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added a comment.

In D95948#2542884 , @mibintc wrote:

> Should we add tests for mlong-double-64, -80, -128?

Assuming Ty->getScalarSizeInBits() returns 64, 80, or 128 in those cases, I 
think it's good enough to just add an AArch64 (or some other 128-bit long 
double host) and call it a day. We're testing isnan(), not that command line 
option, after all.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95948/new/

https://reviews.llvm.org/D95948

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


[PATCH] D95948: Stop traping on sNaN in __builtin_isnan

2021-02-04 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added a comment.

This looks like a definite step forward. Thank you!

Can you do an AArch64 test case showing long double? Right now there's no 
128-bit test case.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95948/new/

https://reviews.llvm.org/D95948

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


[PATCH] D94614: [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 Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG81b69879c946: [FPEnv][X86] Platform builtins edition: clang 
should get from the AST the… (authored by kpn).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94614/new/

https://reviews.llvm.org/D94614

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/X86/avx-builtins-constrained-cmp.c
  clang/test/CodeGen/X86/avx512dq-builtins-constrained.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

Index: clang/test/CodeGen/X86/sse-builtins-constrained.c
===
--- clang/test/CodeGen/X86/sse-builtins-constrained.c
+++ clang/test/CodeGen/X86/sse-builtins-constrained.c
@@ -1,8 +1,15 @@
 // REQUIRES: x86-registered-target
 // RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-unknown-linux-gnu -target-feature +sse -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=UNCONSTRAINED --check-prefix=COMMON --check-prefix=COMMONIR
-// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-unknown-linux-gnu -target-feature +sse -ffp-exception-behavior=strict -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=CONSTRAINED --check-prefix=COMMON --check-prefix=COMMONIR
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-unknown-linux-gnu -target-feature +sse -ffp-exception-behavior=maytrap -DSTRICT=1 -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=CONSTRAINED --check-prefix=COMMON --check-prefix=COMMONIR
 // RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-unknown-linux-gnu -target-feature +sse -S %s -o - -Wall -Werror | FileCheck %s --check-prefix=CHECK-ASM --check-prefix=COMMON
-// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-unknown-linux-gnu -target-feature +sse -ffp-exception-behavior=strict -S %s -o - -Wall -Werror | FileCheck %s --check-prefix=CHECK-ASM --check-prefix=COMMON
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-unknown-linux-gnu -target-feature +sse -ffp-exception-behavior=maytrap -DSTRICT=1 -S %s -o - -Wall -Werror | FileCheck %s --check-prefix=CHECK-ASM --check-prefix=COMMON
+
+#ifdef STRICT
+// Test that the constrained intrinsics are picking up the exception
+// metadata from the AST instead of the global default from the command line.
+
+#pragma float_control(except, on)
+#endif
 
 
 #include 
Index: clang/test/CodeGen/X86/fma-builtins-constrained.c
===
--- clang/test/CodeGen/X86/fma-builtins-constrained.c
+++ clang/test/CodeGen/X86/fma-builtins-constrained.c
@@ -1,8 +1,15 @@
 // REQUIRES: x86-registered-target
 // RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-unknown-linux-gnu -target-feature +fma -O2 -emit-llvm -o - | FileCheck %s --check-prefixes=COMMON,COMMONIR,UNCONSTRAINED
-// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-unknown-linux-gnu -target-feature +fma -ffp-exception-behavior=strict -O2 -emit-llvm -o - | FileCheck %s --check-prefixes=COMMON,COMMONIR,CONSTRAINED
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-unknown-linux-gnu -target-feature +fma -ffp-exception-behavior=maytrap -DSTRICT=1 -O2 -emit-llvm -o - | FileCheck %s --check-prefixes=COMMON,COMMONIR,CONSTRAINED
 // RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-unknown-linux-gnu -target-feature +fma -O2 -S -o - | FileCheck %s --check-prefixes=COMMON,CHECK-ASM
-// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-unknown-linux-gnu -target-feature +fma -O2 -ffp-exception-behavior=strict -S -o - | FileCheck %s --check-prefixes=COMMON,CHECK-ASM
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-unknown-linux-gnu -target-feature +fma -O2 -ffp-exception-behavior=maytrap -DSTRICT=1 -S -o - | FileCheck %s --check-prefixes=COMMON,CHECK-ASM
+
+#ifdef STRICT
+// Test that the constrained intrinsics are picking up the exception
+// metadata from the AST instead of the global default from the command line.
+
+#pragma float_control(except, on)
+#endif
 
 #include 
 
Index: clang/test/CodeGen/X86/avx512f-builtins-constrained.c
===
--- clang/test/CodeGen/X86/avx512f-builtins-constrained.c
+++ clang/test/CodeGen/X86/avx512f-builtins-constrained.c
@@ -1,10 +1,17 @@
 // REQUIRES: x86-registered-target
 // 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=UNCONSTRA

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

2021-01-22 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn updated this revision to Diff 318567.
kpn added a comment.

Update for review comments: Move uses of CGFPOptionsRAII lower and closer to 
where they are needed. This should be less error prone as well.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94614/new/

https://reviews.llvm.org/D94614

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/X86/avx-builtins-constrained-cmp.c
  clang/test/CodeGen/X86/avx512dq-builtins-constrained.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

Index: clang/test/CodeGen/X86/sse-builtins-constrained.c
===
--- clang/test/CodeGen/X86/sse-builtins-constrained.c
+++ clang/test/CodeGen/X86/sse-builtins-constrained.c
@@ -1,8 +1,15 @@
 // REQUIRES: x86-registered-target
 // RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-unknown-linux-gnu -target-feature +sse -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=UNCONSTRAINED --check-prefix=COMMON --check-prefix=COMMONIR
-// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-unknown-linux-gnu -target-feature +sse -ffp-exception-behavior=strict -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=CONSTRAINED --check-prefix=COMMON --check-prefix=COMMONIR
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-unknown-linux-gnu -target-feature +sse -ffp-exception-behavior=maytrap -DSTRICT=1 -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=CONSTRAINED --check-prefix=COMMON --check-prefix=COMMONIR
 // RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-unknown-linux-gnu -target-feature +sse -S %s -o - -Wall -Werror | FileCheck %s --check-prefix=CHECK-ASM --check-prefix=COMMON
-// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-unknown-linux-gnu -target-feature +sse -ffp-exception-behavior=strict -S %s -o - -Wall -Werror | FileCheck %s --check-prefix=CHECK-ASM --check-prefix=COMMON
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-unknown-linux-gnu -target-feature +sse -ffp-exception-behavior=maytrap -DSTRICT=1 -S %s -o - -Wall -Werror | FileCheck %s --check-prefix=CHECK-ASM --check-prefix=COMMON
+
+#ifdef STRICT
+// Test that the constrained intrinsics are picking up the exception
+// metadata from the AST instead of the global default from the command line.
+
+#pragma float_control(except, on)
+#endif
 
 
 #include 
Index: clang/test/CodeGen/X86/fma-builtins-constrained.c
===
--- clang/test/CodeGen/X86/fma-builtins-constrained.c
+++ clang/test/CodeGen/X86/fma-builtins-constrained.c
@@ -1,8 +1,15 @@
 // REQUIRES: x86-registered-target
 // RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-unknown-linux-gnu -target-feature +fma -O2 -emit-llvm -o - | FileCheck %s --check-prefixes=COMMON,COMMONIR,UNCONSTRAINED
-// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-unknown-linux-gnu -target-feature +fma -ffp-exception-behavior=strict -O2 -emit-llvm -o - | FileCheck %s --check-prefixes=COMMON,COMMONIR,CONSTRAINED
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-unknown-linux-gnu -target-feature +fma -ffp-exception-behavior=maytrap -DSTRICT=1 -O2 -emit-llvm -o - | FileCheck %s --check-prefixes=COMMON,COMMONIR,CONSTRAINED
 // RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-unknown-linux-gnu -target-feature +fma -O2 -S -o - | FileCheck %s --check-prefixes=COMMON,CHECK-ASM
-// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-unknown-linux-gnu -target-feature +fma -O2 -ffp-exception-behavior=strict -S -o - | FileCheck %s --check-prefixes=COMMON,CHECK-ASM
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-unknown-linux-gnu -target-feature +fma -O2 -ffp-exception-behavior=maytrap -DSTRICT=1 -S -o - | FileCheck %s --check-prefixes=COMMON,CHECK-ASM
+
+#ifdef STRICT
+// Test that the constrained intrinsics are picking up the exception
+// metadata from the AST instead of the global default from the command line.
+
+#pragma float_control(except, on)
+#endif
 
 #include 
 
Index: clang/test/CodeGen/X86/avx512f-builtins-constrained.c
===
--- clang/test/CodeGen/X86/avx512f-builtins-constrained.c
+++ clang/test/CodeGen/X86/avx512f-builtins-constrained.c
@@ -1,10 +1,17 @@
 // REQUIRES: x86-registered-target
 // 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 -fexpe

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

2021-01-19 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:12268
+  case X86::BI__builtin_ia32_cvtqq2pd512_mask: {
+CodeGenFunction::CGFPOptionsRAII FPOptsRAII(*this, E);
 return EmitX86ConvertIntToFp(*this, Ops, /*IsSigned*/true);

pengfei wrote:
> Maybe better to move it into these Emit* functions?
Certainly. Will do.



Comment at: clang/test/CodeGen/X86/avx512dq-builtins-constrained.c:3
+// RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s 
-triple=x86_64-apple-darwin -target-feature +avx512dq -emit-llvm -o - -Wall 
-Werror | FileCheck %s --check-prefix=UNCONSTRAINED --check-prefix=COMMON 
--check-prefix=COMMONIR
+// RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s 
-triple=x86_64-apple-darwin -target-feature +avx512dq 
-ffp-exception-behavior=maytrap -DSTRICT=1 -emit-llvm -o - -Wall -Werror | tee 
/tmp/X | FileCheck %s --check-prefix=CONSTRAINED --check-prefix=COMMON 
--check-prefix=COMMONIR
+// RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s 
-triple=x86_64-apple-darwin -target-feature +avx512dq -S -o - -Wall -Werror | 
FileCheck %s --check-prefix=CHECK-ASM --check-prefix=COMMON

pengfei wrote:
> Where is the file used? It results in failure on Windows.
Because I forgot to remove the "tee" command perhaps?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94614/new/

https://reviews.llvm.org/D94614

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


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

2021-01-14 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added a comment.

This doesn't add metadata to llvm intrinsics that are not constrained.

The metadata is added by the IRBuilder when the IRBuilder is used to add 
constrained intrinsics. When adding non-constrained intrinsics that have a 
direct mapping to constrained intrinsics, and constrained mode is enabled, the 
IRBuilder will add a constrained intrinsic instead of the requested 
non-constrained intrinsic. This keeps the changes to the front-end smaller.

But the metadata is _only_ added when the IRBuilder knows it is adding a 
constrained intrinsic. So we're not adding anything to any of the other llvm 
intrinsics. The target-specific llvm intrinsics are no exception to this rule.

Some of the clang builtins get lowered in whole or in part to llvm instructions 
(or constrained FP calls). Currently they use the metadata specified by the 
command line arguments. This change causes them to pick up the metadata that 
the AST says should be used. If no #pragma was used then the AST will be 
carrying the metadata from the command line. If a relevant #pragma is used then 
without this change the metadata in the #pragma's scope will be wrong. I'm 
testing for this by having the RUN lines specify "maytrap" but then use the 
#pragma float_control to switch to "fpexcept.strict".

The IRBuilder's idea of the current metadata is updated by CGFPOptionsRAII. 
That's why you see it used right around places where we leave the clang AST and 
call into code that doesn't have access to the AST. Like the IRBuilder.

A similar issue exists with the rounding-mode metadata. But both rounding and 
exception behavior are set by CGFPOptionsRAII, and if that changes then other 
tests already in the tree will fail. So I'm not bothering with rounding 
metadata testing here.

It's true that the middle-end optimizers know nothing about the constrained 
intrinsics. Today. I plan on changing that in the near future.

If use of the constrained intrinsics will cause breakage of the target-specific 
clang builtins then that's important to know and to fix. And I don't know all 
the targets well enough to know if that is a problem. So I'm going around 
asking target-specific developers to take another look and make sure we aren't 
setting ourselves up for problems later by having these builtins lower with the 
correct metadata for this point in the AST.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94614/new/

https://reviews.llvm.org/D94614

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


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

2021-01-13 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn created this revision.
kpn added reviewers: craig.topper, andrew.w.kaylor.
kpn added a project: clang.
Herald added a subscriber: pengfei.
kpn requested review of this revision.
Herald added a subscriber: cfe-commits.

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

For previous work in this vein see D92122  for 
example.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D94614

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/X86/avx-builtins-constrained-cmp.c
  clang/test/CodeGen/X86/avx512dq-builtins-constrained.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

Index: clang/test/CodeGen/X86/sse-builtins-constrained.c
===
--- clang/test/CodeGen/X86/sse-builtins-constrained.c
+++ clang/test/CodeGen/X86/sse-builtins-constrained.c
@@ -1,8 +1,15 @@
 // REQUIRES: x86-registered-target
 // RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-unknown-linux-gnu -target-feature +sse -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=UNCONSTRAINED --check-prefix=COMMON --check-prefix=COMMONIR
-// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-unknown-linux-gnu -target-feature +sse -ffp-exception-behavior=strict -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=CONSTRAINED --check-prefix=COMMON --check-prefix=COMMONIR
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-unknown-linux-gnu -target-feature +sse -ffp-exception-behavior=maytrap -DSTRICT=1 -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=CONSTRAINED --check-prefix=COMMON --check-prefix=COMMONIR
 // RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-unknown-linux-gnu -target-feature +sse -S %s -o - -Wall -Werror | FileCheck %s --check-prefix=CHECK-ASM --check-prefix=COMMON
-// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-unknown-linux-gnu -target-feature +sse -ffp-exception-behavior=strict -S %s -o - -Wall -Werror | FileCheck %s --check-prefix=CHECK-ASM --check-prefix=COMMON
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-unknown-linux-gnu -target-feature +sse -ffp-exception-behavior=maytrap -DSTRICT=1 -S %s -o - -Wall -Werror | FileCheck %s --check-prefix=CHECK-ASM --check-prefix=COMMON
+
+#ifdef STRICT
+// Test that the constrained intrinsics are picking up the exception
+// metadata from the AST instead of the global default from the command line.
+
+#pragma float_control(except, on)
+#endif
 
 
 #include 
Index: clang/test/CodeGen/X86/fma-builtins-constrained.c
===
--- clang/test/CodeGen/X86/fma-builtins-constrained.c
+++ clang/test/CodeGen/X86/fma-builtins-constrained.c
@@ -1,8 +1,15 @@
 // REQUIRES: x86-registered-target
 // RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-unknown-linux-gnu -target-feature +fma -O2 -emit-llvm -o - | FileCheck %s --check-prefixes=COMMON,COMMONIR,UNCONSTRAINED
-// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-unknown-linux-gnu -target-feature +fma -ffp-exception-behavior=strict -O2 -emit-llvm -o - | FileCheck %s --check-prefixes=COMMON,COMMONIR,CONSTRAINED
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-unknown-linux-gnu -target-feature +fma -ffp-exception-behavior=maytrap -DSTRICT=1 -O2 -emit-llvm -o - | FileCheck %s --check-prefixes=COMMON,COMMONIR,CONSTRAINED
 // RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-unknown-linux-gnu -target-feature +fma -O2 -S -o - | FileCheck %s --check-prefixes=COMMON,CHECK-ASM
-// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-unknown-linux-gnu -target-feature +fma -O2 -ffp-exception-behavior=strict -S -o - | FileCheck %s --check-prefixes=COMMON,CHECK-ASM
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-unknown-linux-gnu -target-feature +fma -O2 -ffp-exception-behavior=maytrap -DSTRICT=1 -S -o - | FileCheck %s --check-prefixes=COMMON,CHECK-ASM
+
+#ifdef STRICT
+// Test that the constrained intrinsics are picking up the exception
+// metadata from the AST instead of the global default from the command line.
+
+#pragma float_control(except, on)
+#endif
 
 #include 
 
Index: clang/test/CodeGen/X86/avx512f-builtins-constrained.c
===
--- clang/test/CodeGen/X86/avx512f-builtins-constrained.c
+++ clang/test/CodeGen/X86/avx512f-builtins-constrained.c
@@ -1,10 +1,17 @@
 // REQUIRES: x86-registered-target
 // 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 -f

[PATCH] D94186: [FPEnv][PowerPC] Platform builtins edition: clang should get from the AST the metadata for constrained FP builtins

2021-01-06 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn created this revision.
kpn added reviewers: steven.zhang, nemanjai.
kpn added a project: clang.
Herald added subscribers: shchenz, kbarton.
kpn requested review of this revision.
Herald added a subscriber: cfe-commits.

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

For previous work in this vein see D92122  for 
example.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D94186

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-ppc-fma.c
  clang/test/CodeGen/builtins-ppc-fpconstrained.c

Index: clang/test/CodeGen/builtins-ppc-fpconstrained.c
===
--- clang/test/CodeGen/builtins-ppc-fpconstrained.c
+++ clang/test/CodeGen/builtins-ppc-fpconstrained.c
@@ -2,16 +2,23 @@
 // RUN: %clang_cc1 -triple powerpc64le-gnu-linux -target-feature +vsx \
 // RUN: -emit-llvm %s -o - | FileCheck --check-prefix=CHECK-UNCONSTRAINED %s
 // RUN: %clang_cc1 -triple powerpc64le-gnu-linux -target-feature +vsx \
-// RUN:  -ffp-exception-behavior=strict -emit-llvm %s -o - | FileCheck \
-// RUN: --check-prefix=CHECK-CONSTRAINED -vv %s
+// RUN:  -ffp-exception-behavior=maytrap -DSTRICT=1 -emit-llvm %s -o - | \
+// RUN: FileCheck --check-prefix=CHECK-CONSTRAINED -vv %s
 // RUN: %clang_cc1 -triple powerpc64le-gnu-linux -target-feature +vsx \
 // RUN: -fallow-half-arguments-and-returns -S -o - %s | \
 // RUN: FileCheck --check-prefix=CHECK-ASM --check-prefix=NOT-FIXME-CHECK  %s
 // RUN: %clang_cc1 -triple powerpc64le-gnu-linux -target-feature +vsx \
-// RUN: -fallow-half-arguments-and-returns -S -ffp-exception-behavior=strict \
-// RUN: -o - %s | FileCheck --check-prefix=CHECK-ASM \
+// RUN: -fallow-half-arguments-and-returns -S -ffp-exception-behavior=maytrap \
+// RUN: -DSTRICT=1 -o - %s | FileCheck --check-prefix=CHECK-ASM \
 // RUN: --check-prefix=FIXME-CHECK  %s
 
+#ifdef STRICT
+// Test that the constrained intrinsics are picking up the exception
+// metadata from the AST instead of the global default from the command line.
+
+#pragma float_control(except, on)
+#endif
+
 typedef __attribute__((vector_size(4 * sizeof(float float vec_float;
 typedef __attribute__((vector_size(2 * sizeof(double double vec_double;
 
Index: clang/test/CodeGen/builtins-ppc-fma.c
===
--- clang/test/CodeGen/builtins-ppc-fma.c
+++ clang/test/CodeGen/builtins-ppc-fma.c
@@ -1,6 +1,17 @@
 // RUN: %clang_cc1 -triple powerpc64le-gnu-linux \
-// RUN: -target-feature +altivec -Wall -Wno-unused -Werror -emit-llvm %s -o - | FileCheck  \
+// RUN: -target-feature +altivec -Wall -Wno-unused -Werror -emit-llvm %s -o - | FileCheck --check-prefix=NOSTRICT --check-prefix=SHARED\
 // RUN: %s
+// RUN: %clang_cc1 -triple powerpc64le-gnu-linux \
+// RUN: -ffp-exception-behavior=maytrap -DSTRICT=1 \
+// RUN: -target-feature +altivec -Wall -Wno-unused -Werror -emit-llvm %s -o - | FileCheck --check-prefix=STRICT --check-prefix=SHARED\
+// RUN: %s
+
+#ifdef STRICT
+// Test that the constrained intrinsics are picking up the exception
+// metadata from the AST instead of the global default from the command line.
+
+#pragma float_control(except, on)
+#endif
 
 typedef __attribute__((vector_size(4 * sizeof(float float vec_float;
 typedef __attribute__((vector_size(2 * sizeof(double double vec_double;
@@ -10,34 +21,42 @@
 
 void test_fma(void) {
   vf = __builtin_vsx_xvmaddasp(vf, vf, vf);
-  // CHECK: @llvm.fma.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x float> %{{.*}})
+  // NOSTRICT: @llvm.fma.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x float> %{{.*}})
+  // STRICT: @llvm.experimental.constrained.fma.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x float> %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
 
   vd = __builtin_vsx_xvmaddadp(vd, vd, vd);
-  // CHECK: @llvm.fma.v2f64(<2 x double> %{{.*}}, <2 x double> %{{.*}}, <2 x double> %{{.*}})
+  // NOSTRICT: @llvm.fma.v2f64(<2 x double> %{{.*}}, <2 x double> %{{.*}}, <2 x double> %{{.*}})
+  // STRICT: @llvm.experimental.constrained.fma.v2f64(<2 x double> %{{.*}}, <2 x double> %{{.*}}, <2 x double> %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
 
   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]]
+  // NOSTRICT: [[RESULT:%[^ ]+]] = call <4 x float> @llvm.fma.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x float> %{{.*}})
+  // STRICT: [[RESULT:%[^ ]+]] = call <4 x float> @llvm.experimental.constrained.fma.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x float> %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
+  // SHARED: fneg <4 x float> [[RESULT]]
 

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

2020-12-15 Thread Kevin P. Neal via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG67a1ffd88ac0: [FPEnv] Teach the IRBuilder about 
invoke's correct use of the strictfp… (authored by kpn).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93134/new/

https://reviews.llvm.org/D93134

Files:
  clang/test/CodeGen/exceptions-strictfp.c
  llvm/include/llvm/IR/IRBuilder.h


Index: llvm/include/llvm/IR/IRBuilder.h
===
--- llvm/include/llvm/IR/IRBuilder.h
+++ llvm/include/llvm/IR/IRBuilder.h
@@ -301,7 +301,7 @@
 }
   }
 
-  void setConstrainedFPCallAttr(CallInst *I) {
+  void setConstrainedFPCallAttr(CallBase *I) {
 I->addAttribute(AttributeList::FunctionIndex, Attribute::StrictFP);
   }
 
@@ -1023,16 +1023,21 @@
ArrayRef Args,
ArrayRef OpBundles,
const Twine &Name = "") {
-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 &Name = "") {
-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,
Index: clang/test/CodeGen/exceptions-strictfp.c
===
--- /dev/null
+++ 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 }


Index: llvm/include/llvm/IR/IRBuilder.h
===
--- llvm/include/llvm/IR/IRBuilder.h
+++ llvm/include/llvm/IR/IRBuilder.h
@@ -301,7 +301,7 @@
 }
   }
 
-  void setConstrainedFPCallAttr(CallInst *I) {
+  void setConstrainedFPCallAttr(CallBase *I) {
 I->addAttribute(AttributeList::FunctionIndex, Attribute::StrictFP);
   }
 
@@ -1023,16 +1023,21 @@
ArrayRef Args,
ArrayRef OpBundles,
const Twine &Name = "") {
-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 &Name = "") {
-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,
Index: clang/test/CodeGen/exceptions-str

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

2020-12-11 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn created this revision.
kpn added reviewers: spatel, rjmccall, andrew.w.kaylor, mibintc, sepavloff.
kpn requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D93134

Files:
  clang/test/CodeGen/exceptions-strictfp.c
  llvm/include/llvm/IR/IRBuilder.h


Index: llvm/include/llvm/IR/IRBuilder.h
===
--- llvm/include/llvm/IR/IRBuilder.h
+++ llvm/include/llvm/IR/IRBuilder.h
@@ -301,7 +301,7 @@
 }
   }
 
-  void setConstrainedFPCallAttr(CallInst *I) {
+  void setConstrainedFPCallAttr(CallBase *I) {
 I->addAttribute(AttributeList::FunctionIndex, Attribute::StrictFP);
   }
 
@@ -1019,16 +1019,21 @@
ArrayRef Args,
ArrayRef OpBundles,
const Twine &Name = "") {
-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 &Name = "") {
-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,
Index: clang/test/CodeGen/exceptions-strictfp.c
===
--- /dev/null
+++ 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 }


Index: llvm/include/llvm/IR/IRBuilder.h
===
--- llvm/include/llvm/IR/IRBuilder.h
+++ llvm/include/llvm/IR/IRBuilder.h
@@ -301,7 +301,7 @@
 }
   }
 
-  void setConstrainedFPCallAttr(CallInst *I) {
+  void setConstrainedFPCallAttr(CallBase *I) {
 I->addAttribute(AttributeList::FunctionIndex, Attribute::StrictFP);
   }
 
@@ -1019,16 +1019,21 @@
ArrayRef Args,
ArrayRef OpBundles,
const Twine &Name = "") {
-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 &Name = "") {
-return Insert(InvokeInst::Create(Ty, Callee, NormalDest, UnwindDest, Args),
-  Name);
+InvokeInst *II =
+InvokeInst::Create(Ty, Callee, NormalDest, UnwindDest, Args);
+if (IsFPConstrained)
+  setConstrainedFPCallAttr(II);
+ret

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

2020-12-08 Thread Kevin P. Neal via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGacd4950d4f1e: [FPEnv] Correct constrained metadata in 
fp16-ops-strict.c (authored by kpn).

Changed prior to commit:
  https://reviews.llvm.org/D92596?vs=309327&id=310192#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92596/new/

https://reviews.llvm.org/D92596

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

Index: clang/test/CodeGen/fp16-ops-strictfp.c
===
--- clang/test/CodeGen/fp16-ops-strictfp.c
+++ 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 @@
   // 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 %{{.*}}, 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 0xHBC00, 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 %{{.*}}, metadata !"fpexcept.maytrap

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

2020-12-07 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added inline comments.



Comment at: clang/lib/CodeGen/CGExprScalar.cpp:3006
 
+  CodeGenFunction::CGFPOptionsRAII FPOptsRAII(CGF, OpInfo.FPFeatures);
   SourceLocation Loc = E->getExprLoc();

mibintc wrote:
> kpn wrote:
> > mibintc wrote:
> > > What's the rule to follow about when we need to FPOptsRAII? 
> > It is used on the border between code that has the AST node and code that 
> > doesn't. If any code below this point might use the constrained floating 
> > point intrinsics then the FPOptsRAII is needed.
> > 
> > Sometimes this border is at a call to the IRBuilder. Sometimes it's buried 
> > elsewhere. The hope is that by having the location be defined there we can 
> > at some point audit to verify we have it everywhere we should.
> Oh, that doesn't sound very bug-proof.  Do you mind pointing out 2 different 
> instances, one "AST node" and one "buried elsewhere"?  Or there's probably a 
> code review I should read to find this?  Thank you
Agreed, but the approach of wrapping calls to the IRBuilder isn't very 
bug-proof either. And it requires threading strictfp info throughout code that 
otherwise doesn't support carrying around info currently. So it would be 
invasive and hard to audit.

This patch is an example of code that has the AST node (the Expr*) and is 
calling the IRBuilder. For "buried" examples see D88913.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92596/new/

https://reviews.llvm.org/D92596

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


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

2020-12-07 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added inline comments.



Comment at: clang/lib/CodeGen/CGExprScalar.cpp:2992
 // floating point environment in the loop.
+//XXX true?
 llvm::BasicBlock *startBB = Builder.GetInsertBlock();

mibintc wrote:
> did you mean to leave this here? (blame shows the fixme comment dates from 
> 2012)
I was hoping someone knew what "floating point environment" is relevant here. 
From reading the commit message it doesn't sound like it matters to us, but I 
thought I'd flag it anyway.

No, I wasn't planning on committing with this comment.



Comment at: clang/lib/CodeGen/CGExprScalar.cpp:3006
 
+  CodeGenFunction::CGFPOptionsRAII FPOptsRAII(CGF, OpInfo.FPFeatures);
   SourceLocation Loc = E->getExprLoc();

mibintc wrote:
> What's the rule to follow about when we need to FPOptsRAII? 
It is used on the border between code that has the AST node and code that 
doesn't. If any code below this point might use the constrained floating point 
intrinsics then the FPOptsRAII is needed.

Sometimes this border is at a call to the IRBuilder. Sometimes it's buried 
elsewhere. The hope is that by having the location be defined there we can at 
some point audit to verify we have it everywhere we should.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92596/new/

https://reviews.llvm.org/D92596

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


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

2020-12-03 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn created this revision.
kpn added reviewers: sepavloff, mibintc.
kpn added a project: clang.
kpn requested review of this revision.
Herald added a subscriber: cfe-commits.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92596

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

Index: clang/test/CodeGen/fp16-ops-strictfp.c
===
--- clang/test/CodeGen/fp16-ops-strictfp.c
+++ 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 @@
   // 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 %{{.*}}, 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 0xHBC00, 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 %{{.*}}, metadata !"fpexcept.maytrap")
-  // NOTNATIVE: call float @llvm.experimental.constrained.fadd.f32(float %{{.*}}, float {{.*}}, metadata !"round

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

2020-11-30 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added a comment.

Thanks for the quick turnaround!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92122/new/

https://reviews.llvm.org/D92122

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


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

2020-11-30 Thread Kevin P. Neal via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGabfbc5579bd4: [FPEnv] clang should get from the AST the 
metadata for constrained FP builtins (authored by kpn).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92122/new/

https://reviews.llvm.org/D92122

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

Index: clang/test/CodeGen/strictfp_fpclassify.c
===
--- /dev/null
+++ clang/test/CodeGen/strictfp_fpclassify.c
@@ -0,0 +1,130 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 %s -emit-llvm -ffp-exception-behavior=maytrap -o - -triple x86_64-unknown-unknown | FileCheck %s
+
+// Test that the constrained intrinsics are picking up the exception
+// metadata from the AST instead of the global default from the command line.
+// FIXME: these functions shouldn't trap on SNaN.
+
+#pragma float_control(except, on)
+
+int printf(const char *, ...);
+
+// CHECK-LABEL: @p(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[STR_ADDR:%.*]] = alloca i8*, align 8
+// CHECK-NEXT:[[X_ADDR:%.*]] = alloca i32, align 4
+// CHECK-NEXT:store i8* [[STR:%.*]], i8** [[STR_ADDR]], align 8
+// CHECK-NEXT:store i32 [[X:%.*]], i32* [[X_ADDR]], align 4
+// CHECK-NEXT:[[TMP0:%.*]] = load i8*, i8** [[STR_ADDR]], align 8
+// CHECK-NEXT:[[TMP1:%.*]] = load i32, i32* [[X_ADDR]], align 4
+// CHECK-NEXT:[[CALL:%.*]] = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* [[TMP0]], i32 [[TMP1]]) [[ATTR4:#.*]]
+// CHECK-NEXT:ret void
+//
+void p(char *str, int x) {
+  printf("%s: %d\n", str, x);
+}
+
+#define P(n,args) p(#n #args, __builtin_##n args)
+
+// CHECK-LABEL: @test_fpclassify(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[D_ADDR:%.*]] = alloca double, align 8
+// CHECK-NEXT:store double [[D:%.*]], double* [[D_ADDR]], align 8
+// CHECK-NEXT:[[TMP0:%.*]] = load double, double* [[D_ADDR]], align 8
+// CHECK-NEXT:[[ISZERO:%.*]] = call i1 @llvm.experimental.constrained.fcmp.f64(double [[TMP0]], double 0.00e+00, metadata !"oeq", metadata !"fpexcept.strict") [[ATTR4]]
+// CHECK-NEXT:br i1 [[ISZERO]], label [[FPCLASSIFY_END:%.*]], label [[FPCLASSIFY_NOT_ZERO:%.*]]
+// CHECK:   fpclassify_end:
+// CHECK-NEXT:[[FPCLASSIFY_RESULT:%.*]] = phi i32 [ 4, [[ENTRY:%.*]] ], [ 0, [[FPCLASSIFY_NOT_ZERO]] ], [ 1, [[FPCLASSIFY_NOT_NAN:%.*]] ], [ [[TMP2:%.*]], [[FPCLASSIFY_NOT_INF:%.*]] ]
+// CHECK-NEXT:call void @p(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 [[FPCLASSIFY_RESULT]]) [[ATTR4]]
+// CHECK-NEXT:ret void
+// CHECK:   fpclassify_not_zero:
+// CHECK-NEXT:[[CMP:%.*]] = call i1 @llvm.experimental.constrained.fcmp.f64(double [[TMP0]], double [[TMP0]], metadata !"uno", metadata !"fpexcept.strict") [[ATTR4]]
+// CHECK-NEXT:br i1 [[CMP]], label [[FPCLASSIFY_END]], label [[FPCLASSIFY_NOT_NAN]]
+// CHECK:   fpclassify_not_nan:
+// CHECK-NEXT:[[TMP1:%.*]] = call double @llvm.fabs.f64(double [[TMP0]]) [[ATTR5:#.*]]
+// CHECK-NEXT:[[ISINF:%.*]] = call i1 @llvm.experimental.constrained.fcmp.f64(double [[TMP1]], double 0x7FF0, metadata !"oeq", metadata !"fpexcept.strict") [[ATTR4]]
+// CHECK-NEXT:br i1 [[ISINF]], label [[FPCLASSIFY_END]], label [[FPCLASSIFY_NOT_INF]]
+// CHECK:   fpclassify_not_inf:
+// CHECK-NEXT:[[ISNORMAL:%.*]] = call i1 @llvm.experimental.constrained.fcmp.f64(double [[TMP1]], double 0x10, metadata !"uge", metadata !"fpexcept.strict") [[ATTR4]]
+// CHECK-NEXT:[[TMP2]] = select i1 [[ISNORMAL]], i32 2, i32 3
+// CHECK-NEXT:br label [[FPCLASSIFY_END]]
+//
+void test_fpclassify(double d) {
+  P(fpclassify, (0, 1, 2, 3, 4, d));
+
+  return;
+}
+
+// CHECK-LABEL: @test_isinf(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[D_ADDR:%.*]] = alloca double, align 8
+// CHECK-NEXT:store double [[D:%.*]], double* [[D_ADDR]], align 8
+// CHECK-NEXT:[[TMP0:%.*]] = load double, double* [[D_ADDR]], align 8
+// CHECK-NEXT:[[TMP1:%.*]] = call double @llvm.fabs.f64(double [[TMP0]]) [[ATTR5]]
+// CHECK-NEXT:[[CMPINF:%.*]] = call i1 @llvm.experimental.constrained.fcmp.f64(double [[TMP1]], double 0x7FF0, metadata !"oeq", metadata !"fpexcept.strict") [[ATTR4]]
+// CHECK-NEXT:[[TMP2:%.*]] = zext i1 [[CMPINF]] to i32
+// CHECK-NEXT:call void @p(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 [[TMP2]]) [[ATTR4]]
+// CHECK-NEXT:ret void
+//
+void test_isinf(double d) {
+  P(isinf, (d));
+
+  return;
+}
+
+// CHECK-LABEL: @test_isinf_sign(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[D_ADDR:%.*]] = alloca double, align 8
+// CHECK-NEXT:store double [[D:%.*]], double* [[D

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

2020-11-25 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn created this revision.
kpn added reviewers: sepavloff, mibintc, rjmccall.
kpn added a project: clang.
Herald added a subscriber: cfe-commits.
kpn requested review of this revision.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92122

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

Index: clang/test/CodeGen/strictfp_fpclassify.c
===
--- /dev/null
+++ clang/test/CodeGen/strictfp_fpclassify.c
@@ -0,0 +1,130 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 %s -emit-llvm -ffp-exception-behavior=maytrap -o - -triple x86_64-unknown-unknown | FileCheck %s
+
+// Test that the constrained intrinsics are picking up the exception
+// metadata from the AST instead of the global default from the command line.
+// FIXME: these functions shouldn't trap on SNaN.
+
+#pragma float_control(except, on)
+
+int printf(const char *, ...);
+
+// CHECK-LABEL: @p(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[STR_ADDR:%.*]] = alloca i8*, align 8
+// CHECK-NEXT:[[X_ADDR:%.*]] = alloca i32, align 4
+// CHECK-NEXT:store i8* [[STR:%.*]], i8** [[STR_ADDR]], align 8
+// CHECK-NEXT:store i32 [[X:%.*]], i32* [[X_ADDR]], align 4
+// CHECK-NEXT:[[TMP0:%.*]] = load i8*, i8** [[STR_ADDR]], align 8
+// CHECK-NEXT:[[TMP1:%.*]] = load i32, i32* [[X_ADDR]], align 4
+// CHECK-NEXT:[[CALL:%.*]] = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* [[TMP0]], i32 [[TMP1]]) [[ATTR4:#.*]]
+// CHECK-NEXT:ret void
+//
+void p(char *str, int x) {
+  printf("%s: %d\n", str, x);
+}
+
+#define P(n,args) p(#n #args, __builtin_##n args)
+
+// CHECK-LABEL: @test_fpclassify(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[D_ADDR:%.*]] = alloca double, align 8
+// CHECK-NEXT:store double [[D:%.*]], double* [[D_ADDR]], align 8
+// CHECK-NEXT:[[TMP0:%.*]] = load double, double* [[D_ADDR]], align 8
+// CHECK-NEXT:[[ISZERO:%.*]] = call i1 @llvm.experimental.constrained.fcmp.f64(double [[TMP0]], double 0.00e+00, metadata !"oeq", metadata !"fpexcept.strict") [[ATTR4]]
+// CHECK-NEXT:br i1 [[ISZERO]], label [[FPCLASSIFY_END:%.*]], label [[FPCLASSIFY_NOT_ZERO:%.*]]
+// CHECK:   fpclassify_end:
+// CHECK-NEXT:[[FPCLASSIFY_RESULT:%.*]] = phi i32 [ 4, [[ENTRY:%.*]] ], [ 0, [[FPCLASSIFY_NOT_ZERO]] ], [ 1, [[FPCLASSIFY_NOT_NAN:%.*]] ], [ [[TMP2:%.*]], [[FPCLASSIFY_NOT_INF:%.*]] ]
+// CHECK-NEXT:call void @p(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 [[FPCLASSIFY_RESULT]]) [[ATTR4]]
+// CHECK-NEXT:ret void
+// CHECK:   fpclassify_not_zero:
+// CHECK-NEXT:[[CMP:%.*]] = call i1 @llvm.experimental.constrained.fcmp.f64(double [[TMP0]], double [[TMP0]], metadata !"uno", metadata !"fpexcept.strict") [[ATTR4]]
+// CHECK-NEXT:br i1 [[CMP]], label [[FPCLASSIFY_END]], label [[FPCLASSIFY_NOT_NAN]]
+// CHECK:   fpclassify_not_nan:
+// CHECK-NEXT:[[TMP1:%.*]] = call double @llvm.fabs.f64(double [[TMP0]]) [[ATTR5:#.*]]
+// CHECK-NEXT:[[ISINF:%.*]] = call i1 @llvm.experimental.constrained.fcmp.f64(double [[TMP1]], double 0x7FF0, metadata !"oeq", metadata !"fpexcept.strict") [[ATTR4]]
+// CHECK-NEXT:br i1 [[ISINF]], label [[FPCLASSIFY_END]], label [[FPCLASSIFY_NOT_INF]]
+// CHECK:   fpclassify_not_inf:
+// CHECK-NEXT:[[ISNORMAL:%.*]] = call i1 @llvm.experimental.constrained.fcmp.f64(double [[TMP1]], double 0x10, metadata !"uge", metadata !"fpexcept.strict") [[ATTR4]]
+// CHECK-NEXT:[[TMP2]] = select i1 [[ISNORMAL]], i32 2, i32 3
+// CHECK-NEXT:br label [[FPCLASSIFY_END]]
+//
+void test_fpclassify(double d) {
+  P(fpclassify, (0, 1, 2, 3, 4, d));
+
+  return;
+}
+
+// CHECK-LABEL: @test_isinf(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[D_ADDR:%.*]] = alloca double, align 8
+// CHECK-NEXT:store double [[D:%.*]], double* [[D_ADDR]], align 8
+// CHECK-NEXT:[[TMP0:%.*]] = load double, double* [[D_ADDR]], align 8
+// CHECK-NEXT:[[TMP1:%.*]] = call double @llvm.fabs.f64(double [[TMP0]]) [[ATTR5]]
+// CHECK-NEXT:[[CMPINF:%.*]] = call i1 @llvm.experimental.constrained.fcmp.f64(double [[TMP1]], double 0x7FF0, metadata !"oeq", metadata !"fpexcept.strict") [[ATTR4]]
+// CHECK-NEXT:[[TMP2:%.*]] = zext i1 [[CMPINF]] to i32
+// CHECK-NEXT:call void @p(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 [[TMP2]]) [[ATTR4]]
+// CHECK-NEXT:ret void
+//
+void test_isinf(double d) {
+  P(isinf, (d));
+
+  return;
+}
+
+// CHECK-LABEL: @test_isinf_sign(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[D_ADDR:%.*]] = a

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

2020-11-12 Thread Kevin P. Neal via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGac523d2de51c: [FPEnv][Clang][Driver] Use MarshallingInfoFlag 
for -fexperimental-strict… (authored by kpn).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88987/new/

https://reviews.llvm.org/D88987

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


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3335,9 +3335,6 @@
   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;
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1308,7 +1308,8 @@
   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]>,


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3335,9 +3335,6 @@
   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;
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1308,7 +1308,8 @@
   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]>,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2020-11-11 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn updated this revision to Diff 304557.
kpn added a comment.

Update for review comments.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88987/new/

https://reviews.llvm.org/D88987

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


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3334,9 +3334,6 @@
   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;
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1307,7 +1307,8 @@
   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]>,


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3334,9 +3334,6 @@
   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;
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1307,7 +1307,8 @@
   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]>,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2020-11-11 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added a comment.

No worries!

The option does already have tests that verify correct operation.




Comment at: clang/include/clang/Driver/Options.td:1286
+  HelpText<"Enables experimental strict floating point in LLVM.">,
+  MarshallingInfoFlag<"LangOpts->ExpStrictFP", "false">;
 def finput_charset_EQ : Joined<["-"], "finput-charset=">, Group;

jansvoboda11 wrote:
> In D82756, we've replaced the "default value" argument with a list of options 
> that can imply the current flag. If empty or omitted, we set the default 
> value to `false` automatically. Could you please remove the `"false"` 
> argument?
Will do.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88987/new/

https://reviews.llvm.org/D88987

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


[PATCH] D90921: [Clang][AArch64] Remove unused prefix in constrained rounding test

2020-11-06 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn accepted this revision.
kpn added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D90921/new/

https://reviews.llvm.org/D90921

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


[PATCH] D88913: [FPEnv] Use strictfp metadata in casting nodes

2020-11-04 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added a comment.

Update for review comments.




Comment at: clang/test/CodeGen/builtin_float_strictfp.c:1
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-windows-pc 
-ffp-exception-behavior=maytrap -o - %s | FileCheck %s 
--check-prefixes=CHECK,FP16
+// RUN: %clang_cc1 -emit-llvm -triple ppc64-be -ffp-exception-behavior=maytrap 
-o - %s | FileCheck %s --check-prefixes=CHECK,NOFP16

sepavloff wrote:
> Part of this test, namely functions `test_floats`, `test_doubles` and 
> `tests_halves` must pass on unpatched compiler, because they don't contain 
> conversion nodes. Maybe they can be extracted into separate patch, on which 
> this one would depend? 
I deleted `test_floats` and `test_doubles` because of that lack of conversion 
nodes. But `test_half` does have implicit conversions and I added checks for 
more of them.



Comment at: clang/test/CodeGen/complex-math-strictfp.c:1
+// RUN: %clang_cc1 %s -ffp-exception-behavior=maytrap -O0 -emit-llvm -triple 
x86_64-unknown-unknown -o - | FileCheck %s --check-prefix=X86
+

sepavloff wrote:
> Throughout this test the only operation that involves complex is construction 
> of complex value from real part. It does not use any conversion node, so this 
> test must with unpatched compiler.
That's valid. The conversion from float to "_Complex float" does get an 
ImplicitCastExpr, but it shouldn't result in constrained intrinsics. So the 
test isn't needed. I'll nuke it.



Comment at: clang/test/CodeGen/complex-strictfp.c:92-95
+  double _Complex a = 5;
+  double _Complex b = 42;
+
+  return a * b != b * a;

sepavloff wrote:
> This function generated complicated code, which is hard to check and easy to 
> break. Can this function be split into smaller functions which would test 
> only one operation? It could allow to use more compact checks. I think these 
> tests should pass on unpatched compiler.
I'll pull this out and put it in a subsequent patch. It shows we have work to 
do, but isn't needed for this patch.



Comment at: clang/test/CodeGen/complex-strictfp.c:131
+//
+void test2(int c) {
+  _Complex double X;

sepavloff wrote:
> This function does not produce constrained intrinsics at all.
Eliminated



Comment at: clang/test/CodeGen/complex-strictfp.c:239
+//
+void test3() {
+  g1 = g1 + g2;

sepavloff wrote:
> Can it be split into smaller functions?
Sure, can do.



Comment at: clang/test/CodeGen/complex-strictfp.c:397
+void t3() {
+  __complex__ long long v = 2;
+}

sepavloff wrote:
> Integer-only arithmetic.
Eliminated



Comment at: clang/test/CodeGen/complex-strictfp.c:421
+void t5() {
+  float _Complex x = t4();
+}

sepavloff wrote:
> No floating point operations, only moves.
Eliminated



Comment at: clang/test/CodeGen/complex-strictfp.c:469-472
+  g1++;
+  g1--;
+  ++g1;
+  --g1;

sepavloff wrote:
> Only these operations involve FP operations, but none produces constrained 
> intrinsics. And they don't produce cast nodes. Besides, these inc/dec 
> operations are represented in IR as add/sub, does it makes sense to test them 
> separately?
Yes, a separate patch for those would be better.



Comment at: clang/test/CodeGen/exprs-strictfp.c:1
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -emit-llvm -o - | 
FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s 
-ffp-exception-behavior=maytrap -emit-llvm -o - | FileCheck %s

kpn wrote:
> sepavloff wrote:
> > No FP casts.
> There's an implied cast in the AST, and I'm pretty sure the bits from that 
> are used when simplifying this into the fcmp. I'll doublecheck.
Confirmed. In `CodeGenFunction::EvaluateExprAsBool()` we set the constrained 
metadata and then call down eventually to 
`ScalarExprEmitter::EmitFloatToBoolConversion()`.

The node we get the metadata from is a "`ImplicitCastExpr 0x80fe2b338 'double' 
 FPExceptionMode=2`".



Comment at: clang/test/CodeGen/incdec-strictfp.c:22
+
+  printf("%lf %lf\n", A, B);
+}

sepavloff wrote:
> This line and corresponding function declaration seem unnecessary?
This whole test is better left to a subsequent patch. It's another holdover 
from my previous attempt at the code changes.



Comment at: clang/test/CodeGen/ubsan-conditional-strictfp.c:1
+// RUN: %clang_cc1 %s -triple x86_64-unknown-unknown 
-ffp-exception-behavior=maytrap -emit-llvm -fsanitize=float-divide-by-zero -o - 
| FileCheck %s
+

kpn wrote:
> sepavloff wrote:
> > What is the effect of `-fsanitize=float-divide-by-zero`? If it absents does 
> > the test change behavior?
> An earlier version of this patch did try passing bits all the way down to the 
> calls to the IRBuilder. In this version of the patch the sanitizer was 
> require

[PATCH] D88913: [FPEnv] Use strictfp metadata in casting nodes

2020-10-30 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added a comment.

I'll see how much I can simplify of the tests.




Comment at: clang/test/CodeGen/exprs-strictfp.c:1
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s -emit-llvm -o - | 
FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown %s 
-ffp-exception-behavior=maytrap -emit-llvm -o - | FileCheck %s

sepavloff wrote:
> No FP casts.
There's an implied cast in the AST, and I'm pretty sure the bits from that are 
used when simplifying this into the fcmp. I'll doublecheck.



Comment at: clang/test/CodeGen/ubsan-conditional-strictfp.c:1
+// RUN: %clang_cc1 %s -triple x86_64-unknown-unknown 
-ffp-exception-behavior=maytrap -emit-llvm -fsanitize=float-divide-by-zero -o - 
| FileCheck %s
+

sepavloff wrote:
> What is the effect of `-fsanitize=float-divide-by-zero`? If it absents does 
> the test change behavior?
An earlier version of this patch did try passing bits all the way down to the 
calls to the IRBuilder. In this version of the patch the sanitizer was required 
to be involved to test one of the places that was changed. I had 100% test 
coverage for that version of the code.

I'll check and see if it is still needed.



Comment at: clang/test/CodeGen/zvector-strictfp.c:9-23
+volatile vector signed char sc, sc2;
+volatile vector unsigned char uc, uc2;
+volatile vector bool char bc, bc2;
+
+volatile vector signed short ss, ss2;
+volatile vector unsigned short us, us2;
+volatile vector bool short bs, bs2;

sepavloff wrote:
> These are integer values, they cannot produce constrained intrinsics. Why 
> they are tested here?
This test is also a holdover from the first version of the patch. It was also 
needed to achieve 100% test coverage with that first version. I'll check and 
see if it is still needed in this v2 version of the patch.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88913/new/

https://reviews.llvm.org/D88913

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


[PATCH] D90316: [FPEnv] Diagnose pragmas FENV_ROUND,_ACCESS and float_control if target does not support StrictFP

2020-10-28 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added a comment.

I also added "-fexperimental-strict-floating-point" which makes it possible to 
write tests for a target when bringing up the support on that target. I think 
it would be confusing for that flag to work on command line arguments but not 
pragmas.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D90316/new/

https://reviews.llvm.org/D90316

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


[PATCH] D88913: [FPEnv] Use strictfp metadata in casting nodes

2020-10-27 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added a comment.

In D88913#2353379 , @sepavloff wrote:

> Generally the patch looks good. But the need to expect incorrect values in 
> tests is a concern. Maybe this is a consequence of storing exception behavior 
> in a separate field of CGFPOptionsRAII. This misbehavior should be fixed.

In this patch? Because that's going to be a huge patch. Fixing all the issues 
with strictfp AST->IRBuilder is going to be large. Fixing them incrementally 
seems better to me. Eliminating the incorrect values in the tests marked FIXME 
would sweep the problem under the rug.

It's true that incorrect values in tests is _not_ the desired end state. But it 
seems to me that as a _temporary_ incremental step it beats the alternatives.




Comment at: clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c:26
+// metadata from the AST instead of the global default from the command line.
+// FIXME: All cases of "fpexcept.maytrap" in this test are wrong.
+

sepavloff wrote:
> kpn wrote:
> > kpn wrote:
> > > sepavloff wrote:
> > > > kpn wrote:
> > > > > sepavloff wrote:
> > > > > > Why they are wrong?
> > > > > Because the #pragma covers the entire file and sets exception 
> > > > > handling to "strict". Thus all constrained intrinsic calls should be 
> > > > > "strict", and if they are "maytrap" or "ignore" then we have a bug.
> > > > What is the reason for that? Does `#pragma float_control` work 
> > > > incorrectly? Why  in `clang/test/CodeGen/complex-math-strictfp.c` 
> > > > exception handling is correct?
> > > The #pragma works just fine. The problem is that we need to get the 
> > > strictfp bits from the AST to the IRBuilder, and we haven't finished 
> > > implementing that. So sometimes it works, like in 
> > > complex-math-strictfp.c, and sometimes it doesn't. As you can see in the 
> > > tests in this patch.
> > I forgot to mention that complex-math-strictfp.c gets a correct BinOpInfo 
> > passed down to get the IRBuilder set correctly. But there are other places 
> > that don't correctly set BinOpInfo and so we get inconsistent behavior 
> > despite the call to the IRBuilder being wrapped in FPOptsRAII. And _that's_ 
> > why I structured this patch the way I did.
> > The problem is that we need to get the strictfp bits from the AST to the 
> > IRBuilder
> 
> What is the status of this problem? Is it on track?
This is a larger problem that we need to tackle incrementally. I'd like to get 
a signoff on the approach taken in this patch before going too far down the 
road of writing fixes for all the issues we have here. But it is at the top of 
my list.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88913/new/

https://reviews.llvm.org/D88913

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


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

2020-10-26 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88987/new/

https://reviews.llvm.org/D88987

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


[PATCH] D88913: [FPEnv] Use strictfp metadata in casting nodes

2020-10-23 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added inline comments.



Comment at: clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c:26
+// metadata from the AST instead of the global default from the command line.
+// FIXME: All cases of "fpexcept.maytrap" in this test are wrong.
+

kpn wrote:
> sepavloff wrote:
> > kpn wrote:
> > > sepavloff wrote:
> > > > Why they are wrong?
> > > Because the #pragma covers the entire file and sets exception handling to 
> > > "strict". Thus all constrained intrinsic calls should be "strict", and if 
> > > they are "maytrap" or "ignore" then we have a bug.
> > What is the reason for that? Does `#pragma float_control` work incorrectly? 
> > Why  in `clang/test/CodeGen/complex-math-strictfp.c` exception handling is 
> > correct?
> The #pragma works just fine. The problem is that we need to get the strictfp 
> bits from the AST to the IRBuilder, and we haven't finished implementing 
> that. So sometimes it works, like in complex-math-strictfp.c, and sometimes 
> it doesn't. As you can see in the tests in this patch.
I forgot to mention that complex-math-strictfp.c gets a correct BinOpInfo 
passed down to get the IRBuilder set correctly. But there are other places that 
don't correctly set BinOpInfo and so we get inconsistent behavior despite the 
call to the IRBuilder being wrapped in FPOptsRAII. And _that's_ why I 
structured this patch the way I did.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88913/new/

https://reviews.llvm.org/D88913

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


[PATCH] D88913: [FPEnv] Use strictfp metadata in casting nodes

2020-10-23 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added inline comments.



Comment at: clang/lib/CodeGen/CodeGenFunction.cpp:154-155
+  OldRounding = CGF.Builder.getDefaultConstrainedRounding();
   if (OldFPFeatures == FPFeatures)
 return;
 

sepavloff wrote:
> This check can be lifted to just after the definition of `OldFPFeatures`.
Actually, no, because this leaves OldExcept and OldRounding uninitialized when 
they get used by the destructor.



Comment at: clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c:26
+// metadata from the AST instead of the global default from the command line.
+// FIXME: All cases of "fpexcept.maytrap" in this test are wrong.
+

sepavloff wrote:
> kpn wrote:
> > sepavloff wrote:
> > > Why they are wrong?
> > Because the #pragma covers the entire file and sets exception handling to 
> > "strict". Thus all constrained intrinsic calls should be "strict", and if 
> > they are "maytrap" or "ignore" then we have a bug.
> What is the reason for that? Does `#pragma float_control` work incorrectly? 
> Why  in `clang/test/CodeGen/complex-math-strictfp.c` exception handling is 
> correct?
The #pragma works just fine. The problem is that we need to get the strictfp 
bits from the AST to the IRBuilder, and we haven't finished implementing that. 
So sometimes it works, like in complex-math-strictfp.c, and sometimes it 
doesn't. As you can see in the tests in this patch.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88913/new/

https://reviews.llvm.org/D88913

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


[PATCH] D88913: [FPEnv] Use strictfp metadata in casting nodes

2020-10-13 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added inline comments.



Comment at: clang/lib/CodeGen/CodeGenFunction.h:618-619
 FPOptions OldFPFeatures;
+llvm::fp::ExceptionBehavior OldExcept;
+llvm::RoundingMode OldRounding;
 Optional FMFGuard;

sepavloff wrote:
> Is it possible to merge this variables into `OldFPFeatures`? In what cases 
> state of `Builder` may differ from the state of `CGF.CurFPFeatures`?
Without this patch they will differ if the AST changes CGF.CurFPFeatures and 
the Builder hasn't been updated yet. Say, because we're going back up the tree.

The concern is that we'll miss places that need to be updated to respect the 
AST. But if we don't make a point of resetting the Builder then we'll end up 
with stale data in the Builder that "just happens" to work. We need tests to 
actually test what they are supposed to test without relying on stale data.

The comments in the tests about "maytrap" being wrong show us that we 
absolutely have exactly this bug in multiple places. The Builder isn't getting 
properly updated and this change makes that visible and clear.



Comment at: clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c:6
 // RUN: %clang_cc1 -triple arm64-none-linux-gnu -target-feature +neon 
-target-feature +fullfp16 -target-feature +v8.2a\
-// RUN: -ffp-exception-behavior=strict \
+// RUN: -ffp-exception-behavior=maytrap -DEXCEPT=1 \
 // RUN: -fexperimental-strict-floating-point \

sepavloff wrote:
> Why did you change exception behavior to `maytrap`?
Because "maytrap" is not the IRBuilder's default of "strict" and it isn't 
clang's default of "ignore".

The #pragma sets the exception handling to "strict". Having the command line 
arguments set a global "maytrap" with a #pragma that sets it to "strict" at the 
top of the file means that places in clang that need to be updated will become 
visible.



Comment at: clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c:26
+// metadata from the AST instead of the global default from the command line.
+// FIXME: All cases of "fpexcept.maytrap" in this test are wrong.
+

sepavloff wrote:
> Why they are wrong?
Because the #pragma covers the entire file and sets exception handling to 
"strict". Thus all constrained intrinsic calls should be "strict", and if they 
are "maytrap" or "ignore" then we have a bug.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88913/new/

https://reviews.llvm.org/D88913

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


[PATCH] D88913: [FPEnv] Use strictfp metadata in casting nodes

2020-10-08 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added inline comments.



Comment at: clang/lib/CodeGen/CodeGenFunction.cpp:139
+
+  switch (E->getStmtClass()) {
+  case Stmt::UnaryOperatorClass: {

sepavloff wrote:
> Actually this is not correct, because subclass relations are not preserved in 
> this case. For instance, `CompounsAssignmentOperator` is not handled, as it 
> does not return `BinaryOperatorClass`.
> 
> I would recommend using `Expr::getFPFeaturesInEffect` or adding similar 
> method.
That's much cleaner. Sorry I missed that earlier.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88913/new/

https://reviews.llvm.org/D88913

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


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

2020-10-07 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn created this revision.
kpn added a reviewer: dang.
kpn added a project: clang.
Herald added subscribers: cfe-commits, dexonsmith.
kpn requested review of this revision.

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.

The previous tests continue to work correctly so I haven't included a new one 
here. I can if needed, but I would need guidance since I don't know what would 
need to be tested.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D88987

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


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3309,9 +3309,6 @@
   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;
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1282,7 +1282,8 @@
   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", "false">;
 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]>,


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3309,9 +3309,6 @@
   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;
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1282,7 +1282,8 @@
   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", "false">;
 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]>,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D85920: [FPEnv][AST] WIP!!! For casts, keep FP options in trailing storage of CastExpr

2020-09-22 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn abandoned this revision.
kpn added a comment.

Unneeded since D85960  landed.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85920/new/

https://reviews.llvm.org/D85920

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


[PATCH] D69272: Enable '#pragma STDC FENV_ACCESS' in frontend

2020-09-11 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added a comment.

Say, in D80952  I added support for disabling 
strictfp support when a target doesn't support it. But it only applies to 
command line arguments.

Is there any chance at all that relevant pragmas can also be disabled with the 
warning in the same cases?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69272/new/

https://reviews.llvm.org/D69272

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


[PATCH] D85920: [FPEnv][AST] WIP!!! For casts, keep FP options in trailing storage of CastExpr

2020-08-17 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn planned changes to this revision.
kpn added a comment.

It would be better to go with D85960 . I'll 
hedge and keep this open until that one gets pushed.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85920/new/

https://reviews.llvm.org/D85920

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


[PATCH] D85960: [AST][FPEnv] Keep FP options in trailing storage of CastExpr

2020-08-14 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added a comment.

You mentioned in D85920  a need to merge this 
review with that review. I don't think that's needed. This code here is farther 
along. It does everything that D85920  does 
and has necessary pieces implemented as well.

I think this ticket should go into the tree instead of D85920 
. I'd sign off on it this minute if I had more 
experience in clang.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85960/new/

https://reviews.llvm.org/D85960

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


[PATCH] D85920: [FPEnv][AST] WIP!!! For casts, keep FP options in trailing storage of CastExpr

2020-08-13 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn created this revision.
kpn added reviewers: rjmccall, mibintc, shafik, sepavloff.
kpn added a project: clang.
Herald added subscribers: cfe-commits, jfb, martong.
kpn requested review of this revision.

This change allows FP options to be in the trailing storage of CastExpr. Needed 
for proper emitting of uitofp/sitofp later. The implementation is based on 
BinaryOperator and CallExpr.

THIS IS A WORK IN PROGRESS. I'm opening this now to get feedback on my 
understanding of how the cast classes are used. I'm not sure I have it correct 
and would appreciate more knowledgeable eyes on it.

Tests are still needed,  Sema needs work, a number of other pieces are missing. 
Notes to myself need to be removed, etc.

Also, I've included as much context as I could. There's a 2MB limit on patches 
so I squeeked in under the wire with 1.9MB.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85920

Files:
  clang/include/clang/AST/Expr.h
  clang/include/clang/AST/ExprCXX.h
  clang/include/clang/AST/ExprObjC.h
  clang/include/clang/AST/Stmt.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprCXX.cpp
  clang/lib/Analysis/BodyFarm.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
  clang/lib/Frontend/Rewrite/RewriteObjC.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaCast.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaExprObjC.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/SemaObjCProperty.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Serialization/ASTReaderStmt.cpp

Index: clang/lib/Serialization/ASTReaderStmt.cpp
===
--- clang/lib/Serialization/ASTReaderStmt.cpp
+++ clang/lib/Serialization/ASTReaderStmt.cpp
@@ -2890,13 +2890,17 @@
   break;
 
 case EXPR_IMPLICIT_CAST:
-  S = ImplicitCastExpr::CreateEmpty(Context,
-   /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
+  S = ImplicitCastExpr::CreateEmpty(
+  Context,
+  /*PathSize*/ Record[ASTStmtReader::NumExprFields],
+  false); // XXXFIXME FPOptionsOverride
   break;
 
 case EXPR_CSTYLE_CAST:
-  S = CStyleCastExpr::CreateEmpty(Context,
-   /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
+  S = CStyleCastExpr::CreateEmpty(
+  Context,
+  /*PathSize*/ Record[ASTStmtReader::NumExprFields],
+  false); // XXXFIXME FPOptionsOverride
   break;
 
 case EXPR_COMPOUND_LITERAL:
@@ -3498,8 +3502,10 @@
   break;
 
 case EXPR_CXX_STATIC_CAST:
-  S = CXXStaticCastExpr::CreateEmpty(Context,
-   /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
+  S = CXXStaticCastExpr::CreateEmpty(
+  Context,
+  /*PathSize*/ Record[ASTStmtReader::NumExprFields],
+  false); // XXXFIXME FPOptionsOverride
   break;
 
 case EXPR_CXX_DYNAMIC_CAST:
@@ -3521,8 +3527,10 @@
   break;
 
 case EXPR_CXX_FUNCTIONAL_CAST:
-  S = CXXFunctionalCastExpr::CreateEmpty(Context,
-   /*PathSize*/ Record[ASTStmtReader::NumExprFields]);
+  S = CXXFunctionalCastExpr::CreateEmpty(
+  Context,
+  /*PathSize*/ Record[ASTStmtReader::NumExprFields],
+  false); // XXXFIXME FPOptionsOverride
   break;
 
 case EXPR_BUILTIN_BIT_CAST:
Index: clang/lib/Sema/SemaTemplate.cpp
===
--- clang/lib/Sema/SemaTemplate.cpp
+++ clang/lib/Sema/SemaTemplate.cpp
@@ -7478,7 +7478,7 @@
 // FIXME: This is a hack. We need a better way to handle substituted
 // non-type template parameters.
 E = CStyleCastExpr::Create(Context, OrigT, VK_RValue, CK_IntegralCast, E,
-   nullptr,
+   nullptr, FPOptionsOverride(), // XXXFIXME
Context.getTrivialTypeSourceInfo(OrigT, Loc),
Loc, Loc);
   }
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -3139,7 +3139,8 @@
 // Promote "AsRvalue" to the heap, since we now need this
 // expression node to persist.
 Value = ImplicitCastExpr::Create(S.Context, Value->getType(), CK_NoOp,
- Value, nullptr, VK_XValue);
+ Value, nullptr, FPOptionsOverride(),
+ VK_XValue); // XXXFIXME
 
 // Complete type-checking the initialization of the return type
 // using the constructor we found.
Index: clang/lib/Sema/SemaOverload.cpp

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

2020-07-10 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn marked an inline comment as done.
kpn added inline comments.



Comment at: clang/include/clang/Driver/Options.td:1246
   HelpText<"Enables an experimental new pass manager in LLVM.">;
+def fexperimental_strict_floating_point : Flag<["-"], 
"fexperimental-strict-floating-point">,
+  Group, Flags<[CC1Option]>,

dang wrote:
> A bit late to the party, but can you mark this as 
> `MarshallingInfoFlag<"LangOpts->ExpStrictFP", "false>` so that `if 
> (Args.hasArg(OPT_fexperimental_strict_floating_point)) Opts.ExpStrictFP = 
> true;` in CompilerInvocation.cpp gets generated automatically, we also get 
> serializing the option for free this way.
Assuming this patch makes it to the afternoon, how about I open a new review 
for this?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80952/new/

https://reviews.llvm.org/D80952



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


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

2020-07-10 Thread Kevin P. Neal via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd4ce862f2aa8: Reland "[FPEnv][Clang][Driver] Disable 
constrained floating point on targets… (authored by kpn).
Herald added a reviewer: dang.

Changed prior to commit:
  https://reviews.llvm.org/D80952?vs=276166&id=277004#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80952/new/

https://reviews.llvm.org/D80952

Files:
  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/fp-strictfp-exp.cpp
  clang/test/CodeGen/fp-strictfp.cpp
  clang/test/CodeGen/fpconstrained-cmp-double.c
  clang/test/CodeGen/fpconstrained-cmp-float.c
  clang/test/CodeGen/fpconstrained.c
  clang/test/CodeGen/fpconstrained.cpp

Index: clang/test/CodeGen/fpconstrained.cpp
===
--- clang/test/CodeGen/fpconstrained.cpp
+++ clang/test/CodeGen/fpconstrained.cpp
@@ -1,10 +1,11 @@
-// RUN: %clang_cc1 -x c++ -ftrapping-math -fexceptions -fcxx-exceptions -frounding-math -ffp-exception-behavior=strict -emit-llvm -o - %s | FileCheck %s -check-prefix=FPMODELSTRICT
+// RUN: %clang_cc1 -x c++ -ftrapping-math -fexceptions -fcxx-exceptions -frounding-math -ffp-exception-behavior=strict -fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s -check-prefix=FPMODELSTRICT
 // RUN: %clang_cc1 -x c++ -ffp-contract=fast -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck %s -check-prefix=PRECISE
 // RUN: %clang_cc1 -x c++ -ffast-math -fexceptions -fcxx-exceptions -ffp-contract=fast -emit-llvm -o - %s | FileCheck %s -check-prefix=FAST
 // RUN: %clang_cc1 -x c++ -ffast-math -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck %s -check-prefix=FASTNOCONTRACT
 // 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
+// RUN: %clang_cc1 -x c++ -ffast-math -fexceptions -fcxx-exceptions -ffp-contract=fast -ffp-exception-behavior=strict -fexperimental-strict-floating-point -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 -fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s -check-prefix=MAYTRAP
+
 float f0, f1, f2;
 
   template 
Index: clang/test/CodeGen/fpconstrained.c
===
--- clang/test/CodeGen/fpconstrained.c
+++ clang/test/CodeGen/fpconstrained.c
@@ -1,10 +1,11 @@
-// RUN: %clang_cc1 -ftrapping-math -frounding-math -ffp-exception-behavior=strict -emit-llvm -o - %s | FileCheck %s -check-prefix=FPMODELSTRICT
+// RUN: %clang_cc1 -ftrapping-math -frounding-math -ffp-exception-behavior=strict -fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s -check-prefix=FPMODELSTRICT
 // RUN: %clang_cc1 -ffp-contract=fast -emit-llvm -o - %s | FileCheck %s -check-prefix=PRECISE
 // RUN: %clang_cc1 -ffast-math -ffp-contract=fast -emit-llvm -o - %s | FileCheck %s -check-prefix=FAST
 // RUN: %clang_cc1 -ffast-math -emit-llvm -o - %s | FileCheck %s -check-prefix=FASTNOCONTRACT
 // 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
+// RUN: %clang_cc1 -ffast-math -ffp-contract=fast -ffp-exception-behavior=strict -fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s -check-prefix=EXCEPT
+// RUN: %clang_cc1 

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

2020-07-09 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn marked 3 inline comments as done.
kpn added a comment.

Thanks for the reviews and the fast turnaround! I do appreciate it!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80952/new/

https://reviews.llvm.org/D80952



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


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

2020-07-07 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn updated this revision to Diff 276166.
kpn added a comment.

Add the -fexperimental-strict-floating-point flag to enable on hosts that are 
not marked as supporting strict FP yet. Add test and documentation.

Update tests to use the new flag. This eliminates the XFAIL lines and should 
keep the tests running like before.

Hopefully this will work for 11.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80952/new/

https://reviews.llvm.org/D80952

Files:
  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/fp-strictfp-exp.cpp
  clang/test/CodeGen/fp-strictfp.cpp
  clang/test/CodeGen/fpconstrained-cmp-double.c
  clang/test/CodeGen/fpconstrained-cmp-float.c
  clang/test/CodeGen/fpconstrained.c
  clang/test/CodeGen/fpconstrained.cpp

Index: clang/test/CodeGen/fpconstrained.cpp
===
--- clang/test/CodeGen/fpconstrained.cpp
+++ clang/test/CodeGen/fpconstrained.cpp
@@ -1,10 +1,11 @@
-// RUN: %clang_cc1 -x c++ -ftrapping-math -fexceptions -fcxx-exceptions -frounding-math -ffp-exception-behavior=strict -emit-llvm -o - %s | FileCheck %s -check-prefix=FPMODELSTRICT
+// RUN: %clang_cc1 -x c++ -ftrapping-math -fexceptions -fcxx-exceptions -frounding-math -ffp-exception-behavior=strict -fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s -check-prefix=FPMODELSTRICT
 // RUN: %clang_cc1 -x c++ -ffp-contract=fast -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck %s -check-prefix=PRECISE
 // RUN: %clang_cc1 -x c++ -ffast-math -fexceptions -fcxx-exceptions -ffp-contract=fast -emit-llvm -o - %s | FileCheck %s -check-prefix=FAST
 // RUN: %clang_cc1 -x c++ -ffast-math -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck %s -check-prefix=FASTNOCONTRACT
 // 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
+// RUN: %clang_cc1 -x c++ -ffast-math -fexceptions -fcxx-exceptions -ffp-contract=fast -ffp-exception-behavior=strict -fexperimental-strict-floating-point -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 -fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s -check-prefix=MAYTRAP
+
 float f0, f1, f2;
 
   template 
Index: clang/test/CodeGen/fpconstrained.c
===
--- clang/test/CodeGen/fpconstrained.c
+++ clang/test/CodeGen/fpconstrained.c
@@ -1,10 +1,11 @@
-// RUN: %clang_cc1 -ftrapping-math -frounding-math -ffp-exception-behavior=strict -emit-llvm -o - %s | FileCheck %s -check-prefix=FPMODELSTRICT
+// RUN: %clang_cc1 -ftrapping-math -frounding-math -ffp-exception-behavior=strict -fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s -check-prefix=FPMODELSTRICT
 // RUN: %clang_cc1 -ffp-contract=fast -emit-llvm -o - %s | FileCheck %s -check-prefix=PRECISE
 // RUN: %clang_cc1 -ffast-math -ffp-contract=fast -emit-llvm -o - %s | FileCheck %s -check-prefix=FAST
 // RUN: %clang_cc1 -ffast-math -emit-llvm -o - %s | FileCheck %s -check-prefix=FASTNOCONTRACT
 // 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
+// RUN: %clang_cc1 -ffast-math -ffp-contract=fast -ffp-exception-behavior=strict -fexperimental-strict-floating-point -emit-llvm -o - %s | FileCheck %s -check-prefix=EXCEPT
+// RUN: %clang_cc

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

2020-07-07 Thread Kevin P. Neal via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG39d2ae0afb23: [FPEnv][Clang][Driver] Disable constrained 
floating point on targets lacking… (authored by kpn).

Changed prior to commit:
  https://reviews.llvm.org/D80952?vs=272530&id=275620#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80952/new/

https://reviews.llvm.org/D80952

Files:
  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/fp-strictfp.cpp

Index: clang/test/CodeGen/fp-strictfp.cpp
===
--- /dev/null
+++ clang/test/CodeGen/fp-strictfp.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -triple mips64-linux-gnu -frounding-math -ffp-exception-behavior=strict -O2 -verify=rounding,exception -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple mips64-linux-gnu -ffp-exception-behavior=strict -O2 -verify=exception -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple mips64-linux-gnu -frounding-math -O2 -verify=rounding -emit-llvm -o - %s | FileCheck %s
+//
+// Verify that constrained intrinsics are not used.
+// As more targets gain support for constrained intrinsics the triple
+// in this test will need to change.
+
+// rounding-warning@* {{overriding currently unsupported rounding mode on this target}}
+// exception-warning@* {{overriding currently unsupported use of floating point exceptions on this target}}
+float fp_precise_1(float a, float b, float c) {
+// CHECK: _Z12fp_precise_1fff
+// CHECK: %[[M:.+]] = fmul float{{.*}}
+// CHECK: fadd float %[[M]], %c
+  return a * b + c;
+}
+
+
Index: clang/test/CodeGen/builtins-ppc-fpconstrained.c
===
--- clang/test/CodeGen/builtins-ppc-fpconstrained.c
+++ clang/test/CodeGen/builtins-ppc-fpconstrained.c
@@ -12,6 +12,9 @@
 // RUN: -o - %s | FileCheck --check-prefix=CHECK-ASM \
 // RUN: --check-prefix=FIXME-CHECK  %s
 
+// Disabled until constrained floating point is completed for PowerPC.
+// XFAIL: *
+
 typedef __attribute__((vector_size(4 * sizeof(float float vec_float;
 typedef __attribute__((vector_size(2 * sizeof(double double vec_double;
 
Index: clang/test/CodeGen/arm64-vrnd-constrained.c
===
--- clang/test/CodeGen/arm64-vrnd-constrained.c
+++ clang/test/CodeGen/arm64-vrnd-constrained.c
@@ -9,6 +9,9 @@
 
 // REQUIRES: aarch64-registered-target
 
+// Disabled until constrained floating point is implemented for arm64.
+// XFAIL: *
+
 #include 
 
 float64x2_t rnd5(float64x2_t a) { return vrndq_f64(a); }
Index: clang/test/CodeGen/arm-neon-directed-rounding-constrained.c
===
--- clang/test/CodeGen/arm-neon-directed-rounding-constrained.c
+++ clang/test/CodeGen/arm-neon-directed-rounding-constrained.c
@@ -32,6 +32,9 @@
 
 // REQUIRES: arm-registered-target,aarch64-registered-target
 
+// Disabled until constrained floating point is implemented for arm64.
+// XFAIL: *
+
 #include 
 
 // COMMON-LABEL: test_vrndi_f32
Index: clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c
===
--- clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c
+++ clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c
@@ -19,6 +19,9 @@
 
 // REQUIRES: aarch64-registered-target
 
+// Disabled until constrained floating point is implemented for arm64.
+// XFAIL: *
+
 #include 
 
 // COMMON-LABEL: test_vsqrt_f16
Index: clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem-constrained.c
===
--- clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem-constrained.c
+++ clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem-constrained.c
@@ -15,6 +15,9 @@
 
 // REQUIRES: aarch64-registered-target
 
+// Disabled until constrained floating point is implemented for arm64.
+// XFAIL: *
+
 // Test new aarch64 intrinsics and types but constrained
 
 #include 
Index: clang/test/CodeGen/aarch64-neon-misc-constrained.c
===
--- clang/test/CodeGen/aarch64-neon-misc-constrained.c
+++ clang/test/CodeGen/aarc

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

2020-07-06 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added a comment.

Already on it. I hope I got it now.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80952/new/

https://reviews.llvm.org/D80952



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


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

2020-07-06 Thread Kevin P. Neal via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG39d2ae0afb23: [FPEnv][Clang][Driver] Disable constrained 
floating point on targets lacking… (authored by kpn).

Changed prior to commit:
  https://reviews.llvm.org/D80952?vs=272530&id=275760#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80952/new/

https://reviews.llvm.org/D80952

Files:
  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/fp-strictfp.cpp

Index: clang/test/CodeGen/fp-strictfp.cpp
===
--- /dev/null
+++ clang/test/CodeGen/fp-strictfp.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -triple mips64-linux-gnu -frounding-math -ffp-exception-behavior=strict -O2 -verify=rounding,exception -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple mips64-linux-gnu -ffp-exception-behavior=strict -O2 -verify=exception -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple mips64-linux-gnu -frounding-math -O2 -verify=rounding -emit-llvm -o - %s | FileCheck %s
+//
+// Verify that constrained intrinsics are not used.
+// As more targets gain support for constrained intrinsics the triple
+// in this test will need to change.
+
+// rounding-warning@* {{overriding currently unsupported rounding mode on this target}}
+// exception-warning@* {{overriding currently unsupported use of floating point exceptions on this target}}
+float fp_precise_1(float a, float b, float c) {
+// CHECK: _Z12fp_precise_1fff
+// CHECK: %[[M:.+]] = fmul float{{.*}}
+// CHECK: fadd float %[[M]], %c
+  return a * b + c;
+}
+
+
Index: clang/test/CodeGen/builtins-ppc-fpconstrained.c
===
--- clang/test/CodeGen/builtins-ppc-fpconstrained.c
+++ clang/test/CodeGen/builtins-ppc-fpconstrained.c
@@ -12,6 +12,9 @@
 // RUN: -o - %s | FileCheck --check-prefix=CHECK-ASM \
 // RUN: --check-prefix=FIXME-CHECK  %s
 
+// Disabled until constrained floating point is completed for PowerPC.
+// XFAIL: *
+
 typedef __attribute__((vector_size(4 * sizeof(float float vec_float;
 typedef __attribute__((vector_size(2 * sizeof(double double vec_double;
 
Index: clang/test/CodeGen/arm64-vrnd-constrained.c
===
--- clang/test/CodeGen/arm64-vrnd-constrained.c
+++ clang/test/CodeGen/arm64-vrnd-constrained.c
@@ -9,6 +9,9 @@
 
 // REQUIRES: aarch64-registered-target
 
+// Disabled until constrained floating point is implemented for arm64.
+// XFAIL: *
+
 #include 
 
 float64x2_t rnd5(float64x2_t a) { return vrndq_f64(a); }
Index: clang/test/CodeGen/arm-neon-directed-rounding-constrained.c
===
--- clang/test/CodeGen/arm-neon-directed-rounding-constrained.c
+++ clang/test/CodeGen/arm-neon-directed-rounding-constrained.c
@@ -32,6 +32,9 @@
 
 // REQUIRES: arm-registered-target,aarch64-registered-target
 
+// Disabled until constrained floating point is implemented for arm64.
+// XFAIL: *
+
 #include 
 
 // COMMON-LABEL: test_vrndi_f32
Index: clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c
===
--- clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c
+++ clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c
@@ -19,6 +19,9 @@
 
 // REQUIRES: aarch64-registered-target
 
+// Disabled until constrained floating point is implemented for arm64.
+// XFAIL: *
+
 #include 
 
 // COMMON-LABEL: test_vsqrt_f16
Index: clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem-constrained.c
===
--- clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem-constrained.c
+++ clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem-constrained.c
@@ -15,6 +15,9 @@
 
 // REQUIRES: aarch64-registered-target
 
+// Disabled until constrained floating point is implemented for arm64.
+// XFAIL: *
+
 // Test new aarch64 intrinsics and types but constrained
 
 #include 
Index: clang/test/CodeGen/aarch64-neon-misc-constrained.c
===
--- clang/test/CodeGen/aarch64-neon-misc-constrained.c
+++ clang/test/CodeGen/aarc

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

2020-06-30 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added a comment.

Ping. I'm really hoping to get this into 11. Otherwise we're going multiple 
releases with options that people already use causing crashes on most 
architectures.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80952/new/

https://reviews.llvm.org/D80952



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


[PATCH] D82020: PowerPC-specific builtin constrained FP enablement

2020-06-25 Thread Kevin P. Neal via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG15edd7aaa714: [FPEnv] PowerPC-specific builtin constrained 
FP enablement (authored by ajwock, committed by kpn).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82020/new/

https://reviews.llvm.org/D82020

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-ppc-fpconstrained.c

Index: clang/test/CodeGen/builtins-ppc-fpconstrained.c
===
--- /dev/null
+++ clang/test/CodeGen/builtins-ppc-fpconstrained.c
@@ -0,0 +1,159 @@
+// REQUIRES: powerpc-registered-target
+// RUN: %clang_cc1 -triple powerpc64le-gnu-linux -target-feature +vsx \
+// RUN: -emit-llvm %s -o - | FileCheck --check-prefix=CHECK-UNCONSTRAINED %s
+// RUN: %clang_cc1 -triple powerpc64le-gnu-linux -target-feature +vsx \
+// RUN:  -ffp-exception-behavior=strict -emit-llvm %s -o - | FileCheck \
+// RUN: --check-prefix=CHECK-CONSTRAINED -vv %s
+// RUN: %clang_cc1 -triple powerpc64le-gnu-linux -target-feature +vsx \
+// RUN: -fallow-half-arguments-and-returns -S -o - %s | \
+// RUN: FileCheck --check-prefix=CHECK-ASM --check-prefix=NOT-FIXME-CHECK  %s
+// RUN: %clang_cc1 -triple powerpc64le-gnu-linux -target-feature +vsx \
+// RUN: -fallow-half-arguments-and-returns -S -ffp-exception-behavior=strict \
+// RUN: -o - %s | FileCheck --check-prefix=CHECK-ASM \
+// RUN: --check-prefix=FIXME-CHECK  %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_float(void) {
+  vf = __builtin_vsx_xvsqrtsp(vf);
+  // CHECK-LABEL: try-xvsqrtsp
+  // CHECK-UNCONSTRAINED: @llvm.sqrt.v4f32(<4 x float> %{{.*}})
+  // CHECK-CONSTRAINED: @llvm.experimental.constrained.sqrt.v4f32(<4 x float> %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
+  // CHECK-ASM: xvsqrtsp
+
+  vd = __builtin_vsx_xvsqrtdp(vd);
+  // CHECK-LABEL: try-xvsqrtdp
+  // CHECK-UNCONSTRAINED: @llvm.sqrt.v2f64(<2 x double> %{{.*}})
+  // CHECK-CONSTRAINED: @llvm.experimental.constrained.sqrt.v2f64(<2 x double> %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
+  // CHECK-ASM: xvsqrtdp
+
+  vf = __builtin_vsx_xvrspim(vf);
+  // CHECK-LABEL: try-xvrspim
+  // CHECK-UNCONSTRAINED: @llvm.floor.v4f32(<4 x float> %{{.*}})
+  // CHECK-CONSTRAINED: @llvm.experimental.constrained.floor.v4f32(<4 x float> %{{.*}}, metadata !"fpexcept.strict")
+  // CHECK-ASM: xvrspim
+
+  vd = __builtin_vsx_xvrdpim(vd);
+  // CHECK-LABEL: try-xvrdpim
+  // CHECK-UNCONSTRAINED: @llvm.floor.v2f64(<2 x double> %{{.*}})
+  // CHECK-CONSTRAINED: @llvm.experimental.constrained.floor.v2f64(<2 x double> %{{.*}}, metadata !"fpexcept.strict")
+  // CHECK-ASM: xvrdpim
+
+  vf = __builtin_vsx_xvrspi(vf);
+  // CHECK-LABEL: try-xvrspi
+  // CHECK-UNCONSTRAINED: @llvm.round.v4f32(<4 x float> %{{.*}})
+  // CHECK-CONSTRAINED: @llvm.experimental.constrained.round.v4f32(<4 x float> %{{.*}}, metadata !"fpexcept.strict")
+  // CHECK-ASM: xvrspi
+
+  vd = __builtin_vsx_xvrdpi(vd);
+  // CHECK-LABEL: try-xvrdpi
+  // CHECK-UNCONSTRAINED: @llvm.round.v2f64(<2 x double> %{{.*}})
+  // CHECK-CONSTRAINED: @llvm.experimental.constrained.round.v2f64(<2 x double> %{{.*}}, metadata !"fpexcept.strict")
+  // CHECK-ASM: xvrdpi
+
+  vf = __builtin_vsx_xvrspic(vf);
+  // CHECK-LABEL: try-xvrspic
+  // CHECK-UNCONSTRAINED: @llvm.nearbyint.v4f32(<4 x float> %{{.*}})
+  // CHECK-CONSTRAINED: @llvm.experimental.constrained.nearbyint.v4f32(<4 x float> %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
+  // CHECK-ASM: xvrspic
+
+  vd = __builtin_vsx_xvrdpic(vd);
+  // CHECK-LABEL: try-xvrdpic
+  // CHECK-UNCONSTRAINED: @llvm.nearbyint.v2f64(<2 x double> %{{.*}})
+  // CHECK-CONSTRAINED: @llvm.experimental.constrained.nearbyint.v2f64(<2 x double> %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
+  // CHECK-ASM: xvrdpic
+
+  vf = __builtin_vsx_xvrspip(vf);
+  // CHECK-LABEL: try-xvrspip
+  // CHECK-UNCONSTRAINED: @llvm.ceil.v4f32(<4 x float> %{{.*}})
+  // CHECK-CONSTRAINED: @llvm.experimental.constrained.ceil.v4f32(<4 x float> %{{.*}}, metadata !"fpexcept.strict")
+  // CHECK-ASM: xvrspip
+
+  vd = __builtin_vsx_xvrdpip(vd);
+  // CHECK-LABEL: try-xvrdpip
+  // CHECK-UNCONSTRAINED: @llvm.ceil.v2f64(<2 x double> %{{.*}})
+  // CHECK-CONSTRAINED: @llvm.experimental.constrained.ceil.v2f64(<2 x double> %{{.*}}, metadata !"fpexcept.strict")
+  // CHECK-ASM: xvrdpip
+
+  vf = __builtin_vsx_xvrspiz(vf);
+  // CHECK-LABEL: try-xvrspiz
+  // CHECK-UNCONSTRAINED: @llvm.trunc.v4f32(<4 x float> %{{.*}})
+  // CHECK-CONSTRAINED: @llvm.experimental.constrained.trunc.v4f32(<4 x float> %{{.*}}, metadata !"fpexcept.strict")
+  // CHECK-ASM: xvrspiz
+
+  vd = __builtin_vsx_xvrdpiz(vd);
+  // CHECK-LABEL: try-xvrdpiz
+  // CHECK-UNCONSTRAINED: @l

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

2020-06-22 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn updated this revision to Diff 272530.
kpn added a comment.

Remove debugging command left in accidentally. Rebase.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80952/new/

https://reviews.llvm.org/D80952

Files:
  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/PPC.h
  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/fp-strictfp.cpp

Index: clang/test/CodeGen/fp-strictfp.cpp
===
--- /dev/null
+++ clang/test/CodeGen/fp-strictfp.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -triple mips64-linux-gnu -frounding-math -ffp-exception-behavior=strict -O2 -verify=rounding,exception -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple mips64-linux-gnu -ffp-exception-behavior=strict -O2 -verify=exception -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple mips64-linux-gnu -frounding-math -O2 -verify=rounding -emit-llvm -o - %s | FileCheck %s
+//
+// Verify that constrained intrinsics are not used.
+// As more targets gain support for constrained intrinsics the triple
+// in this test will need to change.
+
+// rounding-warning@* {{overriding currently unsupported rounding mode on this target}}
+// exception-warning@* {{overriding currently unsupported use of floating point exceptions on this target}}
+float fp_precise_1(float a, float b, float c) {
+// CHECK: _Z12fp_precise_1fff
+// CHECK: %[[M:.+]] = fmul float{{.*}}
+// CHECK: fadd float %[[M]], %c
+  return a * b + c;
+}
+
+
Index: clang/test/CodeGen/arm64-vrnd-constrained.c
===
--- clang/test/CodeGen/arm64-vrnd-constrained.c
+++ clang/test/CodeGen/arm64-vrnd-constrained.c
@@ -9,6 +9,9 @@
 
 // REQUIRES: aarch64-registered-target
 
+// Disabled until constrained floating point is implemented for arm64.
+// XFAIL: *
+
 #include 
 
 float64x2_t rnd5(float64x2_t a) { return vrndq_f64(a); }
Index: clang/test/CodeGen/arm-neon-directed-rounding-constrained.c
===
--- clang/test/CodeGen/arm-neon-directed-rounding-constrained.c
+++ clang/test/CodeGen/arm-neon-directed-rounding-constrained.c
@@ -32,6 +32,9 @@
 
 // REQUIRES: arm-registered-target,aarch64-registered-target
 
+// Disabled until constrained floating point is implemented for arm64.
+// XFAIL: *
+
 #include 
 
 // COMMON-LABEL: test_vrndi_f32
Index: clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c
===
--- clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c
+++ clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c
@@ -19,6 +19,9 @@
 
 // REQUIRES: aarch64-registered-target
 
+// Disabled until constrained floating point is implemented for arm64.
+// XFAIL: *
+
 #include 
 
 // COMMON-LABEL: test_vsqrt_f16
Index: clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem-constrained.c
===
--- clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem-constrained.c
+++ clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem-constrained.c
@@ -15,6 +15,9 @@
 
 // REQUIRES: aarch64-registered-target
 
+// Disabled until constrained floating point is implemented for arm64.
+// XFAIL: *
+
 // Test new aarch64 intrinsics and types but constrained
 
 #include 
Index: clang/test/CodeGen/aarch64-neon-misc-constrained.c
===
--- clang/test/CodeGen/aarch64-neon-misc-constrained.c
+++ clang/test/CodeGen/aarch64-neon-misc-constrained.c
@@ -15,6 +15,9 @@
 
 // REQUIRES: aarch64-registered-target
 
+// Disabled until constrained floating point is implemented for arm64.
+// XFAIL: *
+
 // Test new aarch64 intrinsics and types but constrained
 
 #include 
Index: clang/lib/Frontend/CompilerInstance.cpp
===
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -935,6 +935,19 @@
 setAuxTarget(TargetInfo::CreateTargetInfo(getDiagnostics(), TO));
   }
 
+  if (!getTarget().hasStrictFP()) {
+if (getLangOpts().getFPRoundingMode() !=
+llvm::RoundingMode::NearestTiesToEven) {
+  getDiagnostics().Report(diag::warn_fe_backend_unsupported_fp_rounding);
+  getLangOpts().setFPRoundingMode(llvm::RoundingMode::NearestTiesToEven);
+}
+if (getLangOpts().getFPExceptionMode() 

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

2020-06-22 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added a comment.
Herald added a subscriber: wuzish.

Ping?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80952/new/

https://reviews.llvm.org/D80952



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


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

2020-06-11 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn updated this revision to Diff 270219.
kpn retitled this revision from "[FPEnv][Clang][Driver][WIP] Disable 
constrained floating point on targets lacking support." to 
"[FPEnv][Clang][Driver] Disable constrained floating point on targets lacking 
support.".
kpn added a comment.
Herald added a subscriber: kbarton.

Added new warnings to a new group "unsupported-floating-point-opt". The warning 
can be disabled. The disabling of constrained floating point is unaffected by 
the status of the warning.

I added PowerPC to the list of targets that are _not_ disabled by this patch 
since that target is close to parity with X86 and SystemZ.

Is there anything left?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80952/new/

https://reviews.llvm.org/D80952

Files:
  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/PPC.h
  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/fp-strictfp.cpp

Index: clang/test/CodeGen/fp-strictfp.cpp
===
--- /dev/null
+++ clang/test/CodeGen/fp-strictfp.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -triple mips64-linux-gnu -frounding-math -ffp-exception-behavior=strict -O2 -verify=rounding,exception -emit-llvm -o - %s | tee /tmp/1 | FileCheck %s
+// RUN: %clang_cc1 -triple mips64-linux-gnu -ffp-exception-behavior=strict -O2 -verify=exception -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple mips64-linux-gnu -frounding-math -O2 -verify=rounding -emit-llvm -o - %s | FileCheck %s
+//
+// Verify that constrained intrinsics are not used.
+// As more targets gain support for constrained intrinsics the triple
+// in this test will need to change.
+
+// rounding-warning@* {{overriding currently unsupported rounding mode on this target}}
+// exception-warning@* {{overriding currently unsupported use of floating point exceptions on this target}}
+float fp_precise_1(float a, float b, float c) {
+// CHECK: _Z12fp_precise_1fff
+// CHECK: %[[M:.+]] = fmul float{{.*}}
+// CHECK: fadd float %[[M]], %c
+  return a * b + c;
+}
+
+
Index: clang/test/CodeGen/arm64-vrnd-constrained.c
===
--- clang/test/CodeGen/arm64-vrnd-constrained.c
+++ clang/test/CodeGen/arm64-vrnd-constrained.c
@@ -9,6 +9,9 @@
 
 // REQUIRES: aarch64-registered-target
 
+// Disabled until constrained floating point is implemented for arm64.
+// XFAIL: *
+
 #include 
 
 float64x2_t rnd5(float64x2_t a) { return vrndq_f64(a); }
Index: clang/test/CodeGen/arm-neon-directed-rounding-constrained.c
===
--- clang/test/CodeGen/arm-neon-directed-rounding-constrained.c
+++ clang/test/CodeGen/arm-neon-directed-rounding-constrained.c
@@ -32,6 +32,9 @@
 
 // REQUIRES: arm-registered-target,aarch64-registered-target
 
+// Disabled until constrained floating point is implemented for arm64.
+// XFAIL: *
+
 #include 
 
 // COMMON-LABEL: test_vrndi_f32
Index: clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c
===
--- clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c
+++ clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c
@@ -19,6 +19,9 @@
 
 // REQUIRES: aarch64-registered-target
 
+// Disabled until constrained floating point is implemented for arm64.
+// XFAIL: *
+
 #include 
 
 // COMMON-LABEL: test_vsqrt_f16
Index: clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem-constrained.c
===
--- clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem-constrained.c
+++ clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem-constrained.c
@@ -15,6 +15,9 @@
 
 // REQUIRES: aarch64-registered-target
 
+// Disabled until constrained floating point is implemented for arm64.
+// XFAIL: *
+
 // Test new aarch64 intrinsics and types but constrained
 
 #include 
Index: clang/test/CodeGen/aarch64-neon-misc-constrained.c
===
--- clang/test/CodeGen/aarch64-neon-misc-constrained.c
+++ clang/test/CodeGen/aarch64-neon-misc-constrained.c
@@ -15,6 +15,9 @@
 
 // REQUIRES: aarch64-registered-target
 
+// Disabled until constrained floating point is implemented for arm64.
+// XFAIL: *
+
 // Test new aarch64 intrinsics and types but constrained
 
 #include 
Index: clang/lib/Frontend/CompilerInstance.cpp
=

[PATCH] D81178: [FPEnv] Initialization of C++ globals not strictfp aware

2020-06-08 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn marked an inline comment as done.
kpn added inline comments.



Comment at: clang/lib/CodeGen/CodeGenFunction.h:4348
+  /// Query for the use of constrained floating point math
+  bool isStrictFP() { return Builder.getIsFPConstrained(); }
+

rjmccall wrote:
> How is this set that we don't end up also setting it as a function attribute?
I admit I don't understand the question. Since the strictfp attribute is 
required on both definitions and calls then only one accessor function seems 
needed?

I don't get to spend as much time in clang proper as I might like.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81178/new/

https://reviews.llvm.org/D81178



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


[PATCH] D81178: [FPEnv] Initialization of C++ globals not strictfp aware

2020-06-04 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn created this revision.
kpn added reviewers: rjmccall, pcc, mibintc.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The rules of the strictfp attribute say that if it is used inside a function 
then it must also be in the function definition. Initialization of C++ globals 
breaks that rule. This patch corrects the failing test but doesn't attempt to 
correct it on other ABIs.

Error spotted with use of D68233 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81178

Files:
  clang/lib/CodeGen/CGDeclCXX.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/CodeGen/fp-floatcontrol-stack.cpp


Index: clang/test/CodeGen/fp-floatcontrol-stack.cpp
===
--- clang/test/CodeGen/fp-floatcontrol-stack.cpp
+++ clang/test/CodeGen/fp-floatcontrol-stack.cpp
@@ -251,3 +251,8 @@
 #endif
 };
 OFF off;
+
+//CHECK-DEBSTRICT: define internal void 
@_GLOBAL__sub_I_fp_floatcontrol_stack.cpp() [[STRICTDEF:#[0-9]+]]
+//CHECK-DEBSTRICT: call void @__cxx_global_var_init() [[STRICTFPONLY:#[0-9]+]]
+//CHECK-DEBSTRICT: attributes [[STRICTDEF]] = { noinline{{.*}}strictfp{{.*}} }
+//CHECK-DEBSTRICT: attributes [[STRICTFPONLY]] = { strictfp }
Index: clang/lib/CodeGen/CodeGenFunction.h
===
--- clang/lib/CodeGen/CodeGenFunction.h
+++ clang/lib/CodeGen/CodeGenFunction.h
@@ -4344,6 +4344,9 @@
   /// Set the codegen fast-math flags.
   void SetFastMathFlags(FPOptions FPFeatures);
 
+  /// Query for the use of constrained floating point math
+  bool isStrictFP() { return Builder.getIsFPConstrained(); }
+
 private:
   llvm::MDNode *getRangeForLoadFromType(QualType Ty);
   void EmitReturnOfRValue(RValue RV, QualType Ty);
Index: clang/lib/CodeGen/CGDeclCXX.cpp
===
--- clang/lib/CodeGen/CGDeclCXX.cpp
+++ clang/lib/CodeGen/CGDeclCXX.cpp
@@ -594,7 +594,12 @@
   llvm::Function *Fn = CreateGlobalInitOrDestructFunction(
   FTy, llvm::Twine("_GLOBAL__sub_I_", FileName), FI);
 
-  CodeGenFunction(*this).GenerateCXXGlobalInitFunc(Fn, CXXGlobalInits);
+  CodeGenFunction CGFn(*this);
+  CGFn.GenerateCXXGlobalInitFunc(Fn, CXXGlobalInits);
+  if (CGFn.isStrictFP())
+if (!Fn->hasFnAttribute(llvm::Attribute::StrictFP))
+  Fn->addFnAttr(llvm::Attribute::StrictFP);
+
   AddGlobalCtor(Fn);
 
   // In OpenCL global init functions must be converted to kernels in order to


Index: clang/test/CodeGen/fp-floatcontrol-stack.cpp
===
--- clang/test/CodeGen/fp-floatcontrol-stack.cpp
+++ clang/test/CodeGen/fp-floatcontrol-stack.cpp
@@ -251,3 +251,8 @@
 #endif
 };
 OFF off;
+
+//CHECK-DEBSTRICT: define internal void @_GLOBAL__sub_I_fp_floatcontrol_stack.cpp() [[STRICTDEF:#[0-9]+]]
+//CHECK-DEBSTRICT: call void @__cxx_global_var_init() [[STRICTFPONLY:#[0-9]+]]
+//CHECK-DEBSTRICT: attributes [[STRICTDEF]] = { noinline{{.*}}strictfp{{.*}} }
+//CHECK-DEBSTRICT: attributes [[STRICTFPONLY]] = { strictfp }
Index: clang/lib/CodeGen/CodeGenFunction.h
===
--- clang/lib/CodeGen/CodeGenFunction.h
+++ clang/lib/CodeGen/CodeGenFunction.h
@@ -4344,6 +4344,9 @@
   /// Set the codegen fast-math flags.
   void SetFastMathFlags(FPOptions FPFeatures);
 
+  /// Query for the use of constrained floating point math
+  bool isStrictFP() { return Builder.getIsFPConstrained(); }
+
 private:
   llvm::MDNode *getRangeForLoadFromType(QualType Ty);
   void EmitReturnOfRValue(RValue RV, QualType Ty);
Index: clang/lib/CodeGen/CGDeclCXX.cpp
===
--- clang/lib/CodeGen/CGDeclCXX.cpp
+++ clang/lib/CodeGen/CGDeclCXX.cpp
@@ -594,7 +594,12 @@
   llvm::Function *Fn = CreateGlobalInitOrDestructFunction(
   FTy, llvm::Twine("_GLOBAL__sub_I_", FileName), FI);
 
-  CodeGenFunction(*this).GenerateCXXGlobalInitFunc(Fn, CXXGlobalInits);
+  CodeGenFunction CGFn(*this);
+  CGFn.GenerateCXXGlobalInitFunc(Fn, CXXGlobalInits);
+  if (CGFn.isStrictFP())
+if (!Fn->hasFnAttribute(llvm::Attribute::StrictFP))
+  Fn->addFnAttr(llvm::Attribute::StrictFP);
+
   AddGlobalCtor(Fn);
 
   // In OpenCL global init functions must be converted to kernels in order to
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D80952: [FPEnv][Clang][Driver][WIP] Disable constrained floating point on targets lacking support.

2020-06-02 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added a comment.

In D80952#2067643 , @arsenm wrote:

> In D80952#2067563 , @efriedma wrote:
>
> > The problem for the command-line arguments in particular is that they 
> > aren't really new; clang has been eating them for a long time, without any 
> > warning.  So if -frounding-math crashes the compiler, that's a regression.
>
>
> Could we get an -fexperimental-something flag to override this behavior then?


The vast majority of the work needed is in llvm and not clang. Most if not all 
testing is done with the llc executable. There is some work in clang's 
CGBuiltins.cpp, but that's pretty small compared to llvm. And with this patch 
the enabling of the clang support is only one line. That seems cheaper than yet 
another command line flag. Someone doing development of the clang parts is 
going to be building clang anyway so I don't see how a one line change is much 
of a burden.

The flags for strict fp and rounding are already pretty complicated already. 
I'd hate to make it even worse with yet another flag just to avoid having a 
developer have to carry one line in one source file. And when clang+llvm is 
ready for a target that one line would be needed _anyway_. So what would a new 
-fexperimental-something flag gain us?

Also, I'm not sure that the constrained intrinsics will ever be implemented on 
every last one of our targets. So a new flag would complicate matters basically 
forever.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80952/new/

https://reviews.llvm.org/D80952



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


[PATCH] D80952: [FPEnv][Clang][Driver][WIP] Disable constrained floating point on targets lacking support.

2020-06-01 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn created this revision.
kpn added reviewers: cameron.mcinally, craig.topper, andrew.w.kaylor, spatel, 
wristow, nemanjai.
Herald added subscribers: cfe-commits, arphaman.
Herald added a project: clang.
kpn added a comment.

This currently triggers a failure in test "Clang :: Misc/warning-flags.c". 
Suggestions on how to fix that correctly are welcome.


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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D80952

Files:
  clang/include/clang/Basic/DiagnosticFrontendKinds.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/fp-strictfp.cpp

Index: clang/test/CodeGen/fp-strictfp.cpp
===
--- /dev/null
+++ clang/test/CodeGen/fp-strictfp.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -triple powerpc64-linux-gnu -frounding-math -ffp-exception-behavior=strict -O2 -verify=rounding,exception -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple powerpc64-linux-gnu -ffp-exception-behavior=strict -O2 -verify=exception -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple powerpc64-linux-gnu -frounding-math -O2 -verify=rounding -emit-llvm -o - %s | FileCheck %s
+//
+// Verify that constrained intrinsics are not used.
+// As more targets gain support for constrained intrinsics the triple
+// in this test will need to change.
+
+// rounding-warning@* {{overriding currently unsupported rounding mode on this target}}
+// exception-warning@* {{overriding currently unsupported use of floating point exceptions on this target}}
+float fp_precise_1(float a, float b, float c) {
+// CHECK: _Z12fp_precise_1fff
+// CHECK: %[[M:.+]] = fmul fast float{{.*}}
+// CHECK: fadd fast float %[[M]], %c
+#pragma float_control(precise, off)
+  return a * b + c;
+}
+
+
Index: clang/test/CodeGen/arm64-vrnd-constrained.c
===
--- clang/test/CodeGen/arm64-vrnd-constrained.c
+++ clang/test/CodeGen/arm64-vrnd-constrained.c
@@ -9,6 +9,9 @@
 
 // REQUIRES: aarch64-registered-target
 
+// Disabled until constrained floating point is implemented for arm64.
+// XFAIL: *
+
 #include 
 
 float64x2_t rnd5(float64x2_t a) { return vrndq_f64(a); }
Index: clang/test/CodeGen/arm-neon-directed-rounding-constrained.c
===
--- clang/test/CodeGen/arm-neon-directed-rounding-constrained.c
+++ clang/test/CodeGen/arm-neon-directed-rounding-constrained.c
@@ -32,6 +32,9 @@
 
 // REQUIRES: arm-registered-target,aarch64-registered-target
 
+// Disabled until constrained floating point is implemented for arm64.
+// XFAIL: *
+
 #include 
 
 // COMMON-LABEL: test_vrndi_f32
Index: clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c
===
--- clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c
+++ clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c
@@ -19,6 +19,9 @@
 
 // REQUIRES: aarch64-registered-target
 
+// Disabled until constrained floating point is implemented for arm64.
+// XFAIL: *
+
 #include 
 
 // COMMON-LABEL: test_vsqrt_f16
Index: clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem-constrained.c
===
--- clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem-constrained.c
+++ clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem-constrained.c
@@ -15,6 +15,9 @@
 
 // REQUIRES: aarch64-registered-target
 
+// Disabled until constrained floating point is implemented for arm64.
+// XFAIL: *
+
 // Test new aarch64 intrinsics and types but constrained
 
 #include 
Index: clang/test/CodeGen/aarch64-neon-misc-constrained.c
===
--- clang/test/CodeGen/aarch64-neon-misc-constrained.c
+++ clang/test/CodeGen/aarch64-neon-misc-constrained.c
@@ -15,6 +15,9 @@
 
 // REQUIRES: aarch64-register

[PATCH] D80952: [FPEnv][Clang][Driver][WIP] Disable constrained floating point on targets lacking support.

2020-06-01 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added a comment.

This currently triggers a failure in test "Clang :: Misc/warning-flags.c". 
Suggestions on how to fix that correctly are welcome.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80952/new/

https://reviews.llvm.org/D80952



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


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

2020-04-03 Thread Kevin P. Neal via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGba87430cadb2: [PowerPC] Replace subtract-from-zero float in 
version with fneg in PowerPC… (authored by ajwock, committed by kpn).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76949/new/

https://reviews.llvm.org/D76949

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-ppc-fma.c


Index: clang/test/CodeGen/builtins-ppc-fma.c
===
--- /dev/null
+++ 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 x double> @llvm.fma.v2f64(<2 x 
double> %{{.*}}, <2 x double> %{{.*}}, <2 x double> [[RESULT]])
+  // CHECK: fneg <2 x double> [[RESULT2]]
+}
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -13214,25 +13214,24 @@
 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


Index: clang/test/CodeGen/builtins-ppc-fma.c
===
--- /dev/null
+++ 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;

[PATCH] D77074: [FPEnv][AArch64] Platform-specific builtin constrained FP enablement

2020-04-02 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn marked an inline comment as done.
kpn added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:8486-8492
+  return Builder.CreateConstrainedFPCall(
+  F,
+  {EmitScalarExpr(E->getArg(1)), EmitScalarExpr(E->getArg(2)), 
Ops[0]});
+} else {
+  Function *F = CGM.getIntrinsic(Intrinsic::fma, HalfTy);
+  // NEON intrinsic puts accumulator first, unlike the LLVM fma.
+  return Builder.CreateCall(F, {EmitScalarExpr(E->getArg(1)),

dnsampaio wrote:
> It seems that `Builder.CreateCall` and `Builder.CreateConstrainedFPCall` 
> usually have the same arguments, except for the function F being or not part 
> of "experimental_constrained_".
> Would it make sense to teach the `Builder` to select between creating a 
> constrained or not call, depending if the function passed is constrained?
> 
> I was thinking in something like this:
> ```
> Function *F = CGM.getIntrinsic( Builder.getIsFPConstrained()?
> 
> Intrinsic::experimental_constrained_fma :
> Intrinsic::fma, 
> HalfTy);
> return Builder.CreateCallConstrainedFPIfRequired(F, 
> ```
> 
In CGBuiltins.cpp we already have emitUnaryMaybeConstrainedFPBuiltin() plus 
Binary and Ternary. They work well for the pattern seen on other hosts. But 
they won't easily work for this ticket. 

How about a new function just below those three that will work well here? A 
emitCallMaybeConstrainedFPBuiltin() that takes two intrinsic IDs and chooses 
which one based on constrained FP would make for an even more compact use. The 
block of example code you put above would just turn into a single function 
call. Does that work for you?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77074/new/

https://reviews.llvm.org/D77074



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


[PATCH] D77074: [FPEnv][AArch64] Platform-specific builtin constrained FP enablement

2020-03-30 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn marked 3 inline comments as done.
kpn added a comment.

Note that the AArch64 backend isn't ready for some of these changes. That's why 
the test is marked XFAIL.




Comment at: clang/lib/CodeGen/CGBuiltin.cpp:5706
+Function *F;
+//exit(2); // XXX
+if (Builder.getIsFPConstrained())

These exit() calls tie back into my test matrix. They'll be removed when I 
eventually push.



Comment at: clang/test/CodeGen/aarch64-neon-intrinsics-constrained.c:288
+
+// XXX FIXME do we need to check for both w and x registers?
+// COMMON-LABEL: test_vceq_f64

Anyone? I'm not an ARM expert.



Comment at: clang/test/CodeGen/aarch64-neon-intrinsics-constrained.c:889
+
+// FIXME why the unused bitcast? There are several of them!
+// COMMON-LABEL: test_vrnda_f64

???


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77074/new/

https://reviews.llvm.org/D77074



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


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

2020-02-06 Thread Kevin P. Neal via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG208470dd5d0a: [FPEnv][X86] Platform-specific builtin 
constrained FP enablement (authored by kpn).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D73570/new/

https://reviews.llvm.org/D73570

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/avx512f-builtins-constrained.c
  clang/test/CodeGen/fma-builtins-constrained.c
  clang/test/CodeGen/sse-builtins-constrained.c

Index: clang/test/CodeGen/sse-builtins-constrained.c
===
--- /dev/null
+++ clang/test/CodeGen/sse-builtins-constrained.c
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +sse -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=UNCONSTRAINED --check-prefix=COMMON --check-prefix=COMMONIR
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +sse -ffp-exception-behavior=strict -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=CONSTRAINED --check-prefix=COMMON --check-prefix=COMMONIR
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +sse -S %s -o - -Wall -Werror | FileCheck %s --check-prefix=CHECK-ASM --check-prefix=COMMON
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +sse -ffp-exception-behavior=strict -S %s -o - -Wall -Werror | FileCheck %s --check-prefix=CHECK-ASM --check-prefix=COMMON
+
+
+#include 
+
+__m128 test_mm_sqrt_ps(__m128 x) {
+  // COMMON-LABEL: test_mm_sqrt_ps
+  // UNCONSTRAINED: call <4 x float> @llvm.sqrt.v4f32(<4 x float> {{.*}})
+  // CONSTRAINED: call <4 x float> @llvm.experimental.constrained.sqrt.v4f32(<4 x float> {{.*}}, metadata !{{.*}})
+  // CHECK-ASM: sqrtps
+  return _mm_sqrt_ps(x);
+}
+
+__m128 test_sqrt_ss(__m128 x) {
+  // COMMON-LABEL: test_sqrt_ss
+  // COMMONIR: extractelement <4 x float> {{.*}}, i64 0
+  // UNCONSTRAINED: call float @llvm.sqrt.f32(float {{.*}})
+  // CONSTRAINED: call float @llvm.experimental.constrained.sqrt.f32(float {{.*}}, metadata !{{.*}})
+  // CHECK-ASM: sqrtss
+  // COMMONIR: insertelement <4 x float> {{.*}}, float {{.*}}, i64 0
+  return _mm_sqrt_ss(x);
+}
+
Index: clang/test/CodeGen/fma-builtins-constrained.c
===
--- /dev/null
+++ clang/test/CodeGen/fma-builtins-constrained.c
@@ -0,0 +1,352 @@
+// 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 --check-prefix=COMMON --check-prefix=CHECK-ASM %s
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +fma -O -ffp-exception-behavior=strict -S -o - | FileCheck --check-prefix=COMMON --check-prefix=CHECK-ASM %s
+
+// FIXME: Several of these tests are broken when constrained.
+
+#include 
+
+__m128 test_mm_fmadd_ps(__m128 a, __m128 b, __m128 c) {
+  // COMMON-LABEL: test_mm_fmadd_ps
+  // UNCONSTRAINED: call <4 x float> @llvm.fma.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x float> %{{.*}})
+  // CONSTRAINED: call <4 x float> @llvm.experimental.constrained.fma.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x float> %{{.*}}, metadata !{{.*}})
+  // CHECK-ASM: vfmadd213ps
+  return _mm_fmadd_ps(a, b, c);
+}
+
+__m128d test_mm_fmadd_pd(__m128d a, __m128d b, __m128d c) {
+  // COMMON-LABEL: test_mm_fmadd_pd
+  // UNCONSTRAINED: call <2 x double> @llvm.fma.v2f64(<2 x double> %{{.*}}, <2 x double> %{{.*}}, <2 x double> %{{.*}})
+  // CONSTRAINED: call <2 x double> @llvm.experimental.constrained.fma.v2f64(<2 x double> %{{.*}}, <2 x double> %{{.*}}, <2 x double> %{{.*}}, metadata !{{.*}})
+  // CHECK-ASM: vfmadd213pd
+  return _mm_fmadd_pd(a, b, c);
+}
+
+__m128 test_mm_fmadd_ss(__m128 a, __m128 b, __m128 c) {
+  // COMMON-LABEL: test_mm_fmadd_ss
+  // COMMONIR: extractelement <4 x float> %{{.*}}, i64 0
+  // COMMONIR: extractelement <4 x float> %{{.*}}, i64 0
+  // COMMONIR: extractelement <4 x float> %{{.*}}, i64 0
+  // UNCONSTRAINED: call float @llvm.fma.f32(float %{{.*}}, float %{{.*}}, float %{{.*}})
+  // CONSTRAINED: call float @llvm.experimental.constrained.fma.f32(float %{{.*}}, float %{{.*}}, float %{{.*}}, metadata !{{.*}})
+  // CHECK-ASM: vfmadd213ss
+  // COMMONIR: insertelement <4 x float> %{{.*}}, float %{{.*}}, i64 0
+  return _mm_fmadd_ss(a, b, c);
+}
+
+__m128d test_mm_fmadd_sd(__m128d a, __m128d b, __m128d 

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

2020-01-31 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn updated this revision to Diff 241771.
kpn added a comment.

Address review comments: FMA tests are now run optimized. This changes where 
the FIXME lines are located.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D73570/new/

https://reviews.llvm.org/D73570

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/avx512f-builtins-constrained.c
  clang/test/CodeGen/fma-builtins-constrained.c
  clang/test/CodeGen/sse-builtins-constrained.c

Index: clang/test/CodeGen/sse-builtins-constrained.c
===
--- /dev/null
+++ clang/test/CodeGen/sse-builtins-constrained.c
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +sse -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=UNCONSTRAINED --check-prefix=COMMON --check-prefix=COMMONIR
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +sse -ffp-exception-behavior=strict -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=CONSTRAINED --check-prefix=COMMON --check-prefix=COMMONIR
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +sse -S %s -o - -Wall -Werror | FileCheck %s --check-prefix=CHECK-ASM --check-prefix=COMMON
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +sse -ffp-exception-behavior=strict -S %s -o - -Wall -Werror | FileCheck %s --check-prefix=CHECK-ASM --check-prefix=COMMON
+
+
+#include 
+
+__m128 test_mm_sqrt_ps(__m128 x) {
+  // COMMON-LABEL: test_mm_sqrt_ps
+  // UNCONSTRAINED: call <4 x float> @llvm.sqrt.v4f32(<4 x float> {{.*}})
+  // CONSTRAINED: call <4 x float> @llvm.experimental.constrained.sqrt.v4f32(<4 x float> {{.*}}, metadata !{{.*}})
+  // CHECK-ASM: sqrtps
+  return _mm_sqrt_ps(x);
+}
+
+__m128 test_sqrt_ss(__m128 x) {
+  // COMMON-LABEL: test_sqrt_ss
+  // COMMONIR: extractelement <4 x float> {{.*}}, i64 0
+  // UNCONSTRAINED: call float @llvm.sqrt.f32(float {{.*}})
+  // CONSTRAINED: call float @llvm.experimental.constrained.sqrt.f32(float {{.*}}, metadata !{{.*}})
+  // CHECK-ASM: sqrtss
+  // COMMONIR: insertelement <4 x float> {{.*}}, float {{.*}}, i64 0
+  return _mm_sqrt_ss(x);
+}
+
Index: clang/test/CodeGen/fma-builtins-constrained.c
===
--- /dev/null
+++ clang/test/CodeGen/fma-builtins-constrained.c
@@ -0,0 +1,352 @@
+// 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 --check-prefix=COMMON --check-prefix=CHECK-ASM %s
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +fma -O -ffp-exception-behavior=strict -S -o - | FileCheck --check-prefix=COMMON --check-prefix=CHECK-ASM %s
+
+// FIXME: Several of these tests are broken when constrained.
+
+#include 
+
+__m128 test_mm_fmadd_ps(__m128 a, __m128 b, __m128 c) {
+  // COMMON-LABEL: test_mm_fmadd_ps
+  // UNCONSTRAINED: call <4 x float> @llvm.fma.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x float> %{{.*}})
+  // CONSTRAINED: call <4 x float> @llvm.experimental.constrained.fma.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x float> %{{.*}}, metadata !{{.*}})
+  // CHECK-ASM: vfmadd213ps
+  return _mm_fmadd_ps(a, b, c);
+}
+
+__m128d test_mm_fmadd_pd(__m128d a, __m128d b, __m128d c) {
+  // COMMON-LABEL: test_mm_fmadd_pd
+  // UNCONSTRAINED: call <2 x double> @llvm.fma.v2f64(<2 x double> %{{.*}}, <2 x double> %{{.*}}, <2 x double> %{{.*}})
+  // CONSTRAINED: call <2 x double> @llvm.experimental.constrained.fma.v2f64(<2 x double> %{{.*}}, <2 x double> %{{.*}}, <2 x double> %{{.*}}, metadata !{{.*}})
+  // CHECK-ASM: vfmadd213pd
+  return _mm_fmadd_pd(a, b, c);
+}
+
+__m128 test_mm_fmadd_ss(__m128 a, __m128 b, __m128 c) {
+  // COMMON-LABEL: test_mm_fmadd_ss
+  // COMMONIR: extractelement <4 x float> %{{.*}}, i64 0
+  // COMMONIR: extractelement <4 x float> %{{.*}}, i64 0
+  // COMMONIR: extractelement <4 x float> %{{.*}}, i64 0
+  // UNCONSTRAINED: call float @llvm.fma.f32(float %{{.*}}, float %{{.*}}, float %{{.*}})
+  // CONSTRAINED: call float @llvm.experimental.constrained.fma.f32(float %{{.*}}, float %{{.*}}, float %{{.*}}, metadata !{{.*}})
+  // CHECK-ASM: vfmadd213ss
+  // COMMONIR: insertelement <4 x float> %{{.*}}, float %{{.*}}, i64 0
+  return _mm_fmadd_ss(a, b, c);
+}
+
+__m128d test_mm_fmadd_sd(__m128d a, __m128d b, __m128d c) {
+  // COMMON-LABEL: test_mm_fmadd_sd
+  // COMMONIR: extractelement <2 x double> %{{.*}}, i64 0
+ 

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

2020-01-29 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn marked 2 inline comments as done.
kpn added inline comments.



Comment at: clang/test/CodeGen/fma-builtins-constrained.c:4
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin 
-target-feature +fma -S -o - | FileCheck --check-prefix=COMMON 
--check-prefix=CHECK-ASM %s
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin 
-target-feature +fma -ffp-exception-behavior=strict -S -o - | FileCheck 
--check-prefix=COMMON --check-prefix=CHECK-ASM %s
+

craig.topper wrote:
> Technically the fmsub/fnmsub/fnmadd assembly requires optimizations to be 
> enabled. If it appears to work without optimizations its only because 
> fast-isel fell back to SelectionDAG and picked up optimizations due to that. 
> Not something that should be relied on.
Ok. Well, the eventual goal is to ship a product with optimization turned on. 
So I think it makes sense for me to give this a spin with optimizations and see 
what if anything needs to be done. Unless that's overkill I'll start this 
afternoon.



Comment at: clang/test/CodeGen/fma-builtins-constrained.c:6
+
+// FIXME: Several of these tests are broken when constrained.
+

craig.topper wrote:
> Is this just referring to the FIXME-CHECK-ASM?
Yes.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D73570/new/

https://reviews.llvm.org/D73570



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


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

2020-01-28 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn created this revision.
kpn added reviewers: craig.topper, andrew.w.kaylor.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

[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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73570

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/avx512f-builtins-constrained.c
  clang/test/CodeGen/fma-builtins-constrained.c
  clang/test/CodeGen/sse-builtins-constrained.c

Index: clang/test/CodeGen/sse-builtins-constrained.c
===
--- /dev/null
+++ clang/test/CodeGen/sse-builtins-constrained.c
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +sse -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=UNCONSTRAINED --check-prefix=COMMON --check-prefix=COMMONIR
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +sse -ffp-exception-behavior=strict -emit-llvm -o - -Wall -Werror | FileCheck %s --check-prefix=CONSTRAINED --check-prefix=COMMON --check-prefix=COMMONIR
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +sse -S %s -o - -Wall -Werror | FileCheck %s --check-prefix=CHECK-ASM --check-prefix=COMMON
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +sse -ffp-exception-behavior=strict -S %s -o - -Wall -Werror | FileCheck %s --check-prefix=CHECK-ASM --check-prefix=COMMON
+
+
+#include 
+
+__m128 test_mm_sqrt_ps(__m128 x) {
+  // COMMON-LABEL: test_mm_sqrt_ps
+  // UNCONSTRAINED: call <4 x float> @llvm.sqrt.v4f32(<4 x float> {{.*}})
+  // CONSTRAINED: call <4 x float> @llvm.experimental.constrained.sqrt.v4f32(<4 x float> {{.*}}, metadata !{{.*}})
+  // CHECK-ASM: sqrtps
+  return _mm_sqrt_ps(x);
+}
+
+__m128 test_sqrt_ss(__m128 x) {
+  // COMMON-LABEL: test_sqrt_ss
+  // COMMONIR: extractelement <4 x float> {{.*}}, i64 0
+  // UNCONSTRAINED: call float @llvm.sqrt.f32(float {{.*}})
+  // CONSTRAINED: call float @llvm.experimental.constrained.sqrt.f32(float {{.*}}, metadata !{{.*}})
+  // CHECK-ASM: sqrtss
+  // COMMONIR: insertelement <4 x float> {{.*}}, float {{.*}}, i64 0
+  return _mm_sqrt_ss(x);
+}
+
Index: clang/test/CodeGen/fma-builtins-constrained.c
===
--- /dev/null
+++ clang/test/CodeGen/fma-builtins-constrained.c
@@ -0,0 +1,352 @@
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +fma -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 -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 -S -o - | FileCheck --check-prefix=COMMON --check-prefix=CHECK-ASM %s
+// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin -target-feature +fma -ffp-exception-behavior=strict -S -o - | FileCheck --check-prefix=COMMON --check-prefix=CHECK-ASM %s
+
+// FIXME: Several of these tests are broken when constrained.
+
+#include 
+
+__m128 test_mm_fmadd_ps(__m128 a, __m128 b, __m128 c) {
+  // COMMON-LABEL: test_mm_fmadd_ps
+  // UNCONSTRAINED: call <4 x float> @llvm.fma.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x float> %{{.*}})
+  // CONSTRAINED: call <4 x float> @llvm.experimental.constrained.fma.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x float> %{{.*}}, metadata !{{.*}})
+  // CHECK-ASM: vfmadd213ps
+  return _mm_fmadd_ps(a, b, c);
+}
+
+__m128d test_mm_fmadd_pd(__m128d a, __m128d b, __m128d c) {
+  // COMMON-LABEL: test_mm_fmadd_pd
+  // UNCONSTRAINED: call <2 x double> @llvm.fma.v2f64(<2 x double> %{{.*}}, <2 x double> %{{.*}}, <2 x double> %{{.*}})
+  // CONSTRAINED: call <2 x double> @llvm.experimental.constrained.fma.v2f64(<2 x double> %{{.*}}, <2 x double> %{{.*}}, <2 x double> %{{.*}}, metadata !{{.*}})
+  // CHECK-ASM: vfmadd213pd
+  return _mm_fmadd_pd(a, b, c);
+}
+
+__m128 test_mm_fmadd_ss(__m128 a, __m128 b, __m128 c) {
+  // COMMON-LABEL: test_mm_fmadd_ss
+  // COMMONIR: extractelement <4 x float> %{{.*}}, i64 0
+  // COMMONIR: extractelement <4 x float> %{{.*}}, i64 0
+  // COMMONIR: extractelement <4 x float> %{{.*}}, i64 0
+  // UNCONSTRAINED: call float @llvm.fma.f32(float %{{.*}}, float %{{.*}}, float %{{.*}})
+  // CONSTRAINED: call float @llvm.experimental.constrained.fma.f32(float %{{.*}}, float %{{.*}}, float %{{.*}}, metadata !{{.*}})
+  // CHECK-ASM: vfmadd213ss
+  // COMMONIR: insertelement <4 x float> %{{.*}}, float %{{.*}}, i64 0
+  return _mm_fmadd_ss(a, b, c);
+}
+
+__m128d test_mm_fmadd_sd(__m128d a, __m128d b, __m128d c) {
+ 

[PATCH] D72820: [FPEnv] Add pragma FP_CONTRACT support under strict FP.

2020-01-24 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added inline comments.



Comment at: clang/lib/CodeGen/CGExprScalar.cpp:3381
+   "constrained mode");
+FMulAdd = Builder.CreateCall(
+CGF.CGM.getIntrinsic(llvm::Intrinsic::experimental_constrained_fmuladd,

craig.topper wrote:
> kpn wrote:
> > craig.topper wrote:
> > > Doesn't this need to be CreateConstrainedFPCall so that the strictfp 
> > > attribute is added? That will take care of adding the metadata operands 
> > > too.
> > Is this code tested? I ran into a bug yesterday where CreateCall was used 
> > with a constrained intrinsic and the Instruction class blew up because the 
> > function signature was wrong. I wasn't passing in the metadata arguments.
> > 
> > So, yes, it should be, and it would might make sense for the patch to have 
> > test coverage that catches any other cases of this.
> This code is copying the metadata arguments from the fmul intrinsic, MulOp. 
> that’s the getOperand(2) and getOperand(3).
Ah, yes, thanks. Your comment about the attribute is still valid, though. And, 
yes, using CreateConstrainedFPCall() is the easiest way to fix the attribute.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72820/new/

https://reviews.llvm.org/D72820



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


[PATCH] D72820: [FPEnv] Add pragma FP_CONTRACT support under strict FP.

2020-01-24 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn added inline comments.



Comment at: clang/lib/CodeGen/CGExprScalar.cpp:3381
+   "constrained mode");
+FMulAdd = Builder.CreateCall(
+CGF.CGM.getIntrinsic(llvm::Intrinsic::experimental_constrained_fmuladd,

craig.topper wrote:
> Doesn't this need to be CreateConstrainedFPCall so that the strictfp 
> attribute is added? That will take care of adding the metadata operands too.
Is this code tested? I ran into a bug yesterday where CreateCall was used with 
a constrained intrinsic and the Instruction class blew up because the function 
signature was wrong. I wasn't passing in the metadata arguments.

So, yes, it should be, and it would might make sense for the patch to have test 
coverage that catches any other cases of this.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72820/new/

https://reviews.llvm.org/D72820



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


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

2020-01-21 Thread Kevin P. Neal via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2e667d07c773: [FPEnv][SystemZ] Platform-specific builtin 
constrained FP enablement (authored by kpn).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72722/new/

https://reviews.llvm.org/D72722

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  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

Index: clang/test/CodeGen/builtins-systemz-zvector3-constrained.c
===
--- /dev/null
+++ clang/test/CodeGen/builtins-systemz-zvector3-constrained.c
@@ -0,0 +1,109 @@
+// REQUIRES: systemz-registered-target
+// RUN: %clang_cc1 -target-cpu z15 -triple s390x-linux-gnu \
+// RUN: -O -fzvector -flax-vector-conversions=none \
+// RUN: -ffp-exception-behavior=strict \
+// RUN: -Wall -Wno-unused -Werror -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -target-cpu z15 -triple s390x-linux-gnu \
+// RUN: -O -fzvector -flax-vector-conversions=none \
+// RUN: -ffp-exception-behavior=strict \
+// RUN: -Wall -Wno-unused -Werror -S %s -o - | FileCheck %s --check-prefix=CHECK-ASM
+
+#include 
+
+volatile vector signed int vsi;
+volatile vector signed long long vsl;
+volatile vector unsigned int vui;
+volatile vector unsigned long long vul;
+volatile vector float vf;
+volatile vector double vd;
+
+volatile float f;
+volatile double d;
+
+const float * volatile cptrf;
+const double * volatile cptrd;
+
+float * volatile ptrf;
+double * volatile ptrd;
+
+volatile int idx;
+
+void test_core(void) {
+  // CHECK-ASM-LABEL: test_core
+  vector float vf2;
+  vector double vd2;
+
+  vf += vec_revb(vec_xl(idx, cptrf));
+  // CHECK-ASM: vlbrf
+  vd += vec_revb(vec_xl(idx, cptrd));
+  // CHECK-ASM: vlbrg
+
+  vec_xst(vec_revb(vf), idx, ptrf);
+  // CHECK-ASM: vstbrf
+  vec_xst(vec_revb(vd), idx, ptrd);
+  // CHECK-ASM: vstbrg
+
+  vf += vec_revb(vec_insert_and_zero(cptrf));
+  // CHECK-ASM: vllebrzf
+  vd += vec_revb(vec_insert_and_zero(cptrd));
+  // CHECK-ASM: vllebrzg
+
+  vf += vec_revb(vec_splats(f));
+  // CHECK-ASM: vlbrrepf
+  vd += vec_revb(vec_splats(d));
+  // CHECK-ASM: vlbrrepg
+
+  vf2 = vf;
+  vf += vec_revb(vec_insert(f, vec_revb(vf2), 0));
+  // CHECK-ASM: vlebrf
+  vd2 = vd;
+  vd += vec_revb(vec_insert(d, vec_revb(vd2), 0));
+  // CHECK-ASM: vlebrg
+
+  f = vec_extract(vec_revb(vf), 0);
+  // CHECK-ASM: vstebrf
+  d = vec_extract(vec_revb(vd), 0);
+  // CHECK-ASM: vstebrg
+
+  vf += vec_reve(vec_xl(idx, cptrf));
+  // CHECK-ASM: vlerf
+  vd += vec_reve(vec_xl(idx, cptrd));
+  // CHECK-ASM: vlerg
+
+  vec_xst(vec_reve(vf), idx, ptrf);
+  // CHECK-ASM: vsterf
+  vec_xst(vec_reve(vd), idx, ptrd);
+  // CHECK-ASM: vsterg
+}
+
+void test_float(void) {
+  // CHECK-ASM-LABEL: test_float
+
+  vd = vec_double(vsl);
+  // CHECK: call <2 x double> @llvm.experimental.constrained.sitofp.v2f64.v2i64(<2 x i64> %{{.*}}, metadata !{{.*}})
+  // CHECK-ASM: vcdgb
+  vd = vec_double(vul);
+  // CHECK: call <2 x double> @llvm.experimental.constrained.uitofp.v2f64.v2i64(<2 x i64> %{{.*}}, metadata !{{.*}})
+  // CHECK-ASM: vcdlgb
+  vf = vec_float(vsi);
+  // CHECK: call <4 x float> @llvm.experimental.constrained.sitofp.v4f32.v4i32(<4 x i32> %{{.*}}, metadata !{{.*}})
+  // CHECK-ASM: vcefb
+  vf = vec_float(vui);
+  // CHECK: call <4 x float> @llvm.experimental.constrained.uitofp.v4f32.v4i32(<4 x i32> %{{.*}}, metadata !{{.*}})
+  // CHECK-ASM: vcelfb
+
+  vsl = vec_signed(vd);
+  // CHECK: call <2 x i64> @llvm.experimental.constrained.fptosi.v2i64.v2f64(<2 x double> %{{.*}}, metadata !{{.*}})
+  // CHECK-ASM: vcgdb
+  vsi = vec_signed(vf);
+  // CHECK: call <4 x i32> @llvm.experimental.constrained.fptosi.v4i32.v4f32(<4 x float> %{{.*}}, metadata !{{.*}})
+  // CHECK-ASM: vcfeb
+  vul = vec_unsigned(vd);
+  // CHECK: call <2 x i64> @llvm.experimental.constrained.fptoui.v2i64.v2f64(<2 x double> %{{.*}}, metadata !{{.*}})
+  // CHECK-ASM: vclgdb
+  vui = vec_unsigned(vf);
+  // xHECK: fptoui <4 x float> %{{.*}} to <4 x i32>
+  // CHECK: call <4 x i32> @llvm.experimental.constrained.fptoui.v4i32.v4f32(<4 x float> %{{.*}}, metadata !{{.*}})
+  // CHECK-ASM: vclfeb
+}
+
Index: clang/test/CodeGen/builtins-systemz-zvector2-constrained.c
===
--- /dev/null
+++ clang/test/CodeGen/builtins-systemz-zvector2-constrained.c
@@ -0,0 +1,543 @@
+// REQUIRES: systemz-registered-target
+// RUN: %clang_cc1 -target-cpu z14 -triple s390x-linux-gnu \
+// RUN: -O -fzvector -flax-vector-conversions=none \
+// RUN: -ffp-exception-behavior=strict \
+// RUN: -Wall -Wno-unused -Werror -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -target-cpu z14 -triple s390x-linux

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

2020-01-21 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn updated this revision to Diff 239325.
kpn added a comment.

Eliminate a blank line I thought I had already had gotten.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72722/new/

https://reviews.llvm.org/D72722

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  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

Index: clang/test/CodeGen/builtins-systemz-zvector3-constrained.c
===
--- /dev/null
+++ clang/test/CodeGen/builtins-systemz-zvector3-constrained.c
@@ -0,0 +1,109 @@
+// REQUIRES: systemz-registered-target
+// RUN: %clang_cc1 -target-cpu z15 -triple s390x-linux-gnu \
+// RUN: -O -fzvector -flax-vector-conversions=none \
+// RUN: -ffp-exception-behavior=strict \
+// RUN: -Wall -Wno-unused -Werror -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -target-cpu z15 -triple s390x-linux-gnu \
+// RUN: -O -fzvector -flax-vector-conversions=none \
+// RUN: -ffp-exception-behavior=strict \
+// RUN: -Wall -Wno-unused -Werror -S %s -o - | FileCheck %s --check-prefix=CHECK-ASM
+
+#include 
+
+volatile vector signed int vsi;
+volatile vector signed long long vsl;
+volatile vector unsigned int vui;
+volatile vector unsigned long long vul;
+volatile vector float vf;
+volatile vector double vd;
+
+volatile float f;
+volatile double d;
+
+const float * volatile cptrf;
+const double * volatile cptrd;
+
+float * volatile ptrf;
+double * volatile ptrd;
+
+volatile int idx;
+
+void test_core(void) {
+  // CHECK-ASM-LABEL: test_core
+  vector float vf2;
+  vector double vd2;
+
+  vf += vec_revb(vec_xl(idx, cptrf));
+  // CHECK-ASM: vlbrf
+  vd += vec_revb(vec_xl(idx, cptrd));
+  // CHECK-ASM: vlbrg
+
+  vec_xst(vec_revb(vf), idx, ptrf);
+  // CHECK-ASM: vstbrf
+  vec_xst(vec_revb(vd), idx, ptrd);
+  // CHECK-ASM: vstbrg
+
+  vf += vec_revb(vec_insert_and_zero(cptrf));
+  // CHECK-ASM: vllebrzf
+  vd += vec_revb(vec_insert_and_zero(cptrd));
+  // CHECK-ASM: vllebrzg
+
+  vf += vec_revb(vec_splats(f));
+  // CHECK-ASM: vlbrrepf
+  vd += vec_revb(vec_splats(d));
+  // CHECK-ASM: vlbrrepg
+
+  vf2 = vf;
+  vf += vec_revb(vec_insert(f, vec_revb(vf2), 0));
+  // CHECK-ASM: vlebrf
+  vd2 = vd;
+  vd += vec_revb(vec_insert(d, vec_revb(vd2), 0));
+  // CHECK-ASM: vlebrg
+
+  f = vec_extract(vec_revb(vf), 0);
+  // CHECK-ASM: vstebrf
+  d = vec_extract(vec_revb(vd), 0);
+  // CHECK-ASM: vstebrg
+
+  vf += vec_reve(vec_xl(idx, cptrf));
+  // CHECK-ASM: vlerf
+  vd += vec_reve(vec_xl(idx, cptrd));
+  // CHECK-ASM: vlerg
+
+  vec_xst(vec_reve(vf), idx, ptrf);
+  // CHECK-ASM: vsterf
+  vec_xst(vec_reve(vd), idx, ptrd);
+  // CHECK-ASM: vsterg
+}
+
+void test_float(void) {
+  // CHECK-ASM-LABEL: test_float
+
+  vd = vec_double(vsl);
+  // CHECK: call <2 x double> @llvm.experimental.constrained.sitofp.v2f64.v2i64(<2 x i64> %{{.*}}, metadata !{{.*}})
+  // CHECK-ASM: vcdgb
+  vd = vec_double(vul);
+  // CHECK: call <2 x double> @llvm.experimental.constrained.uitofp.v2f64.v2i64(<2 x i64> %{{.*}}, metadata !{{.*}})
+  // CHECK-ASM: vcdlgb
+  vf = vec_float(vsi);
+  // CHECK: call <4 x float> @llvm.experimental.constrained.sitofp.v4f32.v4i32(<4 x i32> %{{.*}}, metadata !{{.*}})
+  // CHECK-ASM: vcefb
+  vf = vec_float(vui);
+  // CHECK: call <4 x float> @llvm.experimental.constrained.uitofp.v4f32.v4i32(<4 x i32> %{{.*}}, metadata !{{.*}})
+  // CHECK-ASM: vcelfb
+
+  vsl = vec_signed(vd);
+  // CHECK: call <2 x i64> @llvm.experimental.constrained.fptosi.v2i64.v2f64(<2 x double> %{{.*}}, metadata !{{.*}})
+  // CHECK-ASM: vcgdb
+  vsi = vec_signed(vf);
+  // CHECK: call <4 x i32> @llvm.experimental.constrained.fptosi.v4i32.v4f32(<4 x float> %{{.*}}, metadata !{{.*}})
+  // CHECK-ASM: vcfeb
+  vul = vec_unsigned(vd);
+  // CHECK: call <2 x i64> @llvm.experimental.constrained.fptoui.v2i64.v2f64(<2 x double> %{{.*}}, metadata !{{.*}})
+  // CHECK-ASM: vclgdb
+  vui = vec_unsigned(vf);
+  // xHECK: fptoui <4 x float> %{{.*}} to <4 x i32>
+  // CHECK: call <4 x i32> @llvm.experimental.constrained.fptoui.v4i32.v4f32(<4 x float> %{{.*}}, metadata !{{.*}})
+  // CHECK-ASM: vclfeb
+}
+
Index: clang/test/CodeGen/builtins-systemz-zvector2-constrained.c
===
--- /dev/null
+++ clang/test/CodeGen/builtins-systemz-zvector2-constrained.c
@@ -0,0 +1,543 @@
+// REQUIRES: systemz-registered-target
+// RUN: %clang_cc1 -target-cpu z14 -triple s390x-linux-gnu \
+// RUN: -O -fzvector -flax-vector-conversions=none \
+// RUN: -ffp-exception-behavior=strict \
+// RUN: -Wall -Wno-unused -Werror -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -target-cpu z14 -triple s390x-linux-gnu \
+// RUN: -O -fzvector -flax-vector-conversions=none \
+// RUN: -ffp-exception-behavior=strict \
+// RUN:

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

2020-01-21 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn updated this revision to Diff 239324.
kpn added a comment.

Update for review comments.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72722/new/

https://reviews.llvm.org/D72722

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  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

Index: clang/test/CodeGen/builtins-systemz-zvector3-constrained.c
===
--- /dev/null
+++ clang/test/CodeGen/builtins-systemz-zvector3-constrained.c
@@ -0,0 +1,109 @@
+// REQUIRES: systemz-registered-target
+// RUN: %clang_cc1 -target-cpu z15 -triple s390x-linux-gnu \
+// RUN: -O -fzvector -flax-vector-conversions=none \
+// RUN: -ffp-exception-behavior=strict \
+// RUN: -Wall -Wno-unused -Werror -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -target-cpu z15 -triple s390x-linux-gnu \
+// RUN: -O -fzvector -flax-vector-conversions=none \
+// RUN: -ffp-exception-behavior=strict \
+// RUN: -Wall -Wno-unused -Werror -S %s -o - | FileCheck %s --check-prefix=CHECK-ASM
+
+#include 
+
+volatile vector signed int vsi;
+volatile vector signed long long vsl;
+volatile vector unsigned int vui;
+volatile vector unsigned long long vul;
+volatile vector float vf;
+volatile vector double vd;
+
+volatile float f;
+volatile double d;
+
+const float * volatile cptrf;
+const double * volatile cptrd;
+
+float * volatile ptrf;
+double * volatile ptrd;
+
+volatile int idx;
+
+void test_core(void) {
+  // CHECK-ASM-LABEL: test_core
+  vector float vf2;
+  vector double vd2;
+
+  vf += vec_revb(vec_xl(idx, cptrf));
+  // CHECK-ASM: vlbrf
+  vd += vec_revb(vec_xl(idx, cptrd));
+  // CHECK-ASM: vlbrg
+
+  vec_xst(vec_revb(vf), idx, ptrf);
+  // CHECK-ASM: vstbrf
+  vec_xst(vec_revb(vd), idx, ptrd);
+  // CHECK-ASM: vstbrg
+
+  vf += vec_revb(vec_insert_and_zero(cptrf));
+  // CHECK-ASM: vllebrzf
+  vd += vec_revb(vec_insert_and_zero(cptrd));
+  // CHECK-ASM: vllebrzg
+
+  vf += vec_revb(vec_splats(f));
+  // CHECK-ASM: vlbrrepf
+  vd += vec_revb(vec_splats(d));
+  // CHECK-ASM: vlbrrepg
+
+  vf2 = vf;
+  vf += vec_revb(vec_insert(f, vec_revb(vf2), 0));
+  // CHECK-ASM: vlebrf
+  vd2 = vd;
+  vd += vec_revb(vec_insert(d, vec_revb(vd2), 0));
+  // CHECK-ASM: vlebrg
+
+  f = vec_extract(vec_revb(vf), 0);
+  // CHECK-ASM: vstebrf
+  d = vec_extract(vec_revb(vd), 0);
+  // CHECK-ASM: vstebrg
+
+  vf += vec_reve(vec_xl(idx, cptrf));
+  // CHECK-ASM: vlerf
+  vd += vec_reve(vec_xl(idx, cptrd));
+  // CHECK-ASM: vlerg
+
+  vec_xst(vec_reve(vf), idx, ptrf);
+  // CHECK-ASM: vsterf
+  vec_xst(vec_reve(vd), idx, ptrd);
+  // CHECK-ASM: vsterg
+}
+
+void test_float(void) {
+  // CHECK-ASM-LABEL: test_float
+
+  vd = vec_double(vsl);
+  // CHECK: call <2 x double> @llvm.experimental.constrained.sitofp.v2f64.v2i64(<2 x i64> %{{.*}}, metadata !{{.*}})
+  // CHECK-ASM: vcdgb
+  vd = vec_double(vul);
+  // CHECK: call <2 x double> @llvm.experimental.constrained.uitofp.v2f64.v2i64(<2 x i64> %{{.*}}, metadata !{{.*}})
+  // CHECK-ASM: vcdlgb
+  vf = vec_float(vsi);
+  // CHECK: call <4 x float> @llvm.experimental.constrained.sitofp.v4f32.v4i32(<4 x i32> %{{.*}}, metadata !{{.*}})
+  // CHECK-ASM: vcefb
+  vf = vec_float(vui);
+  // CHECK: call <4 x float> @llvm.experimental.constrained.uitofp.v4f32.v4i32(<4 x i32> %{{.*}}, metadata !{{.*}})
+  // CHECK-ASM: vcelfb
+
+  vsl = vec_signed(vd);
+  // CHECK: call <2 x i64> @llvm.experimental.constrained.fptosi.v2i64.v2f64(<2 x double> %{{.*}}, metadata !{{.*}})
+  // CHECK-ASM: vcgdb
+  vsi = vec_signed(vf);
+  // CHECK: call <4 x i32> @llvm.experimental.constrained.fptosi.v4i32.v4f32(<4 x float> %{{.*}}, metadata !{{.*}})
+  // CHECK-ASM: vcfeb
+  vul = vec_unsigned(vd);
+  // CHECK: call <2 x i64> @llvm.experimental.constrained.fptoui.v2i64.v2f64(<2 x double> %{{.*}}, metadata !{{.*}})
+  // CHECK-ASM: vclgdb
+  vui = vec_unsigned(vf);
+  // xHECK: fptoui <4 x float> %{{.*}} to <4 x i32>
+  // CHECK: call <4 x i32> @llvm.experimental.constrained.fptoui.v4i32.v4f32(<4 x float> %{{.*}}, metadata !{{.*}})
+  // CHECK-ASM: vclfeb
+}
+
Index: clang/test/CodeGen/builtins-systemz-zvector2-constrained.c
===
--- /dev/null
+++ clang/test/CodeGen/builtins-systemz-zvector2-constrained.c
@@ -0,0 +1,543 @@
+// REQUIRES: systemz-registered-target
+// RUN: %clang_cc1 -target-cpu z14 -triple s390x-linux-gnu \
+// RUN: -O -fzvector -flax-vector-conversions=none \
+// RUN: -ffp-exception-behavior=strict \
+// RUN: -Wall -Wno-unused -Werror -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -target-cpu z14 -triple s390x-linux-gnu \
+// RUN: -O -fzvector -flax-vector-conversions=none \
+// RUN: -ffp-exception-behavior=strict \
+// RUN: -Wall -Wno-unused -Werror -S %

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

2020-01-21 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn marked an inline comment as done.
kpn added inline comments.



Comment at: clang/test/CodeGen/builtins-systemz-vector2-constrained.c:25
+  // CHECK: [[NEG:%[^ ]+]] = fneg <2 x double> {{.*}}
+  // CHECK:  [[RES:%[^ ]+]] = call <2 x double> 
@llvm.experimental.constrained.fma.v2f64(<2 x double> %{{.*}}, <2 x double> 
%{{.*}}, <2 x double> [[NEG]], metadata !{{.*}}, metadata !{{.*}})
+  // CHECK: fneg <2 x double> [[RES]]

uweigand wrote:
> Why is it that this one has metadata nodes and all the others do not?   Do 
> they really not have metadata (why?) or are you just not checking for them?
No reason, really. The regular expression will pick up the second metadata 
argument if present, so I could just eliminate the check for the second one 
here. This isn't a metadata test so precise testing of metadata arguments 
doesn't seem necessary? Consistency would be good, though.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72722/new/

https://reviews.llvm.org/D72722



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


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

2020-01-14 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn created this revision.
kpn added a reviewer: uweigand.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72722

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  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

Index: clang/test/CodeGen/builtins-systemz-zvector3-constrained.c
===
--- /dev/null
+++ clang/test/CodeGen/builtins-systemz-zvector3-constrained.c
@@ -0,0 +1,112 @@
+// REQUIRES: systemz-registered-target
+// RUN: %clang_cc1 -target-cpu z15 -triple s390x-linux-gnu \
+// RUN: -O -fzvector -flax-vector-conversions=none \
+// RUN: -ffp-exception-behavior=strict \
+// RUN: -Wall -Wno-unused -Werror -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -target-cpu z15 -triple s390x-linux-gnu \
+// RUN: -O -fzvector -flax-vector-conversions=none \
+// RUN: -ffp-exception-behavior=strict \
+// RUN: -Wall -Wno-unused -Werror -S %s -o - | FileCheck %s --check-prefix=CHECK-ASM
+
+// FIXME: The lack of constant folding for strict fp breaks this test.
+// See label FIXME-CHECK-ASM.
+
+#include 
+
+volatile vector signed int vsi;
+volatile vector signed long long vsl;
+volatile vector unsigned int vui;
+volatile vector unsigned long long vul;
+volatile vector float vf;
+volatile vector double vd;
+
+volatile float f;
+volatile double d;
+
+const float * volatile cptrf;
+const double * volatile cptrd;
+
+float * volatile ptrf;
+double * volatile ptrd;
+
+volatile int idx;
+
+void test_core(void) {
+  // CHECK-ASM-LABEL: test_core
+  vector float vf2;
+  vector double vd2;
+
+  vf += vec_revb(vec_xl(idx, cptrf));
+  // CHECK-ASM: vlbrf
+  vd += vec_revb(vec_xl(idx, cptrd));
+  // CHECK-ASM: vlbrg
+
+  vec_xst(vec_revb(vf), idx, ptrf);
+  // CHECK-ASM: vstbrf
+  vec_xst(vec_revb(vd), idx, ptrd);
+  // CHECK-ASM: vstbrg
+
+  vf += vec_revb(vec_insert_and_zero(cptrf));
+  // FIXME-CHECK-ASM: vllebrzf
+  vd += vec_revb(vec_insert_and_zero(cptrd));
+  // FIXME-CHECK-ASM: vllebrzg
+
+  vf += vec_revb(vec_splats(f));
+  // CHECK-ASM: vlbrrepf
+  vd += vec_revb(vec_splats(d));
+  // CHECK-ASM: vlbrrepg
+
+  vf2 = vf;
+  vf += vec_revb(vec_insert(f, vec_revb(vf2), 0));
+  // CHECK-ASM: vlebrf
+  vd2 = vd;
+  vd += vec_revb(vec_insert(d, vec_revb(vd2), 0));
+  // CHECK-ASM: vlebrg
+
+  f = vec_extract(vec_revb(vf), 0);
+  // CHECK-ASM: vstebrf
+  d = vec_extract(vec_revb(vd), 0);
+  // CHECK-ASM: vstebrg
+
+  vf += vec_reve(vec_xl(idx, cptrf));
+  // CHECK-ASM: vlerf
+  vd += vec_reve(vec_xl(idx, cptrd));
+  // CHECK-ASM: vlerg
+
+  vec_xst(vec_reve(vf), idx, ptrf);
+  // CHECK-ASM: vsterf
+  vec_xst(vec_reve(vd), idx, ptrd);
+  // CHECK-ASM: vsterg
+}
+
+void test_float(void) {
+  // CHECK-ASM-LABEL: test_float
+
+  vd = vec_double(vsl);
+  // CHECK: call <2 x double> @llvm.experimental.constrained.sitofp.v2f64.v2i64(<2 x i64> %{{.*}}, metadata !{{.*}})
+  // CHECK-ASM: vcdgb
+  vd = vec_double(vul);
+  // CHECK: call <2 x double> @llvm.experimental.constrained.uitofp.v2f64.v2i64(<2 x i64> %{{.*}}, metadata !{{.*}})
+  // CHECK-ASM: vcdlgb
+  vf = vec_float(vsi);
+  // CHECK: call <4 x float> @llvm.experimental.constrained.sitofp.v4f32.v4i32(<4 x i32> %{{.*}}, metadata !{{.*}})
+  // CHECK-ASM: vcefb
+  vf = vec_float(vui);
+  // CHECK: call <4 x float> @llvm.experimental.constrained.uitofp.v4f32.v4i32(<4 x i32> %{{.*}}, metadata !{{.*}})
+  // CHECK-ASM: vcelfb
+
+  vsl = vec_signed(vd);
+  // CHECK: call <2 x i64> @llvm.experimental.constrained.fptosi.v2i64.v2f64(<2 x double> %{{.*}}, metadata !{{.*}})
+  // CHECK-ASM: vcgdb
+  vsi = vec_signed(vf);
+  // CHECK: call <4 x i32> @llvm.experimental.constrained.fptosi.v4i32.v4f32(<4 x float> %{{.*}}, metadata !{{.*}})
+  // CHECK-ASM: vcfeb
+  vul = vec_unsigned(vd);
+  // CHECK: call <2 x i64> @llvm.experimental.constrained.fptoui.v2i64.v2f64(<2 x double> %{{.*}}, metadata !{{.*}})
+  // CHECK-ASM: vclgdb
+  vui = vec_unsigned(vf);
+  // xHECK: fptoui <4 x float> %{{.*}} to <4 x i32>
+  // CHECK: call <4 x i32> @llvm.experimental.constrained.fptoui.v4i32.v4f32(<4 x float> %{{.*}}, metadata !{{.*}})
+  // CHECK-ASM: vclfeb
+}
+
Index: clang/test/CodeGen/builtins-systemz-zvector2-constrained.c
===
--- /dev/null
+++ clang/test/CodeGen/builtins-systemz-zvector2-constrained.c
@@ -0,0 +1,552 @@
+// REQUIRES: systemz-registered-target
+// RUN: %clang_cc1 -target-cpu z14 -triple s390x-linux-gnu \
+// RUN: -O -fzvector -flax-vector-conversions=none \
+// RUN: -ffp-exception-behavior=strict \
+// R

[PATCH] D71854: [SystemZ] Use FNeg in s390x clang builtins

2020-01-02 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn closed this revision.
kpn added a comment.

My pleasure!

Closed with commit 89d6c288ba5adb20d92142e9425f7ab79b8f159e 
.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71854/new/

https://reviews.llvm.org/D71854



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


[PATCH] D71854: [SystemZ] Use FNeg in s390x clang builtins

2020-01-02 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn updated this revision to Diff 235880.
kpn added a comment.

Update now-failing tests.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71854/new/

https://reviews.llvm.org/D71854

Files:
  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

Index: clang/test/CodeGen/builtins-systemz-zvector2.c
===
--- clang/test/CodeGen/builtins-systemz-zvector2.c
+++ clang/test/CodeGen/builtins-systemz-zvector2.c
@@ -686,11 +686,11 @@
 
   vf = vec_nabs(vf);
   // CHECK: [[ABS:%[^ ]+]] = tail call <4 x float> @llvm.fabs.v4f32(<4 x float> %{{.*}})
-  // CHECK-NEXT: fsub <4 x float> , [[ABS]]
+  // CHECK-NEXT: fneg <4 x float> [[ABS]]
   // CHECK-ASM: vflnsb
   vd = vec_nabs(vd);
   // CHECK: [[ABS:%[^ ]+]] = tail call <2 x double> @llvm.fabs.v2f64(<2 x double> %{{.*}})
-  // CHECK-NEXT: fsub <2 x double> , [[ABS]]
+  // CHECK-NEXT: fneg <2 x double> [[ABS]]
   // CHECK-ASM: vflndb
 
   vf = vec_max(vf, vf);
@@ -715,32 +715,32 @@
   // CHECK-ASM: vfmadb
 
   vf = vec_msub(vf, vf, vf);
-  // CHECK: [[NEG:%[^ ]+]] = fsub <4 x float> , %{{.*}}
+  // CHECK: [[NEG:%[^ ]+]] = fneg <4 x float> %{{.*}}
   // CHECK: call <4 x float> @llvm.fma.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x float> [[NEG]])
   // CHECK-ASM: vfmssb
   vd = vec_msub(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]])
   // CHECK-ASM: vfmsdb
 
   vf = vec_nmadd(vf, vf, vf);
   // CHECK: [[RES:%[^ ]+]] = tail call <4 x float> @llvm.fma.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x float> %{{.*}})
-  // CHECK: fsub <4 x float> , [[RES]]
+  // CHECK: fneg <4 x float> [[RES]]
   // CHECK-ASM: vfnmasb
   vd = vec_nmadd(vd, vd, vd);
   // CHECK: [[RES:%[^ ]+]] = tail call <2 x double> @llvm.fma.v2f64(<2 x double> %{{.*}}, <2 x double> %{{.*}}, <2 x double> %{{.*}})
-  // CHECK: fsub <2 x double> , [[RES]]
+  // CHECK: fneg <2 x double> [[RES]]
   // CHECK-ASM: vfnmadb
 
   vf = vec_nmsub(vf, vf, vf);
-  // CHECK: [[NEG:%[^ ]+]] = fsub <4 x float> , %{{.*}}
+  // CHECK: [[NEG:%[^ ]+]] = fneg <4 x float> %{{.*}}
   // CHECK: [[RES:%[^ ]+]] = tail call <4 x float> @llvm.fma.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x float> [[NEG]])
-  // CHECK: fsub <4 x float> , [[RES]]
+  // CHECK: fneg <4 x float> [[RES]]
   // CHECK-ASM: vfnmssb
   vd = vec_nmsub(vd, vd, vd);
-  // CHECK: [[NEG:%[^ ]+]] = fsub <2 x double> , %{{.*}}
+  // CHECK: [[NEG:%[^ ]+]] = fneg <2 x double> %{{.*}}
   // CHECK: [[RES:%[^ ]+]] = tail call <2 x double> @llvm.fma.v2f64(<2 x double> %{{.*}}, <2 x double> %{{.*}}, <2 x double> [[NEG]])
-  // CHECK: fsub <2 x double> , [[RES]]
+  // CHECK: fneg <2 x double> [[RES]]
   // CHECK-ASM: vfnmsdb
 
   vf = vec_sqrt(vf);
Index: clang/test/CodeGen/builtins-systemz-zvector.c
===
--- clang/test/CodeGen/builtins-systemz-zvector.c
+++ clang/test/CodeGen/builtins-systemz-zvector.c
@@ -4442,14 +4442,14 @@
 
   vd = vec_nabs(vd);
   // CHECK: [[ABS:%[^ ]+]] = tail call <2 x double> @llvm.fabs.v2f64(<2 x double> %{{.*}})
-  // CHECK-NEXT: fsub <2 x double> , [[ABS]]
+  // CHECK-NEXT: fneg <2 x double> [[ABS]]
   // CHECK-ASM: vflndb
 
   vd = vec_madd(vd, vd, vd);
   // CHECK: call <2 x double> @llvm.fma.v2f64(<2 x double> %{{.*}}, <2 x double> %{{.*}}, <2 x double> %{{.*}})
   // CHECK-ASM: vfmadb
   vd = vec_msub(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]])
   // CHECK-ASM: vfmsdb
   vd = vec_sqrt(vd);
Index: clang/test/CodeGen/builtins-systemz-vector2.c
===
--- clang/test/CodeGen/builtins-systemz-vector2.c
+++ clang/test/CodeGen/builtins-systemz-vector2.c
@@ -64,11 +64,11 @@
 
   vd = __builtin_s390_vfnmadb(vd, vd, vd);
   // CHECK: [[RES:%[^ ]+]] = call <2 x double> @llvm.fma.v2f64(<2 x double> %{{.*}}, <2 x double> %{{.*}}, <2 x double> %{{.*}})
-  // CHECK: fsub <2 x double> , [[RES]]
+  // CHECK: fneg <2 x double> [[RES]]
   vd = __builtin_s390_vfnmsdb(vd, vd, vd);
-  // CHECK: [[NEG:%[^ ]+]] = fsub <2 x double> , %{{.*}}
+  // CHECK: [[NEG:%[^ ]+]] = fneg <2 x double> %{{.*}}
   // CHECK: [[RES:%[^ ]+]] = call <2 x double> @llvm.fma.v2f64(<2 x double> %{{.*}}, <2 x double> %{{.*}}, <2 x double> [[NEG]])
-  // CHECK: fsub <2 x double> , [[RES]]
+  // CHECK: fneg <2 x double> [[RES]]
 
   vsi = __builtin_s390_vfcesbs(vf, vf, &cc);
   // CHECK: call { <4 x i32>, i32 } @llvm.s390.vfcesbs(<

  1   2   >