From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 42870 invoked by alias); 12 Mar 2015 12:25:18 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 42845 invoked by uid 48); 12 Mar 2015 12:25:15 -0000 From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/65401] New: [5 Regression] make_field_assignment broken for big-endian Date: Thu, 12 Mar 2015 12:25:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: rtl-optimization X-Bugzilla-Version: 5.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status keywords bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-03/txt/msg01303.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65401 Bug ID: 65401 Summary: [5 Regression] make_field_assignment broken for big-endian Product: gcc Version: 5.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: rtl-optimization Assignee: unassigned at gcc dot gnu.org Reporter: jakub at gcc dot gnu.org struct S { unsigned short s[64]; }; __attribute__((noinline, noclone)) void foo (struct S *x) { unsigned int i; unsigned char *s; s = (unsigned char *) x->s; for (i = 0; i < 64; i++) x->s[i] = s[i * 2] | (s[i * 2 + 1] << 8); } int main () { unsigned int i; struct S s; for (i = 0; i < 64; i++) s.s[i] = i + ((64 - i) << 8); foo (&s); for (i = 0; i < 64; i++) if (s.s[i] != (64 - i) + (i << 8)) __builtin_abort (); return 0; } is miscompiled on s390x-linux with -m64 -march=z9-109 -mtune=z10 -O2 -fPIC since r220249, but most likely has been latent before that. make_field_assignment during combine misoptimizes: (set (mem:HI (plus:DI (reg/v/f:DI 126 [ x ]) (reg:DI 125 [ ivtmp.11 ])) [2 MEM[base: x_3(D), index: ivtmp.11_41, offset: 0B]+0 S2 A16]) (ior:HI (zero_extend:HI (mem:QI (plus:DI (reg/v/f:DI 126 [ x ]) (reg:DI 125 [ ivtmp.11 ])) [0 MEM[base: s_4, index: ivtmp.11_41, offset: 0B]+0 S1 A8])) (subreg:HI (reg:SI 128 [ D.1536 ]) 2))) into: (set (mem:QI (plus:DI (reg/v/f:DI 126 [ x ]) (reg:DI 125 [ ivtmp.11 ])) [2 MEM[base: x_3(D), index: ivtmp.11_41, offset: 0B]+0 S1 A16]) (subreg:QI (lshiftrt:SI (reg:SI 128 [ D.1536 ]) (const_int 8 [0x8])) 3)) which is just wrong for big-endian.