aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2018-12-11 19:29:35 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2018-12-11 19:33:09 +0100
commit09d8df84ee908b940a31822c3480f36f817e4f09 (patch)
tree0d0f74ee0ad31cea2f31090161ac22b457650f00
parent7f4daa4f5842b26c5f3e233819e583573eeebaf6 (diff)
downloadbusybox-w32-09d8df84ee908b940a31822c3480f36f817e4f09.tar.gz
busybox-w32-09d8df84ee908b940a31822c3480f36f817e4f09.tar.bz2
busybox-w32-09d8df84ee908b940a31822c3480f36f817e4f09.zip
bc: do not use "(cond ? f1 : f2)(params)" idiom, it messes up static function optimizations
With direct calls, GCC no longer thinks that we take addresses of the functions, and can use "more optimal" internal ABI for _all_ calls to these functions, not only at this callsite. On i486, regparm is used, and: function old new delta zbc_num_inv 56 57 +1 zbc_num_k 852 851 -1 zbc_program_modexp 558 556 -2 zbc_num_d 541 539 -2 bc_num_ulong2num 59 57 -2 zbc_program_num 840 836 -4 bc_num_zero 11 7 -4 bc_num_one 28 24 -4 bc_program_exec 3928 3918 -10 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/8 up/down: 1/-29) Total: -28 bytes text data bss dec hex filename 982237 485 7296 990018 f1b42 busybox_old 982209 485 7296 989990 f1b26 busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--miscutils/bc.c60
1 files changed, 21 insertions, 39 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c
index 5ede8598d..e7f48fcea 100644
--- a/miscutils/bc.c
+++ b/miscutils/bc.c
@@ -5943,6 +5943,7 @@ static BcStatus bc_program_logical(char inst)
5943 5943
5944 s = zbc_program_binOpPrep(&opd1, &n1, &opd2, &n2, false); 5944 s = zbc_program_binOpPrep(&opd1, &n1, &opd2, &n2, false);
5945 if (s) return s; 5945 if (s) return s;
5946
5946 bc_num_init_DEF_SIZE(&res.d.n); 5947 bc_num_init_DEF_SIZE(&res.d.n);
5947 5948
5948 if (inst == BC_INST_BOOL_AND) 5949 if (inst == BC_INST_BOOL_AND)
@@ -5950,50 +5951,31 @@ static BcStatus bc_program_logical(char inst)
5950 else if (inst == BC_INST_BOOL_OR) 5951 else if (inst == BC_INST_BOOL_OR)
5951 cond = bc_num_cmp(n1, &G.prog.zero) || bc_num_cmp(n2, &G.prog.zero); 5952 cond = bc_num_cmp(n1, &G.prog.zero) || bc_num_cmp(n2, &G.prog.zero);
5952 else { 5953 else {
5953
5954 cmp = bc_num_cmp(n1, n2); 5954 cmp = bc_num_cmp(n1, n2);
5955
5956 switch (inst) { 5955 switch (inst) {
5957 5956 case BC_INST_REL_EQ:
5958 case BC_INST_REL_EQ: 5957 cond = cmp == 0;
5959 { 5958 break;
5960 cond = cmp == 0; 5959 case BC_INST_REL_LE:
5961 break; 5960 cond = cmp <= 0;
5962 } 5961 break;
5963 5962 case BC_INST_REL_GE:
5964 case BC_INST_REL_LE: 5963 cond = cmp >= 0;
5965 { 5964 break;
5966 cond = cmp <= 0; 5965 case BC_INST_REL_NE:
5967 break; 5966 cond = cmp != 0;
5968 } 5967 break;
5969 5968 case BC_INST_REL_LT:
5970 case BC_INST_REL_GE: 5969 cond = cmp < 0;
5971 { 5970 break;
5972 cond = cmp >= 0; 5971 case BC_INST_REL_GT:
5973 break; 5972 cond = cmp > 0;
5974 } 5973 break;
5975
5976 case BC_INST_REL_NE:
5977 {
5978 cond = cmp != 0;
5979 break;
5980 }
5981
5982 case BC_INST_REL_LT:
5983 {
5984 cond = cmp < 0;
5985 break;
5986 }
5987
5988 case BC_INST_REL_GT:
5989 {
5990 cond = cmp > 0;
5991 break;
5992 }
5993 } 5974 }
5994 } 5975 }
5995 5976
5996 (cond ? bc_num_one : bc_num_zero)(&res.d.n); 5977 if (cond) bc_num_one(&res.d.n);
5978 //else bc_num_zero(&res.d.n); - already is
5997 5979
5998 bc_program_binOpRetire(&res); 5980 bc_program_binOpRetire(&res);
5999 5981