]> git.baikalelectronics.ru Git - kernel.git/commit
lib/kstrtox.c: use "unsigned int" more
authorAlexey Dobriyan <adobriyan@gmail.com>
Mon, 10 Jul 2017 22:51:41 +0000 (15:51 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Mon, 10 Jul 2017 23:32:34 +0000 (16:32 -0700)
commit2223fc3cedc9f93158f92ac02d411fa899ffe920
tree1db36ebd3507d7e5f294546c9f94db18af140db5
parent6de841c40842eb9eb31f91784ec43d6cef29dbef
lib/kstrtox.c: use "unsigned int" more

gcc does generates stupid code sign extending data back and forth.  Help
by using "unsigned int".

add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-61 (-61)
function                                     old     new   delta
_parse_integer                               128     123      -5

It _still_ does generate useless MOVSX but I don't know how to delete it:

0000000000000070 <_parse_integer>:
...
  a0:   89 c2                   mov    edx,eax
  a2:   83 e8 30                sub    eax,0x30
  a5:   83 f8 09                cmp    eax,0x9
  a8:   76 11                   jbe    bb <_parse_integer+0x4b>
  aa:   83 ca 20                or     edx,0x20
  ad:   0f be c2      ===>      movsx  eax,dl         <===
useless
  b0:   8d 50 9f                lea    edx,[rax-0x61]
  b3:   83 fa 05                cmp    edx,0x5

Patch also helps on embedded archs which generally only like "int".  On
arm "and 0xff" is generated which is waste because all values used in
comparisons are positive.

Link: http://lkml.kernel.org/r/20170514194720.GB32563@avx2
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
lib/kstrtox.c