From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 619D4385B502 for ; Wed, 1 Feb 2023 11:42:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 619D4385B502 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 7B6CE33C2A; Wed, 1 Feb 2023 11:42:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1675251748; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=zIo29Y+gHx9T0A7Z8iyrZkpi3Onl3ZdPMy4BYFjk910=; b=aKIJIp8mGOL6Eib8gYptPU5UlYJ+yy9+VivEkPOBdJzCZPmrXg0xoZxXDtDPBbYwWDOn4l FliWSQ62ahpxRzL12JNp+UdLVy92FaTfMgUo5GF58R96NCSY+k6x3ada0B9Nc4iUdgeTcf iyN18XXBv1NxyWRLR5IyAXJXk4/KQvM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1675251748; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=zIo29Y+gHx9T0A7Z8iyrZkpi3Onl3ZdPMy4BYFjk910=; b=67vgbtiRjOd7t96lxmE10EYLAnRDx7Q/vVSw5ONRnm+IyMB5tQOhQoZ/ImUvahow/4rPUG BjV5iiEbHfjMCCBg== Received: from wotan.suse.de (wotan.suse.de [10.160.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 6699E2C141; Wed, 1 Feb 2023 11:42:28 +0000 (UTC) Date: Wed, 1 Feb 2023 11:42:28 +0000 (UTC) From: Richard Biener To: Jakub Jelinek cc: Jeff Law , Eric Botcazou , gcc-patches@gcc.gnu.org Subject: Re: [PATCH] ree: Fix -fcompare-debug issues in combine_reaching_defs [PR108573] In-Reply-To: Message-ID: References: User-Agent: Alpine 2.22 (LSU 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Wed, 1 Feb 2023, Jakub Jelinek wrote: > Hi! > > The PR78437 r7-4871 changes made combine_reaching_defs punt on > WORD_REGISTER_OPERATIONS targets if a setter of smaller than word > register has wider uses. This unfortunately breaks -fcompare-debug, > because if such a use appears only in DEBUG_INSN(s), while all other > uses aren't wider than the setter, we can REE optimize it without -g > and not with -g. > > Such decisions shouldn't be based on debug instructions. We could try > to reset them or adjust in some other way after we decide to perform the > change, but at least on the testcase which used to fail on riscv64-linux > the > (debug_insn 8 7 9 2 (var_location:HI s (minus:HI (subreg:HI (and:DI (reg:DI 10 a0 [160]) > (const_int 1 [0x1])) 0) > (subreg:HI (ashiftrt:DI (reg/v:DI 9 s1 [orig:151 l ] [151]) > (debug_expr:SI D#1)) 0))) "pr108573.c":12:5 -1 > (nil)) > clearly doesn't care about the upper bits and I have hard time imaging how > could one end up with DEBUG_INSN which actually cares about those upper > bits. > > So, the following patch just ignores uses on DEBUG_INSNs in this case, > if we run into something where we'd need to do something further later on, > let's deal with it when we have a testcase for it. > > Bootstrapped/regtested on x86_64-linux and i686-linux (admittedly > non-WORD_REGISTER_OPERATIONS targets) and tested using a cross to > riscv64-linux on the testcase, ok for trunk? OK. Richard. > 2023-02-01 Jakub Jelinek > > PR debug/108573 > * ree.cc (combine_reaching_defs): Don't return false for paradoxical > subregs in DEBUG_INSNs. > > * gcc.dg/pr108573.c: New test. > > --- gcc/ree.cc.jj 2023-02-01 10:19:22.833436546 +0100 > +++ gcc/ree.cc 2023-02-01 12:25:57.468252609 +0100 > @@ -875,7 +875,8 @@ combine_reaching_defs (ext_cand *cand, c > > for (df_link *use = uses; use; use = use->next) > if (paradoxical_subreg_p (GET_MODE (*DF_REF_LOC (use->ref)), > - GET_MODE (SET_DEST (*dest_sub_rtx)))) > + GET_MODE (SET_DEST (*dest_sub_rtx))) > + && !DEBUG_INSN_P (DF_REF_INSN (use->ref))) > return false; > } > > @@ -963,7 +964,8 @@ combine_reaching_defs (ext_cand *cand, c > rtx dest2 = SET_DEST (*dest_sub_rtx2); > for (use = uses; use; use = use->next) > if (paradoxical_subreg_p (GET_MODE (*DF_REF_LOC (use->ref)), > - GET_MODE (dest2))) > + GET_MODE (dest2)) > + && !DEBUG_INSN_P (DF_REF_INSN (use->ref))) > break; > if (use) > break; > --- gcc/testsuite/gcc.dg/pr108573.c.jj 2023-02-01 12:15:20.476577340 +0100 > +++ gcc/testsuite/gcc.dg/pr108573.c 2023-02-01 12:15:03.044832520 +0100 > @@ -0,0 +1,18 @@ > +/* PR debug/108573 */ > +/* { dg-do compile } */ > +/* { dg-options "-O2 -fcompare-debug" } */ > + > +unsigned g; > + > +int bar (void); > +int baz (int); > + > +void > +foo (unsigned short s, long l) > +{ > + unsigned u = bar (); > + s &= __builtin_add_overflow_p (0, u, 0); > + s %= g; > + s -= l >> s; > + baz (s); > +} > > Jakub > > -- Richard Biener SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman; HRB 36809 (AG Nuernberg)