https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63302
Bug ID: 63302 Summary: [4.9,5.0 Regression] Code with 64-bit long long constants is miscompiled on 32-bit host Product: gcc Version: 4.9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: danglin at gcc dot gnu.org Host: hppa-unknown-linux-gnu Target: hppa-unknown-linux-gnu Build: hppa-unknown-linux-gnu The following function from pa.c is miscompiled when generating a hppa64 cross compiler: dave@mx3210:~/hardware/ldil$ cat ldil.c #define HOST_WIDE_INT long long int pa_ldil_cint_p (HOST_WIDE_INT ival) { HOST_WIDE_INT x = ival & (((HOST_WIDE_INT) -1 << 31) | 0x7ff); return x == 0 || x == ((HOST_WIDE_INT) -1 << 31); } gcc-4.9 -S -O1 ldil.c: dave@mx3210:~/hardware/ldil$ cat ldil.s .LEVEL 1.1 .text .align 4 .globl pa_ldil_cint_p .type pa_ldil_cint_p, @function pa_ldil_cint_p: .PROC .CALLINFO FRAME=0,NO_CALLS .ENTRY extru %r26,31,11,%r28 comiclr,<> 0,%r28,%r28 ldi 1,%r28 bv,n %r0(%r2) .EXIT .PROCEND .size pa_ldil_cint_p, .-pa_ldil_cint_p .ident "GCC: (Debian 4.9.1-14) 4.9.1" The high order bits are not checked in the assembly code. We have the following in ldil.c.170r.expand: pa_ldil_cint_p (long long int ival) { int _6; long long int _8; _Bool _9; ;; basic block 2, loop depth 0 ;; pred: ENTRY _8 = ival_1(D) & 2047; _9 = _8 == 0; _6 = (int) _9; return _6; ;; succ: EXIT } This breaks 64-bit kernel build. 4.8 branch is ok.