[clang] 7cffaf5 - [X89] Ignore -mtune=generic to fix failures some users are seeing after D85384

2020-08-19 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2020-08-19T13:17:57-07:00
New Revision: 7cffaf510f97eabef89b0d45aeb939df40e8e9d3

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

LOG: [X89] Ignore -mtune=generic to fix failures some users are seeing after 
D85384

Some code bases out there pass -mtune=generic to clang. This would have
been ignored prior to D85384. Now it results in an error
because "generic" isn't recognized by isValidCPUName.

And if we let it go through to the backend as a tune
setting it would get the tune flags closer to i386 rather
than a modern CPU.

I plan to change what tune=generic does in the backend in
a future patch. And allow this in the frontend.
But this should be a quick fix for the error some users
are seeing.

Added: 


Modified: 
clang/lib/Driver/ToolChains/Clang.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 4f37590ffbfb..2054069daa5b 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2081,8 +2081,13 @@ void Clang::AddX86TargetArgs(const ArgList ,
 if (Name == "native")
   Name = llvm::sys::getHostCPUName();
 
-CmdArgs.push_back("-tune-cpu");
-CmdArgs.push_back(Args.MakeArgString(Name));
+// Ignore generic either from getHostCPUName or from command line.
+// FIXME: We need to support this eventually but isValidCPUName and the
+// backend aren't ready for it yet.
+if (Name != "generic") {
+  CmdArgs.push_back("-tune-cpu");
+  CmdArgs.push_back(Args.MakeArgString(Name));
+}
   }
 }
 



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


[PATCH] D86193: [CSSPGO] Pseudo probe instrumentation for basic blocks.

2020-08-19 Thread David Li via Phabricator via cfe-commits
davidxl added a comment.

A heads up -- I won't be able to review patch until mid Sept. Hope this is fine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86193

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


[PATCH] D86029: [analyzer] Add modeling for unque_ptr::get()

2020-08-19 Thread Nithin VR via Phabricator via cfe-commits
vrnithinkumar updated this revision to Diff 286675.
vrnithinkumar edited the summary of this revision.
vrnithinkumar added a comment.

- Using conjureSymbolVal in case of missing inner pointer value


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86029

Files:
  clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
  clang/test/Analysis/smart-ptr-text-output.cpp
  clang/test/Analysis/smart-ptr.cpp

Index: clang/test/Analysis/smart-ptr.cpp
===
--- clang/test/Analysis/smart-ptr.cpp
+++ clang/test/Analysis/smart-ptr.cpp
@@ -7,6 +7,7 @@
 
 void clang_analyzer_warnIfReached();
 void clang_analyzer_numTimesReached();
+void clang_analyzer_eval(bool);
 
 void derefAfterMove(std::unique_ptr P) {
   std::unique_ptr Q = std::move(P);
@@ -252,3 +253,26 @@
   P->foo(); // No warning.
   PValid->foo(); // No warning.
 }
+
+void derefOnRawPtrFromGetOnNullPtr() {
+  std::unique_ptr P;
+  P.get()->foo(); // expected-warning {{Called C++ object pointer is null [core.CallAndMessage]}}
+}
+
+void derefOnRawPtrFromGetOnValidPtr() {
+  std::unique_ptr P(new A());
+  P.get()->foo(); // No warning.
+}
+
+void derefOnRawPtrFromGetOnUnknownPtr(std::unique_ptr P) {
+  P.get()->foo(); // No warning.
+}
+
+void derefOnRawPtrFromMultipleGetOnUnknownPtr(std::unique_ptr P) {
+  A *X = P.get();
+  A *Y = P.get();
+  clang_analyzer_eval(X == Y); // expected-warning{{TRUE}}
+  if (!X) {
+Y->foo(); // expected-warning {{Called C++ object pointer is null [core.CallAndMessage]}}
+  }
+}
Index: clang/test/Analysis/smart-ptr-text-output.cpp
===
--- clang/test/Analysis/smart-ptr-text-output.cpp
+++ clang/test/Analysis/smart-ptr-text-output.cpp
@@ -116,3 +116,18 @@
   P->foo(); // expected-warning {{Dereference of null smart pointer 'P' of type 'std::unique_ptr' [cplusplus.Move]}}
   // expected-note@-1 {{Dereference of null smart pointer 'P' of type 'std::unique_ptr'}}
 }
+
+void derefOnRawPtrFromGetOnNullPtr() {
+  std::unique_ptr P; // FIXME: add note "Default constructed smart pointer 'P' is null"
+  P.get()->foo(); // expected-warning {{Called C++ object pointer is null [core.CallAndMessage]}}
+  // expected-note@-1 {{Called C++ object pointer is null}}
+}
+
+void derefOnRawPtrFromGetOnValidPtr() {
+  std::unique_ptr P(new A());
+  P.get()->foo(); // No warning.
+}
+
+void derefOnRawPtrFromGetOnUnknownPtr(std::unique_ptr P) {
+  P.get()->foo(); // No warning.
+}
Index: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
+++ clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
@@ -56,13 +56,15 @@
   void handleReset(const CallEvent , CheckerContext ) const;
   void handleRelease(const CallEvent , CheckerContext ) const;
   void handleSwap(const CallEvent , CheckerContext ) const;
+  void handleGet(const CallEvent , CheckerContext ) const;
 
   using SmartPtrMethodHandlerFn =
   void (SmartPtrModeling::*)(const CallEvent , CheckerContext &) const;
   CallDescriptionMap SmartPtrMethodHandlers{
   {{"reset"}, ::handleReset},
   {{"release"}, ::handleRelease},
-  {{"swap", 1}, ::handleSwap}};
+  {{"swap", 1}, ::handleSwap},
+  {{"get"}, ::handleGet}};
 };
 } // end of anonymous namespace
 
@@ -345,6 +347,33 @@
   }));
 }
 
+void SmartPtrModeling::handleGet(const CallEvent ,
+ CheckerContext ) const {
+  ProgramStateRef State = C.getState();
+  const auto *IC = dyn_cast();
+  if (!IC)
+return;
+
+  const MemRegion *ThisRegion = IC->getCXXThisVal().getAsRegion();
+  if (!ThisRegion)
+return;
+
+  SVal InnerPointerVal;
+  if (const auto *InnerValPtr = State->get(ThisRegion)) {
+InnerPointerVal = *InnerValPtr;
+  } else {
+const auto *CallExpr = Call.getOriginExpr();
+InnerPointerVal = C.getSValBuilder().conjureSymbolVal(
+CallExpr, C.getLocationContext(), Call.getResultType(), C.blockCount());
+State = State->set(ThisRegion, InnerPointerVal);
+  }
+
+  State = State->BindExpr(Call.getOriginExpr(), C.getLocationContext(),
+  InnerPointerVal);
+  // TODO: Add NoteTag, for how the raw pointer got using 'get' method.
+  C.addTransition(State);
+}
+
 void ento::registerSmartPtrModeling(CheckerManager ) {
   auto *Checker = Mgr.registerChecker();
   Checker->ModelSmartPtrDereference =
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D83211: Factor out call to EXTRACTOR in generateCC1CommandLine

2020-08-19 Thread Michael Spencer via Phabricator via cfe-commits
Bigcheese added inline comments.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:3938
+  if ((FLAGS)::CC1Option) {
\
+const auto  = EXTRACTOR(this->KEYPATH);  
\
+if (ALWAYS_EMIT || Extracted != DEFAULT_VALUE) 
\

Will this ever have an issue with lifetime? I can see various values for 
`EXTRACTOR` causing issues here. https://abseil.io/tips/107


It would be good to at least document somewhere the restrictions on `EXTRACTOR`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83211

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


[PATCH] D83298: Add ability to make fixups to CompilerInvocation after option parsing

2020-08-19 Thread Michael Spencer via Phabricator via cfe-commits
Bigcheese accepted this revision.
Bigcheese 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/D83298/new/

https://reviews.llvm.org/D83298

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


[PATCH] D81083: [Clang] Allow "vector_size" applied to Booleans

2020-08-19 Thread Kazushi Marukawa via Phabricator via cfe-commits
kaz7 added a comment.

Thank you preparing this i1 patch and doing it on clang side only.  We were 
testing this patch and sending problem reports.  Now, we can use this patch 
without modifying llvm code.  We can define vector mask types like below.  
Then, we can define intrinsic functions using this type.  Those are converted 
to mask type, e.g v256i1, in the back end without adding bitcasts in 
ISelLowering.cpp.  It helps developers very much.  I hope this extension is 
accepted.

  typedef double __vr __attribute__((__vector_size__(2048)));
  #if __STDC_VERSION__ >= 199901L
  // For C99
  typedef _Bool __vm__attribute__((__vector_size__(32)));
  typedef _Bool __vm256 __attribute__((__vector_size__(32)));
  typedef _Bool __vm512 __attribute__((__vector_size__(64)));
  #else
  #ifdef __cplusplus
  // For C++
  typedef bool __vm__attribute__((__vector_size__(32)));
  typedef bool __vm256 __attribute__((__vector_size__(32)));
  typedef bool __vm512 __attribute__((__vector_size__(64)));
  #else
  #error need C++ or C99 to use vector intrinsics for VE
  #endif
  #endif


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81083

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


[PATCH] D85031: [builtins] Unify the softfloat division implementation

2020-08-19 Thread Anatoly Trosinenko via Phabricator via cfe-commits
atrosinenko updated this revision to Diff 286516.
atrosinenko added a comment.

Rebase the entire patch stack against the up-to-date master and re-upload.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85031

Files:
  compiler-rt/lib/builtins/divdf3.c
  compiler-rt/lib/builtins/divsf3.c
  compiler-rt/lib/builtins/divtf3.c
  compiler-rt/lib/builtins/fp_div_impl.inc
  compiler-rt/lib/builtins/fp_lib.h
  compiler-rt/lib/builtins/int_util.h
  compiler-rt/test/builtins/Unit/divdf3_test.c

Index: compiler-rt/test/builtins/Unit/divdf3_test.c
===
--- compiler-rt/test/builtins/Unit/divdf3_test.c
+++ compiler-rt/test/builtins/Unit/divdf3_test.c
@@ -92,5 +92,13 @@
 if (test__divdf3(0x1.0p+0, 0x1.0001p+0, UINT64_C(0x3fefffe0)))
   return 1;
 
+// some misc test cases obtained by fuzzing against h/w implementation
+if (test__divdf3(0x1.fdc239dd64735p-658, -0x1.fff9364c0843fp-948, UINT64_C(0xd20fdc8fc0ceffb1)))
+  return 1;
+if (test__divdf3(-0x1.78abb261d47c8p+794, 0x1.fb01d537cc5aep+266, UINT64_C(0xe0e7c6148ffc23e3)))
+  return 1;
+if (test__divdf3(-0x1.da7dfe6048b8bp-875, 0x1.ffc7ea3ff60a4p-610, UINT64_C(0xaf5dab1fe0269e2a)))
+  return 1;
+
 return 0;
 }
Index: compiler-rt/lib/builtins/int_util.h
===
--- compiler-rt/lib/builtins/int_util.h
+++ compiler-rt/lib/builtins/int_util.h
@@ -28,4 +28,20 @@
 #define COMPILE_TIME_ASSERT2(expr, cnt)\
   typedef char ct_assert_##cnt[(expr) ? 1 : -1] UNUSED
 
+// Force unrolling the code specified to be repeated N times.
+#define REPEAT_0_TIMES(code_to_repeat) /* do nothing */
+#define REPEAT_1_TIMES(code_to_repeat) code_to_repeat
+#define REPEAT_2_TIMES(code_to_repeat) \
+  REPEAT_1_TIMES(code_to_repeat)   \
+  code_to_repeat
+#define REPEAT_3_TIMES(code_to_repeat) \
+  REPEAT_2_TIMES(code_to_repeat)   \
+  code_to_repeat
+#define REPEAT_4_TIMES(code_to_repeat) \
+  REPEAT_3_TIMES(code_to_repeat)   \
+  code_to_repeat
+
+#define REPEAT_N_TIMES_(N, code_to_repeat) REPEAT_##N##_TIMES(code_to_repeat)
+#define REPEAT_N_TIMES(N, code_to_repeat) REPEAT_N_TIMES_(N, code_to_repeat)
+
 #endif // INT_UTIL_H
Index: compiler-rt/lib/builtins/fp_lib.h
===
--- compiler-rt/lib/builtins/fp_lib.h
+++ compiler-rt/lib/builtins/fp_lib.h
@@ -49,9 +49,12 @@
 
 #if defined SINGLE_PRECISION
 
+typedef uint16_t half_rep_t;
 typedef uint32_t rep_t;
+typedef uint64_t twice_rep_t;
 typedef int32_t srep_t;
 typedef float fp_t;
+#define HALF_REP_C UINT16_C
 #define REP_C UINT32_C
 #define significandBits 23
 
@@ -67,9 +70,11 @@
 
 #elif defined DOUBLE_PRECISION
 
+typedef uint32_t half_rep_t;
 typedef uint64_t rep_t;
 typedef int64_t srep_t;
 typedef double fp_t;
+#define HALF_REP_C UINT32_C
 #define REP_C UINT64_C
 #define significandBits 52
 
@@ -111,9 +116,11 @@
 #elif defined QUAD_PRECISION
 #if __LDBL_MANT_DIG__ == 113 && defined(__SIZEOF_INT128__)
 #define CRT_LDBL_128BIT
+typedef uint64_t half_rep_t;
 typedef __uint128_t rep_t;
 typedef __int128_t srep_t;
 typedef long double fp_t;
+#define HALF_REP_C UINT64_C
 #define REP_C (__uint128_t)
 // Note: Since there is no explicit way to tell compiler the constant is a
 // 128-bit integer, we let the constant be casted to 128-bit integer
Index: compiler-rt/lib/builtins/fp_div_impl.inc
===
--- /dev/null
+++ compiler-rt/lib/builtins/fp_div_impl.inc
@@ -0,0 +1,310 @@
+//===-- lib/fp_div_impl.inc - Floating point division -*- C -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file implements soft-float division with the IEEE-754 default
+// rounding (to nearest, ties to even).
+//
+//===--===//
+
+#include "fp_lib.h"
+
+#define HW (typeWidth / 2)
+#define loMask (REP_C(-1) >> HW)
+
+#define NUMBER_OF_ITERATIONS   \
+  (NUMBER_OF_HALF_ITERATIONS + NUMBER_OF_FULL_ITERATIONS)
+
+#if NUMBER_OF_FULL_ITERATIONS < 1
+#error At least one full iteration is required
+#endif
+
+static __inline fp_t __divXf3__(fp_t a, fp_t b) {
+
+  const unsigned int aExponent = toRep(a) >> significandBits & maxExponent;
+  const 

[PATCH] D84932: [builtins] Add more test cases for __div[sdt]f3 LibCalls

2020-08-19 Thread Anatoly Trosinenko via Phabricator via cfe-commits
atrosinenko updated this revision to Diff 286514.
atrosinenko added a comment.

Rebase the entire patch stack against the up-to-date master and re-upload.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84932

Files:
  compiler-rt/test/builtins/Unit/divdf3_test.c
  compiler-rt/test/builtins/Unit/divsf3_test.c
  compiler-rt/test/builtins/Unit/divtf3_test.c
  compiler-rt/test/builtins/Unit/fp_test.h

Index: compiler-rt/test/builtins/Unit/fp_test.h
===
--- compiler-rt/test/builtins/Unit/fp_test.h
+++ compiler-rt/test/builtins/Unit/fp_test.h
@@ -253,14 +253,29 @@
 return fromRep32(0x7f80U);
 }
 
+static inline float makeNegativeInf32(void)
+{
+return fromRep32(0xff80U);
+}
+
 static inline double makeInf64(void)
 {
 return fromRep64(0x7ff0UL);
 }
 
+static inline double makeNegativeInf64(void)
+{
+return fromRep64(0xfff0UL);
+}
+
 #if __LDBL_MANT_DIG__ == 113
 static inline long double makeInf128(void)
 {
 return fromRep128(0x7fffUL, 0x0UL);
 }
+
+static inline long double makeNegativeInf128(void)
+{
+return fromRep128(0xUL, 0x0UL);
+}
 #endif
Index: compiler-rt/test/builtins/Unit/divtf3_test.c
===
--- compiler-rt/test/builtins/Unit/divtf3_test.c
+++ compiler-rt/test/builtins/Unit/divtf3_test.c
@@ -32,6 +32,8 @@
 int main()
 {
 #if __LDBL_MANT_DIG__ == 113
+// Returned NaNs are assumed to be qNaN by default
+
 // qNaN / any = qNaN
 if (test__divtf3(makeQNaN128(),
  0x1.23456789abcdefp+5L,
@@ -39,17 +41,111 @@
  UINT64_C(0x0)))
 return 1;
 // NaN / any = NaN
-if (test__divtf3(makeNaN128(UINT64_C(0x80003000)),
+if (test__divtf3(makeNaN128(UINT64_C(0x3000)),
  0x1.23456789abcdefp+5L,
  UINT64_C(0x7fff8000),
  UINT64_C(0x0)))
 return 1;
-// inf / any = inf
-if (test__divtf3(makeInf128(),
- 0x1.23456789abcdefp+5L,
+// any / qNaN = qNaN
+if (test__divtf3(0x1.23456789abcdefp+5L,
+ makeQNaN128(),
+ UINT64_C(0x7fff8000),
+ UINT64_C(0x0)))
+return 1;
+// any / NaN = NaN
+if (test__divtf3(0x1.23456789abcdefp+5L,
+ makeNaN128(UINT64_C(0x3000)),
+ UINT64_C(0x7fff8000),
+ UINT64_C(0x0)))
+return 1;
+
+// +Inf / positive = +Inf
+if (test__divtf3(makeInf128(), 3.L,
  UINT64_C(0x7fff),
  UINT64_C(0x0)))
 return 1;
+// +Inf / negative = -Inf
+if (test__divtf3(makeInf128(), -3.L,
+ UINT64_C(0x),
+ UINT64_C(0x0)))
+return 1;
+// -Inf / positive = -Inf
+if (test__divtf3(makeNegativeInf128(), 3.L,
+ UINT64_C(0x),
+ UINT64_C(0x0)))
+return 1;
+// -Inf / negative = +Inf
+if (test__divtf3(makeNegativeInf128(), -3.L,
+ UINT64_C(0x7fff),
+ UINT64_C(0x0)))
+return 1;
+
+// Inf / Inf = NaN
+if (test__divtf3(makeInf128(), makeInf128(),
+ UINT64_C(0x7fff8000),
+ UINT64_C(0x0)))
+return 1;
+// 0.0 / 0.0 = NaN
+if (test__divtf3(+0x0.0p+0L, +0x0.0p+0L,
+ UINT64_C(0x7fff8000),
+ UINT64_C(0x0)))
+return 1;
+// +0.0 / +Inf = +0.0
+if (test__divtf3(+0x0.0p+0L, makeInf128(),
+ UINT64_C(0x0),
+ UINT64_C(0x0)))
+return 1;
+// +Inf / +0.0 = +Inf
+if (test__divtf3(makeInf128(), +0x0.0p+0L,
+ UINT64_C(0x7fff8000),
+ UINT64_C(0x0)))
+return 1;
+
+// positive / +0.0 = +Inf
+if (test__divtf3(+1.0L, +0x0.0p+0L,
+ UINT64_C(0x7fff),
+ UINT64_C(0x0)))
+return 1;
+// positive / -0.0 = -Inf
+if (test__divtf3(+1.0L, -0x0.0p+0L,
+ UINT64_C(0x),
+ UINT64_C(0x0)))
+return 1;
+// negative / +0.0 = -Inf
+if (test__divtf3(-1.0L, +0x0.0p+0L,
+ UINT64_C(0x),
+ UINT64_C(0x0)))
+return 1;
+// negative / -0.0 = +Inf
+if (test__divtf3(-1.0L, -0x0.0p+0L,
+ UINT64_C(0x7fff),
+ UINT64_C(0x0)))
+return 1;
+
+// 1/3
+if (test__divtf3(1.L, 3.L,
+ UINT64_C(0x3ffd),
+ 

[PATCH] D85032: [builtins] Make divXf3 handle denormal results

2020-08-19 Thread Anatoly Trosinenko via Phabricator via cfe-commits
atrosinenko updated this revision to Diff 286517.
atrosinenko added a comment.

Rebase the entire patch stack against the up-to-date master and re-upload.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85032

Files:
  compiler-rt/lib/builtins/fp_div_impl.inc
  compiler-rt/test/builtins/Unit/divdf3_test.c
  compiler-rt/test/builtins/Unit/divsf3_test.c
  compiler-rt/test/builtins/Unit/divtf3_test.c

Index: compiler-rt/test/builtins/Unit/divtf3_test.c
===
--- compiler-rt/test/builtins/Unit/divtf3_test.c
+++ compiler-rt/test/builtins/Unit/divtf3_test.c
@@ -146,6 +146,13 @@
  UINT64_C(0xfffe)))
 return 1;
 
+// smallest normal value divided by 2.0
+if (test__divtf3(0x1.0p-16382L, 2.L, UINT64_C(0x8000), UINT64_C(0x0)))
+  return 1;
+// smallest subnormal result
+if (test__divtf3(0x1.0p-1022L, 0x1p+52L, UINT64_C(0x0), UINT64_C(0x1)))
+  return 1;
+
 // any / any
 if (test__divtf3(0x1.a23b45362464523375893ab4cdefp+5L,
  0x1.eedcbaba3a94546558237654321fp-1L,
Index: compiler-rt/test/builtins/Unit/divsf3_test.c
===
--- compiler-rt/test/builtins/Unit/divsf3_test.c
+++ compiler-rt/test/builtins/Unit/divsf3_test.c
@@ -92,5 +92,20 @@
 if (test__divsf3(0x1.0p+0F, 0x1.0001p+0F, UINT32_C(0x3f7fff00)))
   return 1;
 
+// smallest normal value divided by 2.0
+if (test__divsf3(0x1.0p-126F, 2.0F, UINT32_C(0x0040)))
+  return 1;
+// smallest subnormal result
+if (test__divsf3(0x1.0p-126F, 0x1p+23F, UINT32_C(0x0001)))
+  return 1;
+
+// some misc test cases obtained by fuzzing against h/w implementation
+if (test__divsf3(-0x1.3e75e6p-108F, -0x1.cf372p+38F, UINT32_C(0x0006)))
+  return 1;
+if (test__divsf3(0x1.e77c54p+81F, -0x1.e77c52p-47F, UINT32_C(0xff80)))
+  return 1;
+if (test__divsf3(0x1.fep-126F, 2.F, UINT32_C(0x0080)))
+  return 1;
+
 return 0;
 }
Index: compiler-rt/test/builtins/Unit/divdf3_test.c
===
--- compiler-rt/test/builtins/Unit/divdf3_test.c
+++ compiler-rt/test/builtins/Unit/divdf3_test.c
@@ -92,6 +92,13 @@
 if (test__divdf3(0x1.0p+0, 0x1.0001p+0, UINT64_C(0x3fefffe0)))
   return 1;
 
+// smallest normal value divided by 2.0
+if (test__divdf3(0x1.0p-1022, 2., UINT64_C(0x0008)))
+  return 1;
+// smallest subnormal result
+if (test__divdf3(0x1.0p-1022, 0x1.0p+52, UINT64_C(0x0001)))
+  return 1;
+
 // some misc test cases obtained by fuzzing against h/w implementation
 if (test__divdf3(0x1.fdc239dd64735p-658, -0x1.fff9364c0843fp-948, UINT64_C(0xd20fdc8fc0ceffb1)))
   return 1;
@@ -99,6 +106,12 @@
   return 1;
 if (test__divdf3(-0x1.da7dfe6048b8bp-875, 0x1.ffc7ea3ff60a4p-610, UINT64_C(0xaf5dab1fe0269e2a)))
   return 1;
+if (test__divdf3(0x1.0p-1022, 0x1.9p+5, UINT64_C(0x51eb851eb852)))
+  return 1;
+if (test__divdf3(0x1.0p-1022, 0x1.0028p+41, UINT64_C(0x07ff)))
+  return 1;
+if (test__divdf3(0x1.0p-1022, 0x1.0028p+52, UINT64_C(0x1)))
+  return 1;
 
 return 0;
 }
Index: compiler-rt/lib/builtins/fp_div_impl.inc
===
--- compiler-rt/lib/builtins/fp_div_impl.inc
+++ compiler-rt/lib/builtins/fp_div_impl.inc
@@ -249,6 +249,7 @@
   if (quotient_UQ1 < (implicitBit << 1)) {
 residualLo = (aSignificand << (significandBits + 1)) - quotient_UQ1 * bSignificand;
 writtenExponent -= 1;
+aSignificand <<= 1;
 
 // the error is doubled
   } else {
@@ -278,19 +279,25 @@
   // Now, quotient_UQ1_SB <= the correctly-rounded result
   // and may need taking NextAfter() up to 3 times (see error estimates above)
   // r = a - b * q
+  rep_t absResult;
+  if (writtenExponent > 0) {
+// Clear the implicit bit
+absResult = quotient_UQ1 & significandMask;
+// Insert the exponent
+absResult |= (rep_t)writtenExponent << significandBits;
+residualLo <<= 1;
+  } else {
+// Prevent shift amount from being negative
+if (significandBits + writtenExponent < 0)
+  return fromRep(quotientSign);
 
-  if (writtenExponent < 0) {
-// Result is definitely subnormal, flushing to zero
-return fromRep(quotientSign);
-  }
+absResult = quotient_UQ1 >> (-writtenExponent + 1);
 
-  // Clear the implicit bit
-  rep_t absResult = quotient_UQ1 & significandMask;
-  // Insert the exponent
-  absResult |= (rep_t)writtenExponent << significandBits;
+// multiplied by two to prevent shift amount to be negative
+residualLo = (aSignificand << (significandBits + writtenExponent)) - (absResult * bSignificand << 1);
+  }
 
   // Round
-  residualLo <<= 1;
 

[PATCH] D85731: [NFC][builtins] Make softfloat-related errors less noisy

2020-08-19 Thread Anatoly Trosinenko via Phabricator via cfe-commits
atrosinenko updated this revision to Diff 286513.
atrosinenko added a comment.

Rebase the entire patch stack against the up-to-date master and re-upload.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85731

Files:
  compiler-rt/lib/builtins/fp_lib.h


Index: compiler-rt/lib/builtins/fp_lib.h
===
--- compiler-rt/lib/builtins/fp_lib.h
+++ compiler-rt/lib/builtins/fp_lib.h
@@ -26,6 +26,15 @@
 #include 
 #include 
 
+#if (defined(SINGLE_PRECISION) + defined(DOUBLE_PRECISION) +   
\
+ defined(QUAD_PRECISION)) != 1
+#error Exactly one of SINGLE_PRECISION, DOUBLE_PRECISION or QUAD_PRECISION 
must be defined.
+// Now, turn on some arbitrary one of the three precision settings (except for
+// QUAD_PRECISION that has some specific requirements), so fp_*_impl.inc files
+// could be validated by clang-tidy in a more meaningful way.
+#define SINGLE_PRECISION
+#endif
+
 // x86_64 FreeBSD prior v9.3 define fixed-width types incorrectly in
 // 32-bit mode.
 #if defined(__FreeBSD__) && defined(__i386__)
@@ -195,6 +204,8 @@
 #undef Word_FullMask
 #endif // __LDBL_MANT_DIG__ == 113 && __SIZEOF_INT128__
 #else
+// Should never be reached due to the check for precison-related macro
+// at the top of this file. Recheck it here just in case...
 #error SINGLE_PRECISION, DOUBLE_PRECISION or QUAD_PRECISION must be defined.
 #endif
 


Index: compiler-rt/lib/builtins/fp_lib.h
===
--- compiler-rt/lib/builtins/fp_lib.h
+++ compiler-rt/lib/builtins/fp_lib.h
@@ -26,6 +26,15 @@
 #include 
 #include 
 
+#if (defined(SINGLE_PRECISION) + defined(DOUBLE_PRECISION) +   \
+ defined(QUAD_PRECISION)) != 1
+#error Exactly one of SINGLE_PRECISION, DOUBLE_PRECISION or QUAD_PRECISION must be defined.
+// Now, turn on some arbitrary one of the three precision settings (except for
+// QUAD_PRECISION that has some specific requirements), so fp_*_impl.inc files
+// could be validated by clang-tidy in a more meaningful way.
+#define SINGLE_PRECISION
+#endif
+
 // x86_64 FreeBSD prior v9.3 define fixed-width types incorrectly in
 // 32-bit mode.
 #if defined(__FreeBSD__) && defined(__i386__)
@@ -195,6 +204,8 @@
 #undef Word_FullMask
 #endif // __LDBL_MANT_DIG__ == 113 && __SIZEOF_INT128__
 #else
+// Should never be reached due to the check for precison-related macro
+// at the top of this file. Recheck it here just in case...
 #error SINGLE_PRECISION, DOUBLE_PRECISION or QUAD_PRECISION must be defined.
 #endif
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 0353848 - [Clang][SVE] NFC: Move info about ACLE types into separate function.

2020-08-19 Thread Sander de Smalen via cfe-commits

Author: Sander de Smalen
Date: 2020-08-19T11:04:20+01:00
New Revision: 0353848cc94f0fc23a953f8f420be7ee3342c8dc

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

LOG: [Clang][SVE] NFC: Move info about ACLE types into separate function.

This function returns a struct `BuiltinVectorTypeInfo` that contains
the builtin vector's element type, element count and number of vectors
(used for vector tuples).

Reviewed By: c-rhodes

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

Added: 


Modified: 
clang/include/clang/AST/ASTContext.h
clang/lib/AST/ASTContext.cpp
clang/lib/CodeGen/CodeGenTypes.cpp

Removed: 




diff  --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index b5fb1a4da480..3996644c9c85 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -61,6 +61,7 @@
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/Compiler.h"
+#include "llvm/Support/TypeSize.h"
 #include 
 #include 
 #include 
@@ -1301,6 +1302,21 @@ class ASTContext : public RefCountedBase {
   /// Returns a vla type where known sizes are replaced with [*].
   QualType getVariableArrayDecayedType(QualType Ty) const;
 
+  // Convenience struct to return information about a builtin vector type.
+  struct BuiltinVectorTypeInfo {
+QualType ElementType;
+llvm::ElementCount EC;
+unsigned NumVectors;
+BuiltinVectorTypeInfo(QualType ElementType, llvm::ElementCount EC,
+  unsigned NumVectors)
+: ElementType(ElementType), EC(EC), NumVectors(NumVectors) {}
+  };
+
+  /// Returns the element type, element count and number of vectors
+  /// (in case of tuple) for a builtin vector type.
+  BuiltinVectorTypeInfo
+  getBuiltinVectorTypeInfo(const BuiltinType *VecTy) const;
+
   /// Return the unique reference to a scalable vector type of the specified
   /// element type and scalable number of elements.
   ///

diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index fd3e94fbf3c2..c51629ecfd53 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -3711,6 +3711,119 @@ QualType ASTContext::getIncompleteArrayType(QualType 
elementType,
   return QualType(newType, 0);
 }
 
+ASTContext::BuiltinVectorTypeInfo
+ASTContext::getBuiltinVectorTypeInfo(const BuiltinType *Ty) const {
+#define SVE_INT_ELTTY(BITS, ELTS, SIGNED, NUMVECTORS)  
\
+  {getIntTypeForBitwidth(BITS, SIGNED), llvm::ElementCount(ELTS, true),
\
+   NUMVECTORS};
+
+#define SVE_ELTTY(ELTTY, ELTS, NUMVECTORS) 
\
+  {ELTTY, llvm::ElementCount(ELTS, true), NUMVECTORS};
+
+  switch (Ty->getKind()) {
+  default:
+llvm_unreachable("Unsupported builtin vector type");
+  case BuiltinType::SveInt8:
+return SVE_INT_ELTTY(8, 16, true, 1);
+  case BuiltinType::SveUint8:
+return SVE_INT_ELTTY(8, 16, false, 1);
+  case BuiltinType::SveInt8x2:
+return SVE_INT_ELTTY(8, 16, true, 2);
+  case BuiltinType::SveUint8x2:
+return SVE_INT_ELTTY(8, 16, false, 2);
+  case BuiltinType::SveInt8x3:
+return SVE_INT_ELTTY(8, 16, true, 3);
+  case BuiltinType::SveUint8x3:
+return SVE_INT_ELTTY(8, 16, false, 3);
+  case BuiltinType::SveInt8x4:
+return SVE_INT_ELTTY(8, 16, true, 4);
+  case BuiltinType::SveUint8x4:
+return SVE_INT_ELTTY(8, 16, false, 4);
+  case BuiltinType::SveInt16:
+return SVE_INT_ELTTY(16, 8, true, 1);
+  case BuiltinType::SveUint16:
+return SVE_INT_ELTTY(16, 8, false, 1);
+  case BuiltinType::SveInt16x2:
+return SVE_INT_ELTTY(16, 8, true, 2);
+  case BuiltinType::SveUint16x2:
+return SVE_INT_ELTTY(16, 8, false, 2);
+  case BuiltinType::SveInt16x3:
+return SVE_INT_ELTTY(16, 8, true, 3);
+  case BuiltinType::SveUint16x3:
+return SVE_INT_ELTTY(16, 8, false, 3);
+  case BuiltinType::SveInt16x4:
+return SVE_INT_ELTTY(16, 8, true, 4);
+  case BuiltinType::SveUint16x4:
+return SVE_INT_ELTTY(16, 8, false, 4);
+  case BuiltinType::SveInt32:
+return SVE_INT_ELTTY(32, 4, true, 1);
+  case BuiltinType::SveUint32:
+return SVE_INT_ELTTY(32, 4, false, 1);
+  case BuiltinType::SveInt32x2:
+return SVE_INT_ELTTY(32, 4, true, 2);
+  case BuiltinType::SveUint32x2:
+return SVE_INT_ELTTY(32, 4, false, 2);
+  case BuiltinType::SveInt32x3:
+return SVE_INT_ELTTY(32, 4, true, 3);
+  case BuiltinType::SveUint32x3:
+return SVE_INT_ELTTY(32, 4, false, 3);
+  case BuiltinType::SveInt32x4:
+return SVE_INT_ELTTY(32, 4, true, 4);
+  case BuiltinType::SveUint32x4:
+return SVE_INT_ELTTY(32, 4, false, 4);
+  case BuiltinType::SveInt64:
+return SVE_INT_ELTTY(64, 2, true, 1);
+  case BuiltinType::SveUint64:
+return 

[PATCH] D86100: [Clang][SVE] NFC: Move info about ACLE types into separate function.

2020-08-19 Thread Sander de Smalen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0353848cc94f: [Clang][SVE] NFC: Move info about ACLE types 
into separate function. (authored by sdesmalen).

Changed prior to commit:
  https://reviews.llvm.org/D86100?vs=286113=286520#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86100

Files:
  clang/include/clang/AST/ASTContext.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/CodeGen/CodeGenTypes.cpp

Index: clang/lib/CodeGen/CodeGenTypes.cpp
===
--- clang/lib/CodeGen/CodeGenTypes.cpp
+++ clang/lib/CodeGen/CodeGenTypes.cpp
@@ -534,99 +534,60 @@
 case BuiltinType::OCLReserveID:
   ResultType = CGM.getOpenCLRuntime().convertOpenCLSpecificType(Ty);
   break;
-#define GET_SVE_INT_VEC(BITS, ELTS)\
-  llvm::ScalableVectorType::get(   \
-  llvm::IntegerType::get(getLLVMContext(), BITS), ELTS);
 case BuiltinType::SveInt8:
 case BuiltinType::SveUint8:
-  return GET_SVE_INT_VEC(8, 16);
 case BuiltinType::SveInt8x2:
 case BuiltinType::SveUint8x2:
-  return GET_SVE_INT_VEC(8, 32);
 case BuiltinType::SveInt8x3:
 case BuiltinType::SveUint8x3:
-  return GET_SVE_INT_VEC(8, 48);
 case BuiltinType::SveInt8x4:
 case BuiltinType::SveUint8x4:
-  return GET_SVE_INT_VEC(8, 64);
 case BuiltinType::SveInt16:
 case BuiltinType::SveUint16:
-  return GET_SVE_INT_VEC(16, 8);
 case BuiltinType::SveInt16x2:
 case BuiltinType::SveUint16x2:
-  return GET_SVE_INT_VEC(16, 16);
 case BuiltinType::SveInt16x3:
 case BuiltinType::SveUint16x3:
-  return GET_SVE_INT_VEC(16, 24);
 case BuiltinType::SveInt16x4:
 case BuiltinType::SveUint16x4:
-  return GET_SVE_INT_VEC(16, 32);
 case BuiltinType::SveInt32:
 case BuiltinType::SveUint32:
-  return GET_SVE_INT_VEC(32, 4);
 case BuiltinType::SveInt32x2:
 case BuiltinType::SveUint32x2:
-  return GET_SVE_INT_VEC(32, 8);
 case BuiltinType::SveInt32x3:
 case BuiltinType::SveUint32x3:
-  return GET_SVE_INT_VEC(32, 12);
 case BuiltinType::SveInt32x4:
 case BuiltinType::SveUint32x4:
-  return GET_SVE_INT_VEC(32, 16);
 case BuiltinType::SveInt64:
 case BuiltinType::SveUint64:
-  return GET_SVE_INT_VEC(64, 2);
 case BuiltinType::SveInt64x2:
 case BuiltinType::SveUint64x2:
-  return GET_SVE_INT_VEC(64, 4);
 case BuiltinType::SveInt64x3:
 case BuiltinType::SveUint64x3:
-  return GET_SVE_INT_VEC(64, 6);
 case BuiltinType::SveInt64x4:
 case BuiltinType::SveUint64x4:
-  return GET_SVE_INT_VEC(64, 8);
 case BuiltinType::SveBool:
-  return GET_SVE_INT_VEC(1, 16);
-#undef GET_SVE_INT_VEC
-#define GET_SVE_FP_VEC(TY, ISFP16, ELTS)   \
-  llvm::ScalableVectorType::get(   \
-  getTypeForFormat(getLLVMContext(),   \
-   Context.getFloatTypeSemantics(Context.TY),  \
-   /* UseNativeHalf = */ ISFP16),  \
-  ELTS);
 case BuiltinType::SveFloat16:
-  return GET_SVE_FP_VEC(HalfTy, true, 8);
 case BuiltinType::SveFloat16x2:
-  return GET_SVE_FP_VEC(HalfTy, true, 16);
 case BuiltinType::SveFloat16x3:
-  return GET_SVE_FP_VEC(HalfTy, true, 24);
 case BuiltinType::SveFloat16x4:
-  return GET_SVE_FP_VEC(HalfTy, true, 32);
 case BuiltinType::SveFloat32:
-  return GET_SVE_FP_VEC(FloatTy, false, 4);
 case BuiltinType::SveFloat32x2:
-  return GET_SVE_FP_VEC(FloatTy, false, 8);
 case BuiltinType::SveFloat32x3:
-  return GET_SVE_FP_VEC(FloatTy, false, 12);
 case BuiltinType::SveFloat32x4:
-  return GET_SVE_FP_VEC(FloatTy, false, 16);
 case BuiltinType::SveFloat64:
-  return GET_SVE_FP_VEC(DoubleTy, false, 2);
 case BuiltinType::SveFloat64x2:
-  return GET_SVE_FP_VEC(DoubleTy, false, 4);
 case BuiltinType::SveFloat64x3:
-  return GET_SVE_FP_VEC(DoubleTy, false, 6);
 case BuiltinType::SveFloat64x4:
-  return GET_SVE_FP_VEC(DoubleTy, false, 8);
 case BuiltinType::SveBFloat16:
-  return GET_SVE_FP_VEC(BFloat16Ty, false, 8);
 case BuiltinType::SveBFloat16x2:
-  return GET_SVE_FP_VEC(BFloat16Ty, false, 16);
 case BuiltinType::SveBFloat16x3:
-  return GET_SVE_FP_VEC(BFloat16Ty, false, 24);
-case BuiltinType::SveBFloat16x4:
-  return GET_SVE_FP_VEC(BFloat16Ty, false, 32);
-#undef GET_SVE_FP_VEC
+case BuiltinType::SveBFloat16x4: {
+  ASTContext::BuiltinVectorTypeInfo Info =
+  Context.getBuiltinVectorTypeInfo(cast(Ty));
+  return llvm::ScalableVectorType::get(ConvertType(Info.ElementType),
+

[PATCH] D86100: [Clang][SVE] NFC: Move info about ACLE types into separate function.

2020-08-19 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen added inline comments.



Comment at: clang/include/clang/AST/ASTContext.h:1318
+  BuiltinVectorTypeInfo
+  getElementTypeForBuiltinVector(const BuiltinType *VecTy) const;
+

c-rhodes wrote:
> nit: not sure on the name here since it's returning more than the element 
> type, how about `getBuiltinVectorTypeInfo`?
Thanks, you're right that was a misnomer. I've taken your suggestion (and also 
updated the comment).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86100

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


[PATCH] D86101: [AArch64][SVE] Add missing debug info for ACLE types.

2020-08-19 Thread Richard Sandiford via Phabricator via cfe-commits
rsandifo-arm added inline comments.



Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:748
+  llvm::DINodeArray SubscriptArray = DBuilder.getOrCreateArray(Subscript);
+  llvm::DIType *ElemTy =
+  getOrCreateType(Info.ElementType, TheCU->getFile());

I might be misreading the code, but if we're representing svbool_t as a bitmask 
(which is a good approach IMO), would it be better to pass UnsignedCharTy 
rather than BoolTy here?  It seems odd to represent the type as  
“bools”.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86101

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


[PATCH] D84932: [builtins] Add more test cases for __div[sdt]f3 LibCalls

2020-08-19 Thread Anatoly Trosinenko via Phabricator via cfe-commits
atrosinenko updated this revision to Diff 286523.
atrosinenko added a comment.

Fix the misleading comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84932

Files:
  compiler-rt/test/builtins/Unit/divdf3_test.c
  compiler-rt/test/builtins/Unit/divsf3_test.c
  compiler-rt/test/builtins/Unit/divtf3_test.c
  compiler-rt/test/builtins/Unit/fp_test.h

Index: compiler-rt/test/builtins/Unit/fp_test.h
===
--- compiler-rt/test/builtins/Unit/fp_test.h
+++ compiler-rt/test/builtins/Unit/fp_test.h
@@ -253,14 +253,29 @@
 return fromRep32(0x7f80U);
 }
 
+static inline float makeNegativeInf32(void)
+{
+return fromRep32(0xff80U);
+}
+
 static inline double makeInf64(void)
 {
 return fromRep64(0x7ff0UL);
 }
 
+static inline double makeNegativeInf64(void)
+{
+return fromRep64(0xfff0UL);
+}
+
 #if __LDBL_MANT_DIG__ == 113
 static inline long double makeInf128(void)
 {
 return fromRep128(0x7fffUL, 0x0UL);
 }
+
+static inline long double makeNegativeInf128(void)
+{
+return fromRep128(0xUL, 0x0UL);
+}
 #endif
Index: compiler-rt/test/builtins/Unit/divtf3_test.c
===
--- compiler-rt/test/builtins/Unit/divtf3_test.c
+++ compiler-rt/test/builtins/Unit/divtf3_test.c
@@ -32,6 +32,8 @@
 int main()
 {
 #if __LDBL_MANT_DIG__ == 113
+// Returned NaNs are assumed to be qNaN by default
+
 // qNaN / any = qNaN
 if (test__divtf3(makeQNaN128(),
  0x1.23456789abcdefp+5L,
@@ -39,17 +41,111 @@
  UINT64_C(0x0)))
 return 1;
 // NaN / any = NaN
-if (test__divtf3(makeNaN128(UINT64_C(0x80003000)),
+if (test__divtf3(makeNaN128(UINT64_C(0x3000)),
  0x1.23456789abcdefp+5L,
  UINT64_C(0x7fff8000),
  UINT64_C(0x0)))
 return 1;
-// inf / any = inf
-if (test__divtf3(makeInf128(),
- 0x1.23456789abcdefp+5L,
+// any / qNaN = qNaN
+if (test__divtf3(0x1.23456789abcdefp+5L,
+ makeQNaN128(),
+ UINT64_C(0x7fff8000),
+ UINT64_C(0x0)))
+return 1;
+// any / NaN = NaN
+if (test__divtf3(0x1.23456789abcdefp+5L,
+ makeNaN128(UINT64_C(0x3000)),
+ UINT64_C(0x7fff8000),
+ UINT64_C(0x0)))
+return 1;
+
+// +Inf / positive = +Inf
+if (test__divtf3(makeInf128(), 3.L,
  UINT64_C(0x7fff),
  UINT64_C(0x0)))
 return 1;
+// +Inf / negative = -Inf
+if (test__divtf3(makeInf128(), -3.L,
+ UINT64_C(0x),
+ UINT64_C(0x0)))
+return 1;
+// -Inf / positive = -Inf
+if (test__divtf3(makeNegativeInf128(), 3.L,
+ UINT64_C(0x),
+ UINT64_C(0x0)))
+return 1;
+// -Inf / negative = +Inf
+if (test__divtf3(makeNegativeInf128(), -3.L,
+ UINT64_C(0x7fff),
+ UINT64_C(0x0)))
+return 1;
+
+// Inf / Inf = NaN
+if (test__divtf3(makeInf128(), makeInf128(),
+ UINT64_C(0x7fff8000),
+ UINT64_C(0x0)))
+return 1;
+// 0.0 / 0.0 = NaN
+if (test__divtf3(+0x0.0p+0L, +0x0.0p+0L,
+ UINT64_C(0x7fff8000),
+ UINT64_C(0x0)))
+return 1;
+// +0.0 / +Inf = +0.0
+if (test__divtf3(+0x0.0p+0L, makeInf128(),
+ UINT64_C(0x0),
+ UINT64_C(0x0)))
+return 1;
+// +Inf / +0.0 = +Inf
+if (test__divtf3(makeInf128(), +0x0.0p+0L,
+ UINT64_C(0x7fff8000),
+ UINT64_C(0x0)))
+return 1;
+
+// positive / +0.0 = +Inf
+if (test__divtf3(+1.0L, +0x0.0p+0L,
+ UINT64_C(0x7fff),
+ UINT64_C(0x0)))
+return 1;
+// positive / -0.0 = -Inf
+if (test__divtf3(+1.0L, -0x0.0p+0L,
+ UINT64_C(0x),
+ UINT64_C(0x0)))
+return 1;
+// negative / +0.0 = -Inf
+if (test__divtf3(-1.0L, +0x0.0p+0L,
+ UINT64_C(0x),
+ UINT64_C(0x0)))
+return 1;
+// negative / -0.0 = +Inf
+if (test__divtf3(-1.0L, -0x0.0p+0L,
+ UINT64_C(0x7fff),
+ UINT64_C(0x0)))
+return 1;
+
+// 1/3
+if (test__divtf3(1.L, 3.L,
+ UINT64_C(0x3ffd),
+ UINT64_C(0x)))
+return 1;
+// smallest 

[PATCH] D84932: [builtins] Add more test cases for __div[sdt]f3 LibCalls

2020-08-19 Thread Anatoly Trosinenko via Phabricator via cfe-commits
atrosinenko added inline comments.



Comment at: compiler-rt/test/builtins/Unit/divdf3_test.c:80
+// divisor is 1.0 as UQ1.31
+if (test__divdf3(0x1.0p+0, 0x1.0001p+0, UINT64_C(0x3fefffe0)))
   return 1;

sepavloff wrote:
> atrosinenko wrote:
> > sepavloff wrote:
> > > Is 0x1.0001p+0 equal to 1.0 in UQ1.31?
> > Divisor is `1.(31 zeroes)1` after restoring the implicit bit, so it is 
> > **truncated** to 1.0 as UQ1.31. Instead of counting bits carefully, it 
> > would probably be better to add several tests with the `1` bit shifted 1-2 
> > places left/right as well as if the divisor is round up instead of 
> > truncating - //just in case//. :) So, with table-driven test it would 
> > probably be simpler to not make extra assumptions on the implementation.
> > Divisor is 1.(31 zeroes)1
> 
> So it is **not** `1.0` and the comment is misleading. Try rewording the 
> comment to avoid confusion. Maybe `divisor is truncated to 1.0 in UQ1.31` or 
> something like that. 
Now got it, thank you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84932

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


<    1   2