Changeset: e8d3e508fc4d for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e8d3e508fc4d
Modified Files:
geom/monetdb5/geom.c
monetdb5/modules/kernel/batmmath.c
monetdb5/modules/kernel/mmath.c
sql/backends/monet5/sql.h
Branch: Jun2020
Log Message:
Isolate number constants from the input, so compilers can optimize trival math
expressions
diffs (91 lines):
diff --git a/geom/monetdb5/geom.c b/geom/monetdb5/geom.c
--- a/geom/monetdb5/geom.c
+++ b/geom/monetdb5/geom.c
@@ -48,18 +48,20 @@ wkbNULLcopy(void)
static inline void
degrees2radians(double *x, double *y, double *z)
{
- *x *= M_PI / 180.0;
- *y *= M_PI / 180.0;
- *z *= M_PI / 180.0;
+ double val = M_PI / 180.0;
+ *x *= val;
+ *y *= val;
+ *z *= val;
}
/** convert radians to degrees */
static inline void
radians2degrees(double *x, double *y, double *z)
{
- *x *= 180.0 / M_PI;
- *y *= 180.0 / M_PI;
- *z *= 180.0 / M_PI;
+ double val = 180.0 / M_PI;
+ *x *= val;
+ *y *= val;
+ *z *= val;
}
static str
diff --git a/monetdb5/modules/kernel/batmmath.c
b/monetdb5/modules/kernel/batmmath.c
--- a/monetdb5/modules/kernel/batmmath.c
+++ b/monetdb5/modules/kernel/batmmath.c
@@ -450,25 +450,25 @@ CMDscience_bat_##FUNC(Client cntxt, MalB
static double
radians(double x)
{
- return x * 3.14159265358979323846 / 180.0;
+ return x * (3.14159265358979323846 / 180.0);
}
static float
radiansf(float x)
{
- return (float) (x * 3.14159265358979323846 / 180.0);
+ return (float) (x * (3.14159265358979323846 / 180.0));
}
static double
degrees(double x)
{
- return x * 180.0 / 3.14159265358979323846;
+ return x * (180.0 / 3.14159265358979323846);
}
static float
degreesf(float x)
{
- return (float) (x * 180.0 / 3.14159265358979323846);
+ return (float) (x * (180.0 / 3.14159265358979323846));
}
mal_export str CMDscience_bat_asin(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr pci);
diff --git a/monetdb5/modules/kernel/mmath.c b/monetdb5/modules/kernel/mmath.c
--- a/monetdb5/modules/kernel/mmath.c
+++ b/monetdb5/modules/kernel/mmath.c
@@ -32,8 +32,8 @@
#endif
#define cot(x) (1 / tan(x))
-#define radians(x) ((x) * 3.14159265358979323846 / 180.0)
-#define degrees(x) ((x) * 180.0 / 3.14159265358979323846)
+#define radians(x) ((x) * (3.14159265358979323846 / 180.0))
+#define degrees(x) ((x) * (180.0 / 3.14159265358979323846))
double
logbs(double x, double base)
diff --git a/sql/backends/monet5/sql.h b/sql/backends/monet5/sql.h
--- a/sql/backends/monet5/sql.h
+++ b/sql/backends/monet5/sql.h
@@ -270,8 +270,8 @@ sql5_export str dbl_round_wrap(dbl *res,
sql5_export str dbl_bat_round_wrap(bat *res, const bat *v, const bte *r);
sql5_export str dbl_trunc_wrap(dbl *res, const dbl *v, const int *r);
-#define radians(x) ((x) * 3.14159265358979323846 /180.0 )
-#define degrees(x) ((x) * 180.0/3.14159265358979323846 )
+#define radians(x) ((x) * (3.14159265358979323846 / 180.0))
+#define degrees(x) ((x) * (180.0 / 3.14159265358979323846))
sql5_export str SQLcst_alpha_cst(dbl *res, const dbl *decl, const dbl *theta);
sql5_export str SQLbat_alpha_cst(bat *res, const bat *decl, const dbl *theta);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list