From patchwork Wed Jul 4 12:56:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 939310 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-481003-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="DnkXbaiX"; 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 41LLc825HGz9s4r for ; Wed, 4 Jul 2018 22:57:11 +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=q7NPr/uEOWpf9Hqs m80o7YSfsB3g6dDHm9pj+P+8gtmG9knBNI3LY15wXmYlORBeu7Y7Pu8lJn9fzmAn O+aZdZn7koQjJ1qdPkhOwr/J5EOlp5RNxI8nReKFlQfU3fsCgjwnJKDxVmoBWA2t icyO/tsxr8PL/K/Vhjpb9MNzXzc= 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=CrOB/SbpptW8ko/ok6giU+ 3GrgQ=; b=DnkXbaiXIzhgv0PS5sQSOTe1WnCRx4zPw7sUJmriOvQoyZ86zoUktL eStqf8cuVAuy+jzvIjhewmqOpD9VG7w6WO7UJ4Ou0/yhtnmHTKWYpzp9er30U+C4 6v5pV1PiI42epIAmYim4HcsqEOTf8bofH99hYe7KE3nHq5fvlKPlk= Received: (qmail 96485 invoked by alias); 4 Jul 2018 12:57:03 -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 96469 invoked by uid 89); 4 Jul 2018 12:57:02 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=mhighto_uhwi, expmed.c, sk:ebotcaz, UD:to_uhwi 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; Wed, 04 Jul 2018 12:56:59 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 59F18812E6 for ; Wed, 4 Jul 2018 14:56:57 +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 ZTMtKfrYWJHg for ; Wed, 4 Jul 2018 14:56:57 +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 3D40F81A10 for ; Wed, 4 Jul 2018 14:56:57 +0200 (CEST) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: Fix old thinko in choose_multiplier Date: Wed, 04 Jul 2018 14:56:54 +0200 Message-ID: <5021641.5L4pSmURtV@polaris> MIME-Version: 1.0 As spotted by the reporter of the bug, there is a small thinko at the end of choose_multiplier whereby the (N + 1)th bit of the result is set when the computed value is exactly 2**N. But it turns out that this case can never actually happen given how the function is invoked in the compiler. Bootstrapped/regtested on x86-64/Linux, applied on the mainline as obvious. 2018-07-04 Eric Botcazou PR middle-end/86380 * expmed.c (choose_multiplier): Fix incorrect comparison with mask. Index: expmed.c =================================================================== --- expmed.c (revision 262339) +++ expmed.c (working copy) @@ -3678,7 +3678,7 @@ choose_multiplier (unsigned HOST_WIDE_IN { unsigned HOST_WIDE_INT mask = (HOST_WIDE_INT_1U << n) - 1; *multiplier_ptr = mhigh.to_uhwi () & mask; - return mhigh.to_uhwi () >= mask; + return mhigh.to_uhwi () > mask; } else {