From patchwork Mon Jul 16 07:50:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 944175 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-481591-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="XlZfXaKc"; 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 41TbGv2ydSz9sN8 for ; Mon, 16 Jul 2018 17:52:23 +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:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=oi3LIPnRbF5O7P6m AbAl+feHawIl1o81yMokjDm319cC1RMn7n4NwNgW4+lS4sZSW4uBphSQZLyihuQX wx/cnpHY8uKd5oDEfiDwNo1PG6EvtO2L5h9cW708WqVvjRt2ulAQPFDS/9r3NrRY 0wkyNDBCzcPEfx5iTNtU8YeL99A= 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:from :to:subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=default; bh=PyLrQTAcoG979Uw8nbLQrf Mz1bE=; b=XlZfXaKcnmb+llU2zMscG0Ade1de2qgdrmUOHkEMh1IgqjlLQRcPjL 7zl6A3ZigmaCN4MquMl1E3F6JZdjIbWtMfTTNBA5aqyGdjYXbCtZxHUGQ8p/6nSk Bj68x43NWTYDSYJbtC6p5NLhTJUInKnYMFzR+mLZQ4CVvWdoIh3VY= Received: (qmail 52871 invoked by alias); 16 Jul 2018 07:52:16 -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 52861 invoked by uid 89); 16 Jul 2018 07:52:16 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-10.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=Pack X-HELO: smtp.eu.adacore.com Received: from mel.act-europe.fr (HELO smtp.eu.adacore.com) (194.98.77.210) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 16 Jul 2018 07:52:14 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id F35A581C43 for ; Mon, 16 Jul 2018 09:52:11 +0200 (CEST) Received: from smtp.eu.adacore.com ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ieCUZw9yenTU for ; Mon, 16 Jul 2018 09:52:11 +0200 (CEST) Received: from polaris.localnet (bon31-6-88-161-99-133.fbx.proxad.net [88.161.99.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.eu.adacore.com (Postfix) with ESMTPSA id C9F97818D7 for ; Mon, 16 Jul 2018 09:52:11 +0200 (CEST) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [patch] Fix PR tree-optimization/86514 Date: Mon, 16 Jul 2018 09:50:18 +0200 Message-ID: <3018517.UiVXHDucIc@polaris> MIME-Version: 1.0 Hi, this is a regression present on the mainline and 8 branch in the form of wrong code generated for an Ada program manipulating bit-packed boolean array types. The problem is in the new range optimization code of the reassoc pass: from _64 = _63 | 4; _73 = _64 & 191; _76 = _64 >> 6; _77 = (boolean) _76; _78 = (boolean) _64; _79 = _77 | _78; it deduces: Optimizing range tests _76 +[0, 0] and _64 +[0, 0] |...] _64 = _63 | 4; _73 = _64 & 191; _76 = _64 >> 6; _90 = _76 | _64; _19 = _90 != 0; _77 = (boolean) _76; _78 = (boolean) _64; _79 = _19; which is not equivalent. The proposed fix is to avoid bypassing a conversion to a boolean type from a type with greater precision in init_range_entry. Tested on x86_64-suse-linux, OK for the mainline? 2018-07-16 Eric Botcazou PR tree-optimization/86514 * tree-ssa-reassoc.c (init_range_entry) : Return for a conversion to a boolean type from a type with greater precision. 2018-07-16 Eric Botcazou * gnat.dg/opt73.adb: New test. Index: tree-ssa-reassoc.c =================================================================== --- tree-ssa-reassoc.c (revision 262658) +++ tree-ssa-reassoc.c (working copy) @@ -2168,8 +2168,13 @@ init_range_entry (struct range_entry *r, continue; CASE_CONVERT: if (is_bool) - goto do_default; - if (TYPE_PRECISION (TREE_TYPE (arg0)) == 1) + { + if ((TYPE_PRECISION (exp_type) == 1 + || TREE_CODE (exp_type) == BOOLEAN_TYPE) + && TYPE_PRECISION (TREE_TYPE (arg0)) > 1) + return; + } + else if (TYPE_PRECISION (TREE_TYPE (arg0)) == 1) { if (TYPE_UNSIGNED (TREE_TYPE (arg0))) is_bool = true;