From patchwork Fri Jul 13 11:24:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 943438 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-481484-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="ItVz0LpJ"; 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 41Rr7h2LZQz9s0n for ; Fri, 13 Jul 2018 21:25:03 +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=II1A94n/v8ljcqGGwi0VQPIH704Z2kzOOkr7HQddlRtSL9/84Vk7P mlibrMeXhUlG4MyMyoaYFSolUKkLLyww1TPC5PZjfbOucqtbV33RSjFF1KIARvkF 5LaTJckqKTzoYfMkwHs7m+/lxJtmQ9cDj//m5/385KWII6e6dJB5Ck= 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=ovXlxi2kZJAtgAGOombxPAG0Q0w=; b=ItVz0LpJcVNZi/IFsOd5 npt9rlNCNOpyop7cqjb9WfPe5mi7IoGsRooeifiDmq+7CPwPqNoaTKnYInXlvKjt TMqTejQG9VH6nxxl0dwVDRWPjnTP/BihIcm5Q2M0zteUhRswH1oyO+HCfLZOECT5 CQ94QtTvpkrxCIM2fHCVvaE= Received: (qmail 48066 invoked by alias); 13 Jul 2018 11:24:35 -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 47939 invoked by uid 89); 13 Jul 2018 11:24:22 -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=addr2 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; Fri, 13 Jul 2018 11:24:20 +0000 Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 20292ADB3 for ; Fri, 13 Jul 2018 11:24:14 +0000 (UTC) Date: Fri, 13 Jul 2018 13:24:14 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix PR85974 Message-ID: User-Agent: Alpine 2.20 (LSU 67 2015-01-07) MIME-Version: 1.0 The following patch fixes address difference folding to consider when one operand doesn't need a conversion. Bootstrapped and tested on x86_64-unknown-linux-gnu, applied. Richard. 2018-07-13 Richard Biener PR middle-end/85974 * match.pd (addr1 - addr2): Allow either of the operand to have a conversion. * gcc.c-torture/compile/930326-1.c: Adjust to cover widening. Index: gcc/match.pd =================================================================== --- gcc/match.pd (revision 262624) +++ gcc/match.pd (working copy) @@ -1673,14 +1673,14 @@ (define_operator_list COND_TERNARY (if (ptr_difference_const (@0, @1, &diff)) { build_int_cst_type (type, diff); })))) (simplify - (pointer_diff (convert?@2 ADDR_EXPR@0) (convert?@3 @1)) + (pointer_diff (convert?@2 ADDR_EXPR@0) (convert1?@3 @1)) (if (tree_nop_conversion_p (TREE_TYPE(@2), TREE_TYPE (@0)) && tree_nop_conversion_p (TREE_TYPE(@3), TREE_TYPE (@1))) (with { poly_int64 diff; } (if (ptr_difference_const (@0, @1, &diff)) { build_int_cst_type (type, diff); })))) (simplify - (pointer_diff (convert?@2 @0) (convert?@3 ADDR_EXPR@1)) + (pointer_diff (convert?@2 @0) (convert1?@3 ADDR_EXPR@1)) (if (tree_nop_conversion_p (TREE_TYPE(@2), TREE_TYPE (@0)) && tree_nop_conversion_p (TREE_TYPE(@3), TREE_TYPE (@1))) (with { poly_int64 diff; } Index: gcc/testsuite/gcc.c-torture/compile/930326-1.c =================================================================== --- gcc/testsuite/gcc.c-torture/compile/930326-1.c (revision 262624) +++ gcc/testsuite/gcc.c-torture/compile/930326-1.c (working copy) @@ -4,3 +4,4 @@ struct } s; long i = s.f-&s.b; +long long j = s.f-&s.b;