[Bug target/82858] __builtin_add_overflow() generates suboptimal code with unsigned types on x86

2017-11-06 Thread ubizjak at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82858 --- Comment #5 from Uroš Bizjak --- Actually, -m32 -march=i386 -mtune=generic generates expected code: movl8(%esp), %eax addl4(%esp), %eax sbbl%edx, %edx orl %edx, %eax ret -march=i386

[Bug target/82858] __builtin_add_overflow() generates suboptimal code with unsigned types on x86

2017-11-06 Thread glisse at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82858 --- Comment #4 from Marc Glisse --- unsigned c; unsigned d = __builtin_add_overflow(a, b, )?-1:0; return c|d; gives the expected asm. Ideally phiopt would recognize a saturing add pattern, but we have nothing to model it in gimple.

[Bug target/82858] __builtin_add_overflow() generates suboptimal code with unsigned types on x86

2017-11-06 Thread trippels at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82858 --- Comment #3 from Markus Trippelsdorf --- (In reply to Liu Hao from comment #2) > Trunk on produces the following code: > > ``` > saturated_add(unsigned int, unsigned int): > add edi, esi > mov eax, -1 >

[Bug target/82858] __builtin_add_overflow() generates suboptimal code with unsigned types on x86

2017-11-06 Thread lh_mouse at 126 dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82858 --- Comment #2 from Liu Hao --- Trunk on produces the following code: ``` saturated_add(unsigned int, unsigned int): add edi, esi mov eax, -1 cmovnc eax, edi ret ``` Condition moves are however, in my

[Bug target/82858] __builtin_add_overflow() generates suboptimal code with unsigned types on x86

2017-11-06 Thread trippels at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82858 Markus Trippelsdorf changed: What|Removed |Added Keywords||missed-optimization