From patchwork Mon Nov 1 13:31:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew MacLeod X-Patchwork-Id: 1549170 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=ZJE6X2hB; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HjYqd3GyYz9sVc for ; Tue, 2 Nov 2021 00:32:28 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 60F353857C62 for ; Mon, 1 Nov 2021 13:32:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 60F353857C62 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1635773546; bh=7YijLsSCEhyJ8Yi6B6JQDk1AH9raowq1UZRNo1TOU8E=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=ZJE6X2hB1EMf6rIP5nocfu0BgKBdIx6ybeDLhTbNmD4x0YZvhqJJSn/nyqMk1ridB dU8Gs4w40aipJ76R4YeDn1W5v/WS+o89s1YqPhvMS1JDNYIZWOCPzRMsRBNpPbl0XU e14w5ANIDkxstWbXQIXzL1TfZ1x7pZl7/DHCr1+E= 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 732213858409 for ; Mon, 1 Nov 2021 13:31:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 732213858409 Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-360-dnGUFME6NeidVMYoZLCGmA-1; Mon, 01 Nov 2021 09:31:40 -0400 X-MC-Unique: dnGUFME6NeidVMYoZLCGmA-1 Received: by mail-qv1-f72.google.com with SMTP id bu1-20020ad455e1000000b0038529a6d278so16214377qvb.10 for ; Mon, 01 Nov 2021 06:31:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version:content-language; bh=7YijLsSCEhyJ8Yi6B6JQDk1AH9raowq1UZRNo1TOU8E=; b=1o8MbI8hswnYW3wxL/Ob5sGS2YfedlH9jW9NsVLxOmUqTJOaQcC8lEQR75RgKSOJCQ vFE/ypKPNxhLB2eTK98gH7AfV3W9RDWmUX3ioWUO0Y6cFX+RldysYDlLehlWfwVNhvfo WU0ftCQeg9m+Tfa+wFLuYGepSPBc5dA33m0o5q3yyS1wyvfiHLR97RjlHdZlFR2rTIA0 BRUWs0mGJV+6PIMaI5Lp9RpjtduhsxWQ+N5IuatNVL/uK/eBsjqIV3EiHnouuMToLpIG aM2GeYFlIiuoB1JEJS9gRi7a2puc7rPjvVdVM+AAIR67NoisK/rBwBU+EhghVFKNgYIQ t5Hw== X-Gm-Message-State: AOAM532sztS8ddn6rcJYqgRwAwG+SHuHR7gbF8BiAVrlRfQvM1F2O5S3 xNlN4FvVZ+vRtEx46zEXipaKaQbAA+hR44nFZU6g2wBJ7t2O8GpoxBmtDx9t/NIvQ7dDE9JHTc5 qw3UG5S2vL2loQJeGCl4O+whQ58SXnubU4Xjep6khdvOfRLKczx+ar7aB7zhdSbykZvfqPA== X-Received: by 2002:a05:620a:2982:: with SMTP id r2mr23393712qkp.425.1635773499827; Mon, 01 Nov 2021 06:31:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw79g9GuxbBVQlu71xg48mW/VsOtBb0r6XuB1FP4BcuL/5cHn9ETmg1Kiv09qUa+j68ny7JjQ== X-Received: by 2002:a05:620a:2982:: with SMTP id r2mr23393683qkp.425.1635773499516; Mon, 01 Nov 2021 06:31:39 -0700 (PDT) Received: from ?IPv6:2607:fea8:a262:5f00::38cf? ([2607:fea8:a262:5f00::38cf]) by smtp.gmail.com with ESMTPSA id s7sm3854948qtc.32.2021.11.01.06.31.37 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 01 Nov 2021 06:31:38 -0700 (PDT) To: gcc-patches Subject: [COMMITTED] PR tree-optimization/103003 - Don't register nonsensical relations. Message-ID: Date: Mon, 1 Nov 2021 09:31:36 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-CA X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Andrew MacLeod via Gcc-patches From: Andrew MacLeod Reply-To: Andrew MacLeod Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" The testcase in question has a stmt of the form:    _10 = _4 <= _4; We know this resolves to true, but when proce3ssing outgoing edges on the following branch, we try to register the relations _4 <= _4  and _4 > _4 on the 2 outgoing edges...  which is nonsense of course. this patch simply changes the registry to bai is the 2 ssa_anames are the same. If the relation is ==, then equality is already implied, and any other relation just doesn't make much sense. Bootstrapped on x86_64-pc-linux-gnu with no regressions.  Pushed. Andrew commit 0187c03be31a58ba561d535687dc00c94f0ff1aa Author: Andrew MacLeod Date: Sat Oct 30 11:00:49 2021 -0400 Don't register nonsensical relations. gcc/ PR tree-optimization/103003 * value-relation.cc (dom_oracle::register_relation): If the 2 ssa names are the same, don't register any relation. gcc/testsuite/ * gcc.dg/pr103003.c: New. diff --git a/gcc/testsuite/gcc.dg/pr103003.c b/gcc/testsuite/gcc.dg/pr103003.c new file mode 100644 index 00000000000..d3d65f8b6a6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr103003.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +typedef char int8_t; +int8_t c_4, uli_5; +unsigned short us_6; +void func_1() { + int uli_9; + short ptr_16ptr_11 = &uli_9; /* { dg-warning "initialization of*" } */ + for (; us_6 <= 6;) + if ((us_6 *= uli_9) < (uli_5 || 0) ?: ((c_4 = us_6) >= us_6) - uli_5) + uli_9 = 9; +} diff --git a/gcc/value-relation.cc b/gcc/value-relation.cc index f572bcd4dc2..f1e46d38de1 100644 --- a/gcc/value-relation.cc +++ b/gcc/value-relation.cc @@ -877,7 +877,13 @@ relation_oracle::register_edge (edge e, relation_kind k, tree op1, tree op2) void dom_oracle::register_relation (basic_block bb, relation_kind k, tree op1, tree op2) -{ // Equivalencies are handled by the equivalence oracle. +{ + // If the 2 ssa_names are the same, do nothing. An equivalence is implied, + // and no other relation makes sense. + if (op1 == op2) + return; + + // Equivalencies are handled by the equivalence oracle. if (k == EQ_EXPR) equiv_oracle::register_relation (bb, k, op1, op2); else