aboutsummaryrefslogtreecommitdiff
path: root/src/lj_opt_fold.c
diff options
context:
space:
mode:
authorMike Pall <mike>2013-02-22 20:39:25 +0100
committerMike Pall <mike>2013-02-23 01:19:00 +0100
commitb359ce804bb52585815fc52d7846202db4341acb (patch)
tree47ce07e6dc9403ce9e6b775c8d2f6d77360c6605 /src/lj_opt_fold.c
parentfdc0ce8debd46bdf35aaec320eef3105055e90b5 (diff)
downloadluajit-b359ce804bb52585815fc52d7846202db4341acb.tar.gz
luajit-b359ce804bb52585815fc52d7846202db4341acb.tar.bz2
luajit-b359ce804bb52585815fc52d7846202db4341acb.zip
Remove obsolete non-truncating number to integer conversions.
Diffstat (limited to 'src/lj_opt_fold.c')
-rw-r--r--src/lj_opt_fold.c27
1 files changed, 10 insertions, 17 deletions
diff --git a/src/lj_opt_fold.c b/src/lj_opt_fold.c
index be50bf97..e67f3ee6 100644
--- a/src/lj_opt_fold.c
+++ b/src/lj_opt_fold.c
@@ -647,27 +647,22 @@ LJFOLD(CONV KNUM IRCONV_INT_NUM)
647LJFOLDF(kfold_conv_knum_int_num) 647LJFOLDF(kfold_conv_knum_int_num)
648{ 648{
649 lua_Number n = knumleft; 649 lua_Number n = knumleft;
650 if (!(fins->op2 & IRCONV_TRUNC)) { 650 int32_t k = lj_num2int(n);
651 int32_t k = lj_num2int(n); 651 if (irt_isguard(fins->t) && n != (lua_Number)k) {
652 if (irt_isguard(fins->t) && n != (lua_Number)k) { 652 /* We're about to create a guard which always fails, like CONV +1.5.
653 /* We're about to create a guard which always fails, like CONV +1.5. 653 ** Some pathological loops cause this during LICM, e.g.:
654 ** Some pathological loops cause this during LICM, e.g.: 654 ** local x,k,t = 0,1.5,{1,[1.5]=2}
655 ** local x,k,t = 0,1.5,{1,[1.5]=2} 655 ** for i=1,200 do x = x+ t[k]; k = k == 1 and 1.5 or 1 end
656 ** for i=1,200 do x = x+ t[k]; k = k == 1 and 1.5 or 1 end 656 ** assert(x == 300)
657 ** assert(x == 300) 657 */
658 */ 658 return FAILFOLD;
659 return FAILFOLD;
660 }
661 return INTFOLD(k);
662 } else {
663 return INTFOLD((int32_t)n);
664 } 659 }
660 return INTFOLD(k);
665} 661}
666 662
667LJFOLD(CONV KNUM IRCONV_U32_NUM) 663LJFOLD(CONV KNUM IRCONV_U32_NUM)
668LJFOLDF(kfold_conv_knum_u32_num) 664LJFOLDF(kfold_conv_knum_u32_num)
669{ 665{
670 lua_assert((fins->op2 & IRCONV_TRUNC));
671#ifdef _MSC_VER 666#ifdef _MSC_VER
672 { /* Workaround for MSVC bug. */ 667 { /* Workaround for MSVC bug. */
673 volatile uint32_t u = (uint32_t)knumleft; 668 volatile uint32_t u = (uint32_t)knumleft;
@@ -681,14 +676,12 @@ LJFOLDF(kfold_conv_knum_u32_num)
681LJFOLD(CONV KNUM IRCONV_I64_NUM) 676LJFOLD(CONV KNUM IRCONV_I64_NUM)
682LJFOLDF(kfold_conv_knum_i64_num) 677LJFOLDF(kfold_conv_knum_i64_num)
683{ 678{
684 lua_assert((fins->op2 & IRCONV_TRUNC));
685 return INT64FOLD((uint64_t)(int64_t)knumleft); 679 return INT64FOLD((uint64_t)(int64_t)knumleft);
686} 680}
687 681
688LJFOLD(CONV KNUM IRCONV_U64_NUM) 682LJFOLD(CONV KNUM IRCONV_U64_NUM)
689LJFOLDF(kfold_conv_knum_u64_num) 683LJFOLDF(kfold_conv_knum_u64_num)
690{ 684{
691 lua_assert((fins->op2 & IRCONV_TRUNC));
692 return INT64FOLD(lj_num2u64(knumleft)); 685 return INT64FOLD(lj_num2u64(knumleft));
693} 686}
694 687