From patchwork Tue Dec 4 11:25:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 1007582 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-491585-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="lbyKESzi"; 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 438KKx3W6lz9s0t for ; Tue, 4 Dec 2018 22:25:38 +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=Ecvlh05d8ST5eQG8wxYsAEu3Mr/0M+8MlfYII+woh/td2Gw/i2zYX JCBD0ncfVyyFIr/5WB6VGYYMARKzWNwBBUgPeeydue2awVR6eSIwcB/d8bP60dum XbRFVVa2vCT7dRMKVA1K+3Y+o3aq9FkcM1VDUHF/jo0U8WuM44aBi8= 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=S4C6DF/62nSIl2SX+dplzA3Hz/E=; b=lbyKESzicVV+AvVJCamw w38G5qUUIIHz1Vkn3JBFcS7dux0LDRlVPKyT8UCBig9OEDQJc2ypprWvIaNK+rAd 93Hm6jM6G3jqqkcsMr6uBr/yOx2gUxZezTUIp6UQ+OHqQ8a30Eroi15hkmw4wWoi RF1EALLxECgvF2wLNmf5dh4= Received: (qmail 29634 invoked by alias); 4 Dec 2018 11:25:30 -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 29605 invoked by uid 89); 4 Dec 2018 11:25:29 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.2 spammy=alter 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, 04 Dec 2018 11:25:27 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 543DEAA71 for ; Tue, 4 Dec 2018 11:25:24 +0000 (UTC) Date: Tue, 4 Dec 2018 12:25:24 +0100 (CET) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix miscompiles with latest VRP change Message-ID: User-Agent: Alpine 2.20 (LSU 67 2015-01-07) MIME-Version: 1.0 Jeff noticed that some dfp stuff was miscompiled. I appearantly didn't notice the new assert registering isn't guarded by EQ/NE_EXPR thus the following makes it fancy. Bootstrapped and tested on x86_64-unknown-linux-gnu, applied. Richard. 2018-12-04 Richard Biener PR tree-optimization/88301 * tree-vrp.c (register_edge_assert_for_2): Fix sign-conversion issues in last commit. diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index b00eca87c82..c01ae591511 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -2973,6 +2973,21 @@ register_edge_assert_for_2 (tree name, edge e, wide_int rmin, rmax; tree rhs1 = gimple_assign_rhs1 (def_stmt); if (INTEGRAL_TYPE_P (TREE_TYPE (rhs1)) + /* Make sure the relation preserves the upper/lower boundary of + the range conservatively. */ + && (comp_code == NE_EXPR + || comp_code == EQ_EXPR + || (TYPE_SIGN (TREE_TYPE (name)) + == TYPE_SIGN (TREE_TYPE (rhs1))) + || ((comp_code == LE_EXPR + || comp_code == LT_EXPR) + && !TYPE_UNSIGNED (TREE_TYPE (rhs1))) + || ((comp_code == GE_EXPR + || comp_code == GT_EXPR) + && TYPE_UNSIGNED (TREE_TYPE (rhs1)))) + /* And the conversion does not alter the value we compare + against and all values in rhs1 can be represented in + the converted to type. */ && int_fits_type_p (val, TREE_TYPE (rhs1)) && ((TYPE_PRECISION (TREE_TYPE (name)) > TYPE_PRECISION (TREE_TYPE (rhs1)))