Message ID | ZB1oZcqg/ujxE+D+@tucnak |
---|---|
State | Unresolved |
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp481937vqo; Fri, 24 Mar 2023 02:14:38 -0700 (PDT) X-Google-Smtp-Source: AKy350bPILpLox25v3DEyh1ixLnKSz77369VJCIS6w0MzZOc6OLaCYXKi3CYmzEuMfJ8YRAgpC/8 X-Received: by 2002:a17:906:ca12:b0:922:cb10:ad06 with SMTP id jt18-20020a170906ca1200b00922cb10ad06mr2015783ejb.43.1679649278758; Fri, 24 Mar 2023 02:14:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679649278; cv=none; d=google.com; s=arc-20160816; b=RQpnxOQ3UN3Aa1A3UMfHQ17mB0aTRQAPAdWWTZubrnb1Bo3BZXjvxCcB+E2eTjeE2R IuaLfp79SAzbULfVgcMW43rKC/MOs+TRSWE2Q0eKFJ9ai0cbjb7ODw2xRZPyQ32X4u9K zgi1H+52vE/CqP0BEAT5V48s2xTes3KnUUGtZ2gP8aaIrErv7eQxoL3eIc8j80IRdqbQ Tt6ePObvg9Tz+8TZvCzfCNN+jdnW9CJrZPt8dI75+9kED2w9b5izjFDkaeH2SxO4fFTG dSexX5i0aFpeFeevmaA3pMwfmS5QpOazr2cBIMOZmJNvQSL62+ILnk537mxD6kaORkke vx6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:cc:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=mSeoNIMse8r+vqZQongLvViVhuEdNZLxWNZtClB1nFk=; b=e1giZAr+3G3HELuF9bne3fmuTZG3pK6ipygKY+3Lw6AXrxeezZLjhfEoqO0rijO05n X+qm/kFuo/1vV4cZBLqTISZHrSPeJCGqPrZdrymdcRgyLCxXp9FsutwxtVtPzvso5fEc Qo+r6qFlsEiNrKkKzczsEO61e8SW4SBchaCprfLM7ihBXG7YQTALo4HLN4kw1azvnN5n r6H2l4UK/CocAiQu3PBrr1jm0ojUe73oKo17Cw6gRBlIkeJPmPDZy/vUS5TieeTBPuQ/ +v1nHghAaNbjBQ3TVSIxZUxxpl+0qKNvS2qFrPRTZw561wmkDHnNdQV/wntPMRjKJD/c RmVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=xN7jo3XZ; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id vl5-20020a170907b60500b00933e496c8d5si13787541ejc.759.2023.03.24.02.14.38 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Mar 2023 02:14:38 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=xN7jo3XZ; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id ABC2F384D1BE for <ouuuleilei@gmail.com>; Fri, 24 Mar 2023 09:14:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ABC2F384D1BE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1679649277; bh=mSeoNIMse8r+vqZQongLvViVhuEdNZLxWNZtClB1nFk=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=xN7jo3XZkBefEzp1KHggsS/nw3jGTDkY2bKpYwCaBKD8LPfPOCWyJlsDU2UsoCRH9 GwKgTZltwSSg3Pg48zXn9xWRFgMyCtbU2glFVNxT0Ru6XlzVxjbPkopPLH1ZjqtQ4+ 9JXhzrn9RHC2//L0+nROhupNiR6Gvnk19vbSW09c= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 39FFC38708C2 for <gcc-patches@gcc.gnu.org>; Fri, 24 Mar 2023 09:13:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 39FFC38708C2 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-240-KeNDzARgP8mek0TYbXhFcQ-1; Fri, 24 Mar 2023 05:13:49 -0400 X-MC-Unique: KeNDzARgP8mek0TYbXhFcQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 76AEA101A550 for <gcc-patches@gcc.gnu.org>; Fri, 24 Mar 2023 09:13:29 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.16]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D53D21121314 for <gcc-patches@gcc.gnu.org>; Fri, 24 Mar 2023 09:13:27 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 32O97wqL3026905 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 24 Mar 2023 10:08:07 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 32O97oVf3026903; Fri, 24 Mar 2023 10:07:50 +0100 Date: Fri, 24 Mar 2023 10:07:49 +0100 To: Richard Biener <rguenther@suse.de> Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] builtins: Fix up ICE in inline_string_cmp [PR109258] Message-ID: <ZB1oZcqg/ujxE+D+@tucnak> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> From: Jakub Jelinek via Gcc-patches <gcc-patches@gcc.gnu.org> Reply-To: Jakub Jelinek <jakub@redhat.com> Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761239922054088789?= X-GMAIL-MSGID: =?utf-8?q?1761239922054088789?= |
Series |
builtins: Fix up ICE in inline_string_cmp [PR109258]
|
|
Checks
Context | Check | Description |
---|---|---|
snail/gcc-patch-check | warning | Git am fail log |
Commit Message
Jakub Jelinek
March 24, 2023, 9:07 a.m. UTC
Hi! The PR109086 r13-6690 inline_string_cmp change to if (diff != result) emit_move_insn (result, diff); regressed FAIL: go.test/test/fixedbugs/bug207.go, -O2 -g (internal compiler error: in emit_move_insn, at expr.cc:4224) The problem is the Go FE doesn't mark __builtin_memcmp as pure (I'll also send patch for that) and so result is const0_rtx when the call lost its lhs and the above move ICEs because moving something into const0_rtx is obviously invalid. I think it is better not to rely on all FEs having these *cmp functions pure anD DCE being performed. The following patch just punts from the inline expansion in that case, so we just emit normal library call. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2023-03-24 Jakub Jelinek <jakub@redhat.com> PR middle-end/109258 * builtins.cc (inline_expand_builtin_bytecmp): Return NULL_RTX early if target == const0_rtx. Jakub
Comments
On Fri, 24 Mar 2023, Jakub Jelinek wrote: > Hi! > > The PR109086 r13-6690 inline_string_cmp change to > if (diff != result) > emit_move_insn (result, diff); > regressed > FAIL: go.test/test/fixedbugs/bug207.go, -O2 -g (internal compiler error: in emit_move_insn, at expr.cc:4224) > The problem is the Go FE doesn't mark __builtin_memcmp as pure (I'll also > send patch for that) and so result is const0_rtx when the call lost its lhs > and the above move ICEs because moving something into const0_rtx is obviously > invalid. > I think it is better not to rely on all FEs having these *cmp functions > pure anD DCE being performed. The following patch just punts from the > inline expansion in that case, so we just emit normal library call. > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? OK. > 2023-03-24 Jakub Jelinek <jakub@redhat.com> > > PR middle-end/109258 > * builtins.cc (inline_expand_builtin_bytecmp): Return NULL_RTX early > if target == const0_rtx. > > --- gcc/builtins.cc.jj 2023-03-23 10:00:58.308100548 +0100 > +++ gcc/builtins.cc 2023-03-23 11:05:38.308135309 +0100 > @@ -7178,8 +7178,8 @@ inline_expand_builtin_bytecmp (tree exp, > bool is_ncmp = (fcode == BUILT_IN_STRNCMP || fcode == BUILT_IN_MEMCMP); > > /* Do NOT apply this inlining expansion when optimizing for size or > - optimization level below 2. */ > - if (optimize < 2 || optimize_insn_for_size_p ()) > + optimization level below 2 or if unused *cmp hasn't been DCEd. */ > + if (optimize < 2 || optimize_insn_for_size_p () || target == const0_rtx) > return NULL_RTX; > > gcc_checking_assert (fcode == BUILT_IN_STRCMP > > Jakub > >
--- gcc/builtins.cc.jj 2023-03-23 10:00:58.308100548 +0100 +++ gcc/builtins.cc 2023-03-23 11:05:38.308135309 +0100 @@ -7178,8 +7178,8 @@ inline_expand_builtin_bytecmp (tree exp, bool is_ncmp = (fcode == BUILT_IN_STRNCMP || fcode == BUILT_IN_MEMCMP); /* Do NOT apply this inlining expansion when optimizing for size or - optimization level below 2. */ - if (optimize < 2 || optimize_insn_for_size_p ()) + optimization level below 2 or if unused *cmp hasn't been DCEd. */ + if (optimize < 2 || optimize_insn_for_size_p () || target == const0_rtx) return NULL_RTX; gcc_checking_assert (fcode == BUILT_IN_STRCMP