Skip to content

Commit

Permalink
Coerce to double in case fun is e.g. a compiler builtin. Remove unused
Browse files Browse the repository at this point in the history
R_sqrt work-around. With Luke Tierney.


git-svn-id: https://svn.r-project.org/R/trunk@84682 00db46b3-68df-0310-9c12-caf00c1e9a41
  • Loading branch information
kalibera committed Jul 12, 2023
1 parent 42731d0 commit 6373cb9
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions src/main/eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -4808,7 +4808,7 @@ static SEXP cmp_arith2(SEXP call, int opval, SEXP opsym, SEXP x, SEXP y,
} \
else if (vx->tag == INTSXP && vx->u.ival != NA_INTEGER) { \
SKIP_OP(); \
SETSTACK_REAL(-1, fun(vx->u.ival)); \
SETSTACK_REAL(-1, fun((double) vx->u.ival)); \
R_Visible = TRUE; \
NEXT(); \
} \
Expand Down Expand Up @@ -4890,18 +4890,6 @@ static SEXP cmp_arith2(SEXP call, int opval, SEXP opsym, SEXP x, SEXP y,

#include "arithmetic.h"

/* The current (as of r67808) Windows toolchain compiles explicit sqrt
calls in a way that returns a different NaN than NA_real_ when
called with NA_real_. Not sure this is a bug in the Windows
toolchain or in our expectations, but these defines attempt to work
around this. */
#if (defined(_WIN32) || defined(_WIN64)) && defined(__GNUC__) && \
__GNUC__ <= 4 && !defined(__clang__)
# define R_sqrt(x) (ISNAN(x) ? x : sqrt(x))
#else
# define R_sqrt sqrt
#endif

#define DO_LOG() do { \
R_bcstack_t vvx; \
R_bcstack_t *vx = bcStackScalarReal(R_BCNodeStackTop - 1, &vvx); \
Expand Down Expand Up @@ -7500,7 +7488,7 @@ static SEXP bcEval(SEXP body, SEXP rho, Rboolean useCache)
OP(MUL, 1): FastBinary(R_MUL, TIMESOP, R_MulSym);
OP(DIV, 1): FastBinary(R_DIV, DIVOP, R_DivSym);
OP(EXPT, 1): FastBinary(R_POW, POWOP, R_ExptSym);
OP(SQRT, 1): FastMath1(R_sqrt, R_SqrtSym);
OP(SQRT, 1): FastMath1(sqrt, R_SqrtSym);
OP(EXP, 1): FastMath1(exp, R_ExpSym);
OP(EQ, 1): FastRelop2(==, EQOP, R_EqSym);
OP(NE, 1): FastRelop2(!=, NEOP, R_NeSym);
Expand Down

0 comments on commit 6373cb9

Please sign in to comment.