aboutsummaryrefslogtreecommitdiff
path: root/gcc/config
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@gcc.gnu.org>2017-12-08 00:56:34 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2017-12-08 00:56:34 +0100
commit7f5aed1e5d7b8f02ed81178f65d84cbd27ec88cd (patch)
tree19a103430578ba4a53e3f95d98e6a0aa9aa7770d /gcc/config
parent9b6c97373a0ca04b5888a1c4ca6519c94388da50 (diff)
downloadgcc-7f5aed1e5d7b8f02ed81178f65d84cbd27ec88cd.zip
gcc-7f5aed1e5d7b8f02ed81178f65d84cbd27ec88cd.tar.gz
gcc-7f5aed1e5d7b8f02ed81178f65d84cbd27ec88cd.tar.bz2
re PR target/81906 (Calls to rint() wrongly optimized away starting in g++ 6)
PR target/81906 * config/i386/i386.c (ix86_expand_rint): Handle flag_rounding_math. * gcc.target/i386/pr81906.c: New test. From-SVN: r255486
Diffstat (limited to 'gcc/config')
-rw-r--r--gcc/config/i386/i386.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 5d77f28..e323102 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -44255,8 +44255,7 @@ ix86_expand_lfloorceil (rtx op0, rtx op1, bool do_floor)
emit_move_insn (op0, ireg);
}
-/* Expand rint (IEEE round to nearest) rounding OPERAND1 and storing the
- result in OPERAND0. */
+/* Expand rint rounding OPERAND1 and storing the result in OPERAND0. */
void
ix86_expand_rint (rtx operand0, rtx operand1)
{
@@ -44264,11 +44263,17 @@ ix86_expand_rint (rtx operand0, rtx operand1)
xa = fabs (operand1);
if (!isless (xa, 2**52))
return operand1;
- xa = xa + 2**52 - 2**52;
+ two52 = 2**52;
+ if (flag_rounding_math)
+ {
+ two52 = copysign (two52, operand1);
+ xa = operand1;
+ }
+ xa = xa + two52 - two52;
return copysign (xa, operand1);
*/
machine_mode mode = GET_MODE (operand0);
- rtx res, xa, TWO52, mask;
+ rtx res, xa, TWO52, two52, mask;
rtx_code_label *label;
res = gen_reg_rtx (mode);
@@ -44281,8 +44286,16 @@ ix86_expand_rint (rtx operand0, rtx operand1)
TWO52 = ix86_gen_TWO52 (mode);
label = ix86_expand_sse_compare_and_jump (UNLE, TWO52, xa, false);
- xa = expand_simple_binop (mode, PLUS, xa, TWO52, NULL_RTX, 0, OPTAB_DIRECT);
- xa = expand_simple_binop (mode, MINUS, xa, TWO52, xa, 0, OPTAB_DIRECT);
+ two52 = TWO52;
+ if (flag_rounding_math)
+ {
+ two52 = gen_reg_rtx (mode);
+ ix86_sse_copysign_to_positive (two52, TWO52, res, mask);
+ xa = res;
+ }
+
+ xa = expand_simple_binop (mode, PLUS, xa, two52, NULL_RTX, 0, OPTAB_DIRECT);
+ xa = expand_simple_binop (mode, MINUS, xa, two52, xa, 0, OPTAB_DIRECT);
ix86_sse_copysign_to_positive (res, xa, res, mask);