ruby-changes:44433
From: nobu <ko1@a...>
Date: Thu, 27 Oct 2016 23:28:20 +0900 (JST)
Subject: [ruby-changes:44433] nobu:r56506 (trunk): ruby/ruby.h: optimize rb_integer_type_p
nobu 2016-10-27 23:28:14 +0900 (Thu, 27 Oct 2016) New Revision: 56506 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=56506 Log: ruby/ruby.h: optimize rb_integer_type_p * include/ruby/ruby.h (rb_integer_type_p): turn into macro to help clang based on old gcc to eliminate CSE. Modified files: trunk/ChangeLog trunk/include/ruby/ruby.h Index: ChangeLog =================================================================== --- ChangeLog (revision 56505) +++ ChangeLog (revision 56506) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Thu Oct 27 23:28:12 2016 Nobuyoshi Nakada <nobu@r...> + + * include/ruby/ruby.h (rb_integer_type_p): turn into macro to help + clang based on old gcc to eliminate CSE. + Thu Oct 27 16:33:47 2016 NAKAMURA Usaku <usa@r...> * tool/redmine-backporter.rb (rel): check the exception and show right Index: include/ruby/ruby.h =================================================================== --- include/ruby/ruby.h (revision 56505) +++ include/ruby/ruby.h (revision 56506) @@ -1480,6 +1480,17 @@ rb_obj_write(VALUE a, VALUE *slot, VALUE https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L1480 #define RUBY_INTEGER_UNIFICATION 1 #define RB_INTEGER_TYPE_P(obj) rb_integer_type_p(obj) +#if defined __GNUC__ && !GCC_VERSION_SINCE(4, 3, 0) +/* clang 3.x (4.2 compatible) can't eliminate CSE of RB_BUILTIN_TYPE + * in inline function and caller function */ +#define rb_integer_type_p(obj) \ + __extension__ ({ \ + const VALUE integer_type_obj = (obj); \ + (RB_FIXNUM_P(integer_type_obj) || \ + (!RB_SPECIAL_CONST_P(integer_type_obj) && \ + RB_BUILTIN_TYPE(integer_type_obj) == RUBY_T_BIGNUM)); \ + }) +#else static inline int rb_integer_type_p(VALUE obj) { @@ -1487,6 +1498,7 @@ rb_integer_type_p(VALUE obj) https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L1498 (!RB_SPECIAL_CONST_P(obj) && RB_BUILTIN_TYPE(obj) == RUBY_T_BIGNUM)); } +#endif #if SIZEOF_INT < SIZEOF_LONG # define RB_INT2NUM(v) RB_INT2FIX((int)(v)) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/