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

2020-08-25 Thread Anatoly Trosinenko via Phabricator via cfe-commits
atrosinenko added a comment.

Uploaded, 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


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

2020-08-25 Thread Anatoly Trosinenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb9f49d13fd44: [compiler-rt][builtins] Add more test cases 
for __div[sdt]f3 LibCalls (authored by atrosinenko).

Changed prior to commit:
  https://reviews.llvm.org/D84932?vs=286523=287650#toc

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(0x7fff),
+ 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;
+
+// 

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

2020-08-25 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff accepted this revision.
sepavloff 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/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


[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


[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 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] D84932: [builtins] Add more test cases for __div[sdt]f3 LibCalls

2020-08-18 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff added a comment.

In D84932#2223559 , @atrosinenko wrote:

> @sepavloff
>
> Thank you for the test cases. Looks like it is worth completely rewriting the 
> three tests as table-driven tests

Tests are not required to be compact. It is more important to have clear 
checks, which can be easily extracted. Table-driven tests are suitable if 
number of test cases is large, I think this is not the case.




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;

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. 


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


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

2020-08-18 Thread Anatoly Trosinenko via Phabricator via cfe-commits
atrosinenko added a comment.

@sepavloff

Thank you for the test cases. Looks like it is worth completely rewriting the 
three tests as table-driven tests, so for example adding four cases for 
`[+-]Inf / [+-]0.0` would be almost as easy as testing only one of them 
(something similar is already implemented for `udivmod?i4_test.c`). The 
differences between adjacent test cases would be more visually obvious, as well.




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


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


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

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

Address the review comments.


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-18 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff added inline comments.



Comment at: compiler-rt/test/builtins/Unit/divdf3_test.c:29-34
+// qNaN / any = qNaN
+if (test__divdf3(makeQNaN64(), 3., UINT64_C(0x7ff8)))
+  return 1;
+// NaN / any = NaN
+if (test__divdf3(makeNaN64(UINT64_C(0x123)), 3., 
UINT64_C(0x7ff8)))
+  return 1;

Expressions `any/nan' also could be checked.



Comment at: compiler-rt/test/builtins/Unit/divdf3_test.c:49-54
+// Inf / Inf = NaN
+if (test__divdf3(makeInf64(), makeInf64(), UINT64_C(0x7ff8)))
+  return 1;
+// 0.0 / 0.0 = NaN
+if (test__divdf3(+0x0.0p+0, +0x0.0p+0, UINT64_C(0x7ff8)))
+  return 1;

Expression `Inf/0' also could be checked.



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;

Is 0x1.0001p+0 equal to 1.0 in UQ1.31?



Comment at: compiler-rt/test/builtins/Unit/divsf3_test.c:27
 {
+// Returned NaNs are assumed to be qNaN by default
+

Similar notes as for double precision checks.



Comment at: compiler-rt/test/builtins/Unit/divtf3_test.c:34
 {
 #if __LDBL_MANT_DIG__ == 113
+// Returned NaNs are assumed to be qNaN by default

Similar notes as double precision checks.


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


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

2020-08-12 Thread Anatoly Trosinenko via Phabricator via cfe-commits
atrosinenko added a comment.

Ping


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


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

2020-08-06 Thread Anatoly Trosinenko via Phabricator via cfe-commits
atrosinenko added a comment.

Ping.


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


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

2020-07-30 Thread Anatoly Trosinenko via Phabricator via cfe-commits
atrosinenko created this revision.
atrosinenko added reviewers: koviankevin, joerg, efriedma, compnerd, scanon.
Herald added a project: Sanitizers.
Herald added a subscriber: Sanitizers.
atrosinenko requested review of this revision.

This patch

- makes the three tests look more uniformly
- adds more test cases (basically, everything that was in some of test files is 
put everythere)
- specifies types of integer and fp literals more stricter
- makes NaN in the second test case of `divtf3` to be `sNaN` instead of testing 
for `qNaN` again

This patch is sent in preparation for unifying the division implementations and 
implementing subnormal result handling.


Repository:
  rG LLVM Github Monorepo

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,89 @@
  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,
+
+// +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;
+
+// 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 normal result
+if (test__divtf3(0x1.0p-16381L, 2.L,
+ UINT64_C(0x0001),
+ UINT64_C(0x0)))
+return 1;
+
+// divisor is exactly 1.0
+if (test__divtf3(0x1.0p+0L,
+ 0x1.0p+0L,
+ UINT64_C(0x3fff),