[Bug middle-end/96625] Unnecessarily large assembly generated when a bit-offsetted higher-end end of a uint64_t-backed bitfield is shifted toward the high end (left) by its bit-offset

crazylht at gmail dot com gcc-bugzilla@gcc.gnu.org
Mon Aug 17 07:19:42 GMT 2020


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96625

--- Comment #1 from Hongtao.liu <crazylht at gmail dot com> ---
movabs rax,0x1ffffffffffffff8 --- it also clear high 3 bits.
and    rax,rdi

differs from 

and    rax,0xfffffffffffffff8

using g++ -O2 test.c -S got
---
        movq    %rdi, %rax
        andq    $-8, %rax
        ret
---

but gcc -O2 test.c -S got
---
        movabsq $2305843009213693944, %rax  ---- (1FFFFFFFFFFFFFF8₁₆)
        andq    %rdi, %rax
        ret
---

Is this related to language standard?


More information about the Gcc-bugs mailing list