mesa/src
Ian Romanick 6ed53c27ef i965: Micro-optimize brw_get_index_type
With the switch-statement, GCC 4.8.3 produces a small pile of code with
a branch.

00000000 <brw_get_index_type>:
  000000:       8b 54 24 04             mov    0x4(%esp),%edx
  000004:       b8 01 00 00 00          mov    $0x1,%eax
  000009:       81 fa 03 14 00 00       cmp    $0x1403,%edx
  00000f:       74 0d                   je     00001e <brw_get_index_type+0x1e>
  000011:       31 c0                   xor    %eax,%eax
  000013:       81 fa 05 14 00 00       cmp    $0x1405,%edx
  000019:       0f 94 c0                sete   %al
  00001c:       01 c0                   add    %eax,%eax
  00001e:       c3                      ret

However, this could be two instructions.

00000000 <brw_get_index_type>:
  000000:       2d 01 14 00 00          sub    $0x1401,%eax
  000005:       d1 e8                   shr    %eax
  000007:       90                      nop
  000008:       90                      nop
  000009:       90                      nop
  00000a:       90                      nop
  00000b:       c3                      ret

The function was also moved to the header so that it could be inlined at
the two call sites.  Without this, 32-bit also needs to pull the
parameter from the stack.  This means there is a push, a call, a move,
and a ret added to a two instruction function.  The above code shows the
function with __attribute__((regparm=1)), but even this adds several
extra instructions.  There is also an extra instruction on 64-bit to
move the parameter to %eax for the subtract.

On Bay Trail-D using Fedora 20 compile flags (-m64 -O2 -mtune=generic
for 64-bit and -m32 -march=i686 -mtune=atom for 32-bit), affects
Gl32Batch7:

32-bit: Difference at 95.0% confidence 0.818589% +/- 0.234661% (n=40)
64-bit: Difference at 95.0% confidence 0.54554% +/- 0.354092% (n=40)

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Matt Turner <mattst88@gmail.com>
2015-01-14 16:56:47 -08:00
..
egl egl/wayland: Fix unused variable warnings 2015-01-13 11:33:23 -08:00
gallium freedreno/ir3: handle "holes" in inputs 2015-01-13 08:17:18 -05:00
gbm gbm: remove support for GCC older than 4.1.0 2014-12-17 08:37:29 +11:00
getopt
glsl mesa/glsl/glapi: enable GL_EXT_draw_buffers extension 2015-01-14 07:48:51 +02:00
glx mesa: remove support for GCC older than 3.3.0 2014-12-17 08:37:05 +11:00
gtest gtest: Add headers to distribution. 2014-12-12 12:11:46 -08:00
hgl hgl: traverse add-on entries 2014-12-10 14:01:01 +00:00
loader mesa: Add scons files to distribution. 2014-12-12 12:11:50 -08:00
mapi mesa/glsl/glapi: enable GL_EXT_draw_buffers extension 2015-01-14 07:48:51 +02:00
mesa i965: Micro-optimize brw_get_index_type 2015-01-14 16:56:47 -08:00
util util: Silence signed-unsigned comparison warnings 2014-12-17 17:15:36 +00:00
Makefile.am mesa: Add scons files to distribution. 2014-12-12 12:11:50 -08:00
SConscript egl: Fix non-dri SCons builds re #87657 2014-12-25 10:34:49 -05:00