From patchwork Tue Jul 18 07:31:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 789957 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-458372-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="EUFAV584"; 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 3xBX1G11nKz9s72 for ; Tue, 18 Jul 2017 17:32:15 +1000 (AEST) 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=VY2aQlt8WxRm8zSx0eLk31yDvRc6hKqWQodnc6qxmI/9Vaar62P8h OVKhotNXfkYKlPHck42bZudDMDjwofz0ZGr3DZwKS4f3Defx7CfoCpFfQvQsfuZA A3kJR7jRKXfm26TISViJ78r4TZYc2Hsp1yV8tN7TRljUbqOcXWbMVY= 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=iSPTeu5luGA00Yju95BOl6jlJYI=; b=EUFAV584TpM95jdCk+XB uoB6IkSmEu0kqnCMZeJSv00FvTgBPhC1rUVh+1H/wvMxSpK31UF+HtjMWnVZLOea hfZ7bq+NqKB4orpZjTsSK81sw8NpfbAU3St6f0nqeQ10o4nmHK36pR176O2bSBFq M1cgehuqt18Y8Zht/8Rb0VY= Received: (qmail 46764 invoked by alias); 18 Jul 2017 07:32:04 -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 31170 invoked by uid 89); 18 Jul 2017 07:31:52 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy= 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; Tue, 18 Jul 2017 07:31:48 +0000 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id F3CF5ADBA for ; Tue, 18 Jul 2017 07:31:45 +0000 (UTC) Date: Tue, 18 Jul 2017 09:31:45 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix PR81403 Message-ID: User-Agent: Alpine 2.20 (LSU 67 2015-01-07) MIME-Version: 1.0 The following fixes VN simplification during PHI translation where we can assign value-numbers to new expressions in different context and thus have to reset flow-sensitive SSA info like we do during VN. Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk. Richard. 2017-07-18 Richard Biener PR tree-optimization/80620 PR tree-optimization/81403 * tree-ssa-pre.c (phi_translate_1): Clear range and points-to info when re-using a VN table entry. * gcc.dg/torture/pr80620.c: New testcase. * gcc.dg/torture/pr81403.c: Likewise. Index: gcc/tree-ssa-pre.c =================================================================== --- gcc/tree-ssa-pre.c (revision 250270) +++ gcc/tree-ssa-pre.c (working copy) @@ -1489,6 +1489,45 @@ phi_translate_1 (pre_expr expr, bitmap_s PRE_EXPR_NARY (expr) = nary; new_val_id = nary->value_id; get_or_alloc_expression_id (expr); + /* When we end up re-using a value number make sure that + doesn't have unrelated (which we can't check here) + range or points-to info on it. */ + if (result + && INTEGRAL_TYPE_P (TREE_TYPE (result)) + && SSA_NAME_RANGE_INFO (result) + && ! SSA_NAME_IS_DEFAULT_DEF (result)) + { + if (! VN_INFO (result)->info.range_info) + { + VN_INFO (result)->info.range_info + = SSA_NAME_RANGE_INFO (result); + VN_INFO (result)->range_info_anti_range_p + = SSA_NAME_ANTI_RANGE_P (result); + } + if (dump_file && (dump_flags & TDF_DETAILS)) + { + fprintf (dump_file, "clearing range info of "); + print_generic_expr (dump_file, result); + fprintf (dump_file, "\n"); + } + SSA_NAME_RANGE_INFO (result) = NULL; + } + else if (result + && POINTER_TYPE_P (TREE_TYPE (result)) + && SSA_NAME_PTR_INFO (result) + && ! SSA_NAME_IS_DEFAULT_DEF (result)) + { + if (! VN_INFO (result)->info.ptr_info) + VN_INFO (result)->info.ptr_info + = SSA_NAME_PTR_INFO (result); + if (dump_file && (dump_flags & TDF_DETAILS)) + { + fprintf (dump_file, "clearing points-to info of "); + print_generic_expr (dump_file, result); + fprintf (dump_file, "\n"); + } + SSA_NAME_PTR_INFO (result) = NULL; + } } else { Index: gcc/testsuite/gcc.dg/torture/pr80620.c =================================================================== --- gcc/testsuite/gcc.dg/torture/pr80620.c (nonexistent) +++ gcc/testsuite/gcc.dg/torture/pr80620.c (working copy) @@ -0,0 +1,33 @@ +/* { dg-do run } */ +/* { dg-require-effective-target int32plus } */ + +long long int a = -465274079317386463LL; +int b = 856872806; +int c = -1940894202; +int d = 1718449211; +int e = -392681565; +unsigned long long int f = 13521452247506316486ULL; +int g = -13194608; + +__attribute__((noinline, noclone)) +void foo () +{ + if (!a - a) + c = b = 0; + else + d = 3UL * a == 0; + if (g / a) + e = 0 < -a + 500849970701012771LL + (unsigned long) -a; + else + f = 4081116982543369LL & a; +} + +int +main () +{ + asm volatile ("" : : : "memory"); + foo (); + if (f != 2818598057803777LL) + __builtin_abort (); + return 0; +} Index: gcc/testsuite/gcc.dg/torture/pr81403.c =================================================================== --- gcc/testsuite/gcc.dg/torture/pr81403.c (nonexistent) +++ gcc/testsuite/gcc.dg/torture/pr81403.c (working copy) @@ -0,0 +1,32 @@ +/* { dg-do run } */ +/* { dg-require-effective-target int32plus } */ + +short var_9 = 19581; +unsigned char var_33 = 21; +long long int var_55 = 286697804684061197LL; +long long int var_59 = -1962393262513510540LL; +long long int var_71 = 4731868609112929952LL; +long long int var_773 = -4784633456247777769LL; +short var_776 = 5894; +long long int var_1321 = 7573221950916697355LL; +unsigned char uc = 217; + +void foo() +{ + if (var_55) + var_71 = 0; + if (var_9 != ~(0 < uc)) + var_773 = 0; + else + var_776 = 1 / ~var_9 * -1; + if (var_33) + var_59 = ~var_9 & 10393; + var_1321 = ~var_9; +} +int main() +{ + foo(); + if (var_59 != 8320) + __builtin_abort (); + return 0; +}