aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2019-03-19 08:25:59 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2019-03-19 08:25:59 +0100
commitce2c025c2480b6d36eb25b3aae877141ab4c3a5d (patch)
tree69f03b83883ad63d4bb303e381209b838c4642bb /gcc
parent855cd9b166c70a6e5a90e342314e71203f15b8f4 (diff)
downloadgcc-ce2c025c2480b6d36eb25b3aae877141ab4c3a5d.zip
gcc-ce2c025c2480b6d36eb25b3aae877141ab4c3a5d.tar.gz
gcc-ce2c025c2480b6d36eb25b3aae877141ab4c3a5d.tar.bz2
re PR target/89726 (Incorrect inlined version of 'ceil' for 32bit)
PR target/89726 * config/i386/i386.c (ix86_expand_floorceildf_32): In ceil compensation use x2 += 1 instead of x2 -= -1 and when honoring signed zeros, do another copysign after the compensation. * gcc.target/i386/fpprec-1.c (x): Add 6 new constants. (expect_round, expect_rint, expect_floor, expect_ceil, expect_trunc): Add expected results for them. From-SVN: r269790
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/config/i386/i386.c17
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.target/i386/fpprec-1.c8
4 files changed, 29 insertions, 8 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index e0df9e0..5684358 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2019-03-19 Jakub Jelinek <jakub@redhat.com>
+
+ PR target/89726
+ * config/i386/i386.c (ix86_expand_floorceildf_32): In ceil
+ compensation use x2 += 1 instead of x2 -= -1 and when honoring
+ signed zeros, do another copysign after the compensation.
+
2019-03-18 Martin Sebor <msebor@redhat.com>
PR tree-optimization/89720
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 560170f..184c5c1 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -45563,8 +45563,10 @@ ix86_expand_floorceildf_32 (rtx operand0, rtx operand1, bool do_floor)
x2 -= 1;
Compensate. Ceil:
if (x2 < x)
- x2 -= -1;
- return x2;
+ x2 += 1;
+ if (HONOR_SIGNED_ZEROS (mode))
+ x2 = copysign (x2, x);
+ return x2;
*/
machine_mode mode = GET_MODE (operand0);
rtx xa, TWO52, tmp, one, res, mask;
@@ -45590,17 +45592,16 @@ ix86_expand_floorceildf_32 (rtx operand0, rtx operand1, bool do_floor)
/* xa = copysign (xa, operand1) */
ix86_sse_copysign_to_positive (xa, xa, res, mask);
- /* generate 1.0 or -1.0 */
- one = force_reg (mode,
- const_double_from_real_value (do_floor
- ? dconst1 : dconstm1, mode));
+ /* generate 1.0 */
+ one = force_reg (mode, const_double_from_real_value (dconst1, mode));
/* Compensate: xa = xa - (xa > operand1 ? 1 : 0) */
tmp = ix86_expand_sse_compare_mask (UNGT, xa, res, !do_floor);
emit_insn (gen_rtx_SET (tmp, gen_rtx_AND (mode, one, tmp)));
- /* We always need to subtract here to preserve signed zero. */
- tmp = expand_simple_binop (mode, MINUS,
+ tmp = expand_simple_binop (mode, do_floor ? MINUS : PLUS,
xa, tmp, NULL_RTX, 0, OPTAB_DIRECT);
+ if (!do_floor && HONOR_SIGNED_ZEROS (mode))
+ ix86_sse_copysign_to_positive (tmp, tmp, res, mask);
emit_move_insn (res, tmp);
emit_label (label);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 308753e..ae077a1 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,10 @@
2019-03-19 Jakub Jelinek <jakub@redhat.com>
+ PR target/89726
+ * gcc.target/i386/fpprec-1.c (x): Add 6 new constants.
+ (expect_round, expect_rint, expect_floor, expect_ceil, expect_trunc):
+ Add expected results for them.
+
PR c/89734
* gcc.dg/pr89734.c: New test.
diff --git a/gcc/testsuite/gcc.target/i386/fpprec-1.c b/gcc/testsuite/gcc.target/i386/fpprec-1.c
index 1c17c1d..4e55a22 100644
--- a/gcc/testsuite/gcc.target/i386/fpprec-1.c
+++ b/gcc/testsuite/gcc.target/i386/fpprec-1.c
@@ -11,6 +11,9 @@ double x[] = { __builtin_nan(""), __builtin_inf(), -__builtin_inf(),
0x1.0000000000001p-1, 0x1.fffffffffffffp-2,
0x1.0000000000001p+0, 0x1.fffffffffffffp-1,
0x1.8000000000001p+0, 0x1.7ffffffffffffp+0,
+ -0x1.0000000000001p-1, -0x1.fffffffffffffp-2,
+ -0x1.0000000000001p+0, -0x1.fffffffffffffp-1,
+ -0x1.8000000000001p+0, -0x1.7ffffffffffffp+0,
-0.0, 0.0, -0.5, 0.5, -1.0, 1.0, -1.5, 1.5, -2.0, 2.0,
-2.5, 2.5 };
#define NUM (sizeof(x)/sizeof(double))
@@ -19,6 +22,7 @@ double expect_round[] = { __builtin_nan(""), __builtin_inf(), -__builtin_inf(),
-0x1.fffffffffffffp+1023, 0x1.fffffffffffffp+1023,
-0.0, 0.0,
1.0, 0.0, 1.0, 1.0, 2.0, 1.0,
+ -1.0, -0.0, -1.0, -1.0, -2.0, -1.0,
-0.0, 0.0, -1.0, 1.0, -1.0, 1.0, -2.0, 2.0, -2.0, 2.0,
-3.0, 3.0 };
@@ -26,6 +30,7 @@ double expect_rint[] = { __builtin_nan(""), __builtin_inf(), -__builtin_inf(),
-0x1.fffffffffffffp+1023, 0x1.fffffffffffffp+1023,
-0.0, 0.0,
1.0, 0.0, 1.0, 1.0, 2.0, 1.0,
+ -1.0, -0.0, -1.0, -1.0, -2.0, -1.0,
-0.0, 0.0, -0.0, 0.0, -1.0, 1.0, -2.0, 2.0, -2.0, 2.0,
-2.0, 2.0 };
@@ -33,6 +38,7 @@ double expect_floor[] = { __builtin_nan(""), __builtin_inf(), -__builtin_inf(),
-0x1.fffffffffffffp+1023, 0x1.fffffffffffffp+1023,
-1.0, 0.0,
0.0, 0.0, 1.0, 0.0, 1.0, 1.0,
+ -1.0, -1.0, -2.0, -1.0, -2.0, -2.0,
-0.0, 0.0, -1.0, 0.0, -1.0, 1.0, -2.0, 1.0, -2.0, 2.0,
-3.0, 2.0 };
@@ -40,6 +46,7 @@ double expect_ceil[] = { __builtin_nan(""), __builtin_inf(), -__builtin_inf(),
-0x1.fffffffffffffp+1023, 0x1.fffffffffffffp+1023,
-0.0, 1.0,
1.0, 1.0, 2.0, 1.0, 2.0, 2.0,
+ -0.0, -0.0, -1.0, -0.0, -1.0, -1.0,
-0.0, 0.0, -0.0, 1.0, -1.0, 1.0, -1.0, 2.0, -2.0, 2.0,
-2.0, 3.0 };
@@ -47,6 +54,7 @@ double expect_trunc[] = { __builtin_nan(""), __builtin_inf(), -__builtin_inf(),
-0x1.fffffffffffffp+1023, 0x1.fffffffffffffp+1023,
-0.0, 0.0,
0.0, 0.0, 1.0, 0.0, 1.0, 1.0,
+ -0.0, -0.0, -1.0, -0.0, -1.0, -1.0,
-0.0, 0.0, -0.0, 0.0, -1.0, 1.0, -1.0, 1.0, -2.0, 2.0,
-2.0, 2.0 };