From patchwork Mon Feb 18 12:54:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 1043967 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-496504-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="ITyVqVUs"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4433k25CD4z9s3x for ; Mon, 18 Feb 2019 23:55:01 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=geDxXbJHtnMere8s0R/IjqFByAmfGFtNbgXmqcb9nLEiaHwtb5q3y FOYfqTqG+OoxmtTaj4AxnBo3TxczKQdJMvPsAitVjim45P/R9p4aC230mpE++KtW +5kxogmkMm9V0LoJjqaaveGMIkQ/dQTWXUo6fTnWyakXvTaCUOZZMU= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=BNyMFWhFX5E8yHR73Zv4XnB+z70=; b=ITyVqVUsoQJzps7Ev4lP nnP6SMUUCHG4fB6OjidREz+pZsn1VU3VUQxzQ4BekL8Bi8oRuX4xVf53Ltv4QmxP 7izEto3+mSrEnkbBX9voW7Cjq6/LfJMZ3qpryMvtxBK6MscAKdqo1HOybrz+EqEA Pc5kSwJQgPQLoYQPcRs+8Ps= Received: (qmail 64059 invoked by alias); 18 Feb 2019 12:54:54 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 64046 invoked by uid 89); 18 Feb 2019 12:54:53 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-10.6 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KAM_NUMSUBJECT, SPF_PASS autolearn=ham version=3.3.2 spammy=U*rguenther, rguenther@suse.de, sk:rguenth, rguenthersusede X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 18 Feb 2019 12:54:52 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id A5630AB4C for ; Mon, 18 Feb 2019 12:54:50 +0000 (UTC) Date: Mon, 18 Feb 2019 13:54:50 +0100 (CET) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix PR89296 Message-ID: User-Agent: Alpine 2.20 (LSU 67 2015-01-07) MIME-Version: 1.0 no-warning overloading means we should be quite narrow to catch only problematic cases when setting the flag. Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk. Richard. 2019-02-18 Richard Biener PR tree-optimization/89296 * tree-ssa-loop-ch.c (ch_base::copy_headers): Restrict setting of no-warning flag to cases that might emit the bogus warning. * gcc.dg/uninit-pr89296.c: New testcase. Index: gcc/tree-ssa-loop-ch.c =================================================================== --- gcc/tree-ssa-loop-ch.c (revision 268979) +++ gcc/tree-ssa-loop-ch.c (working copy) @@ -452,11 +452,23 @@ ch_base::copy_headers (function *fun) { gimple *stmt = gsi_stmt (bsi); if (gimple_code (stmt) == GIMPLE_COND) - gimple_set_no_warning (stmt, true); + { + tree lhs = gimple_cond_lhs (stmt); + if (gimple_cond_code (stmt) != EQ_EXPR + && gimple_cond_code (stmt) != NE_EXPR + && INTEGRAL_TYPE_P (TREE_TYPE (lhs)) + && TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (lhs))) + gimple_set_no_warning (stmt, true); + } else if (is_gimple_assign (stmt)) { enum tree_code rhs_code = gimple_assign_rhs_code (stmt); - if (TREE_CODE_CLASS (rhs_code) == tcc_comparison) + tree rhs1 = gimple_assign_rhs1 (stmt); + if (TREE_CODE_CLASS (rhs_code) == tcc_comparison + && rhs_code != EQ_EXPR + && rhs_code != NE_EXPR + && INTEGRAL_TYPE_P (TREE_TYPE (rhs1)) + && TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (rhs1))) gimple_set_no_warning (stmt, true); } } Index: gcc/testsuite/gcc.dg/uninit-pr89296.c =================================================================== --- gcc/testsuite/gcc.dg/uninit-pr89296.c (nonexistent) +++ gcc/testsuite/gcc.dg/uninit-pr89296.c (working copy) @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -Wuninitialized" } */ + +int get_a_value (); +void printk(const char *); +void test_func() +{ + int loop; + while (!loop) { /* { dg-warning "is used uninitialized" } */ + loop = get_a_value(); + printk("..."); + } +}