From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7943 invoked by alias); 2 Jul 2014 14:53:35 -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 7056 invoked by uid 48); 2 Jul 2014 14:53:24 -0000 From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/61673] New: [4.9/4.10 Regression] Miscompilation of _gnutls_hostname_compare on s390 Date: Wed, 02 Jul 2014 14:53: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: 4.9.1 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: jakub 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 cf_gcctarget 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: 2014-07/txt/msg00104.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61673 Bug ID: 61673 Summary: [4.9/4.10 Regression] Miscompilation of _gnutls_hostname_compare on s390 Product: gcc Version: 4.9.1 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: rtl-optimization Assignee: jakub at gcc dot gnu.org Reporter: jakub at gcc dot gnu.org Target: s390-linux char e; __attribute__((noinline, noclone)) void foo (const char *x) { char d = x[0]; int c = d; if ((c >= 0 && c <= 0x7f) == 0) e = d; } int main () { const char c[] = { 0x54, 0x87 }; e = 0x21; foo (c); if (e != 0x21) __builtin_abort (); foo (c + 1); if (e != 0x87) __builtin_abort (); return 0; } is miscompiled supposedly starting with r202393. Before combine we have: (insn 7 6 8 2 (parallel [ (set (reg:SI 47 [ D.1404 ]) (and:SI (subreg:SI (reg/v:QI 44 [ d ]) 0) (const_int 255 [0xff]))) (clobber (reg:CC 33 %cc)) ]) gnutls2.c:8 455 {*andsi3_esa} (expr_list:REG_UNUSED (reg:CC 33 %cc) (nil))) (insn 8 7 9 2 (set (reg:CCU 33 %cc) (compare:CCU (reg:SI 47 [ D.1404 ]) (const_int 127 [0x7f]))) gnutls2.c:8 39 {*cmpsi_ccu} (expr_list:REG_DEAD (reg:SI 47 [ D.1404 ]) (nil))) (jump_insn 9 8 10 2 (set (pc) (if_then_else (leu (reg:CCU 33 %cc) (const_int 0 [0])) (label_ref:SI 15) (pc))) gnutls2.c:8 599 {*cjump_31} (expr_list:REG_DEAD (reg:CCU 33 %cc) (int_list:REG_BR_PROB 3900 (nil))) -> 15) and combine turns this into: (note 7 6 8 2 NOTE_INSN_DELETED) (insn 8 7 9 2 (parallel [ (set (reg:CCZ 33 %cc) (compare:CCZ (and:SI (subreg:SI (reg/v:QI 44 [ d ]) 0) (const_int -128 [0xffffffffffffff80])) (const_int 0 [0]))) (clobber (scratch:SI)) ]) gnutls2.c:8 453 {*andsi3_cconly} (nil)) (jump_insn 9 8 10 2 (set (pc) (if_then_else (eq (reg:CCZ 33 %cc) (const_int 0 [0])) (label_ref:SI 15) (pc))) gnutls2.c:8 599 {*cjump_31} (expr_list:REG_DEAD (reg:CCU 33 %cc) (int_list:REG_BR_PROB 3900 (nil))) -> 15) The -128 should have been 128, we want to test the sign bit of QImode rather than also any of the higher bits that contain garbage.