aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Pall <mike>2011-04-05 16:31:48 +0200
committerMike Pall <mike>2011-04-05 16:31:48 +0200
commit3acd4892e96fb73a751852a079537adc3fd2d560 (patch)
tree4d0c3be6ac80ae32f5d56c16e34103d22b609562 /src
parent48438b9e13e8a9ce19dea37a75d29c015968c619 (diff)
downloadluajit-3acd4892e96fb73a751852a079537adc3fd2d560.tar.gz
luajit-3acd4892e96fb73a751852a079537adc3fd2d560.tar.bz2
luajit-3acd4892e96fb73a751852a079537adc3fd2d560.zip
Add FOLD rule for FLOAT->NUM->FLOAT conversions.
Diffstat (limited to 'src')
-rw-r--r--src/buildvm_fold.c8
-rw-r--r--src/lj_opt_fold.c9
2 files changed, 14 insertions, 3 deletions
diff --git a/src/buildvm_fold.c b/src/buildvm_fold.c
index 33a117d7..b43d2c48 100644
--- a/src/buildvm_fold.c
+++ b/src/buildvm_fold.c
@@ -111,13 +111,15 @@ static uint32_t nexttoken(char **pp, int allowlit, int allowany)
111 if (!strcmp(ircall_names[i], p+7)) 111 if (!strcmp(ircall_names[i], p+7))
112 return i; 112 return i;
113 } else if (allowlit && !strncmp(p, "IRCONV_", 7)) { 113 } else if (allowlit && !strncmp(p, "IRCONV_", 7)) {
114 for (i = 0; irt_names[i]; i++) 114 for (i = 0; irt_names[i]; i++) {
115 if (!strncmp(irt_names[i], p+7, 3) && p[10] == '_') { 115 const char *r = strchr(p+7, '_');
116 if (r && !strncmp(irt_names[i], p+7, r-(p+7))) {
116 uint32_t j; 117 uint32_t j;
117 for (j = 0; irt_names[j]; j++) 118 for (j = 0; irt_names[j]; j++)
118 if (!strncmp(irt_names[j], p+11, 3)) 119 if (!strcmp(irt_names[j], r+1))
119 return (i << 5) + j; 120 return (i << 5) + j;
120 } 121 }
122 }
121 } else if (allowlit && *p >= '0' && *p <= '9') { 123 } else if (allowlit && *p >= '0' && *p <= '9') {
122 for (i = 0; *p >= '0' && *p <= '9'; p++) 124 for (i = 0; *p >= '0' && *p <= '9'; p++)
123 i = i*10 + (*p - '0'); 125 i = i*10 + (*p - '0');
diff --git a/src/lj_opt_fold.c b/src/lj_opt_fold.c
index edd376c9..44a55709 100644
--- a/src/lj_opt_fold.c
+++ b/src/lj_opt_fold.c
@@ -914,6 +914,15 @@ LJFOLDF(simplify_conv_int_i64)
914 return NEXTFOLD; 914 return NEXTFOLD;
915} 915}
916 916
917LJFOLD(CONV CONV IRCONV_NUM_FLOAT) /* _NUM */
918LJFOLDF(simplify_conv_flt_num)
919{
920 PHIBARRIER(fleft);
921 if ((fleft->op2 & IRCONV_SRCMASK) == IRT_NUM)
922 return fleft->op1;
923 return NEXTFOLD;
924}
925
917/* Shortcut TOBIT + IRT_NUM <- IRT_INT/IRT_U32 conversion. */ 926/* Shortcut TOBIT + IRT_NUM <- IRT_INT/IRT_U32 conversion. */
918LJFOLD(TOBIT CONV KNUM) 927LJFOLD(TOBIT CONV KNUM)
919LJFOLDF(simplify_tobit_conv) 928LJFOLDF(simplify_tobit_conv)