From patchwork Fri Nov 3 15:40:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 117934 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp3610826qgn; Fri, 3 Nov 2017 08:40:29 -0700 (PDT) X-Google-Smtp-Source: ABhQp+SXqUIP+XUnvpvHNhAx79cvUdxPpXAsR2zNigywN/SoFrqlwC0YjbX7I6K4VEsh+d5IVDTJ X-Received: by 10.84.245.145 with SMTP id j17mr7024359pll.163.1509723629770; Fri, 03 Nov 2017 08:40:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509723629; cv=none; d=google.com; s=arc-20160816; b=P4eCGASUUPNaYlJewo/InHv+bs3VjJ6LiLnF90+XsGM5xLlWWyZ5DHy5a+I2XHGhrg 0/6dJSEsk3GDZQvQtbdf3/pO1ASe9hosLHHV+PM8rujt5BfK17gwgtWWFh47ymUaZOXP PrJ28a1wcPcGQ0Ql5omsPev85DtUgMvijnegTJSbF+bqrBN+uRIwYbcNuZrw9oDfsjPm L19zshniKH8Bpo4KZd2HMNxP4gzsOQsH/JJMGjzOJ4j7rdk6zpP87qme5z9WdpQfEWcF j3LnEiC9R4c34QXLXYJg8WlCxu9uch/u1rbgnCF3HqyOAiS3OCLRhYKAkePWVrbdiuYH 7Xhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:message-id:date:subject:mail-followup-to:to :from:delivered-to:sender:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=Z9YU+z2i62CMNYJHvUdLVDUQEP7r4KWinprs8tkU5jE=; b=JzjKHniNeARU08/FJovl02IdtnPRPNipzS2EsvdTSm6W2b2O2ITdzVk3rYNtk8uS3L 2ywa8Vyg68brkvDWAq6HGKkQiU4fzr/POjEqIHUkNRiNe3m+Sg6xKXwUH7Qdn5K1nKg6 s3YQhKzyKECR/z1E4AHuqrqiVba3GW+6PIjMdM75BHUIehh/vSOrncKrXuDhHI0KfHFl YRxQ/WrPgba35gAecwDeWfpkImW25CEMdDfidbDpWP/EJGXAt263pfUaEmXmSut0mVXQ EMJZFJ3oj3UWwKFjvckyRZA4l14kxbUCalkaCb3bKLSRpHTT4iQtiEZjQDDT5IbZZDgx y9hQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=kRDlidYw; spf=pass (google.com: domain of gcc-patches-return-465863-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-465863-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id 66si6404668pgf.326.2017.11.03.08.40.29 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 Nov 2017 08:40:29 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-465863-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=kRDlidYw; spf=pass (google.com: domain of gcc-patches-return-465863-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-465863-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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; q=dns; s= default; b=JCUm9tdMwLZMRkAHsQMx6jfdviaForkb/C1zHQ/+pOblUvJbi9WMn DItrJTNH6DzNEAwIQZtpOvAe9noYMdMQUOozwrDYCzjFk8JpOCJmOFyUP99Rm8TL YgIpn8xIdby83xTCvzkc88spuNWNRFnUmhpkOP6CAa2yXyvm3xuN7A= 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; s= default; bh=fqBwiW2IFWV0xJe1iUON6ekIAdo=; b=kRDlidYw0JNCvtHEwt++ mGANs/YY6lKda4rftJEDGvtEDC/Ty5sTJovkcb2x+u+SCyRq0LC7tsKXff01BeAn qP0MDp9ghaFtkAfDWYy8DfhC37xSUuugu/kSRd1nw/rE8Dp5tdLHTJxFvmilOTrx fHVwDz2fLnP37kbtNjE7kbs= Received: (qmail 126895 invoked by alias); 3 Nov 2017 15:40: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 126029 invoked by uid 89); 3 Nov 2017 15:40:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=Hayward, hayward X-HELO: mail-wm0-f43.google.com Received: from mail-wm0-f43.google.com (HELO mail-wm0-f43.google.com) (74.125.82.43) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 03 Nov 2017 15:40:14 +0000 Received: by mail-wm0-f43.google.com with SMTP id r68so2351636wmr.1 for ; Fri, 03 Nov 2017 08:40:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:mail-followup-to:subject:date:message-id :user-agent:mime-version; bh=Z9YU+z2i62CMNYJHvUdLVDUQEP7r4KWinprs8tkU5jE=; b=RFdv0IDDJ7X+jhWHF+IbVaegm0o+ogO5fKMWZlhHJFtf2potCJcTdkHAg+q/in4oSk ZINlIwUOCfhmkn2vSztMDMYcwWtDIP/SmHukaqyYqRC/POgOIATykjIEqQsC5h0X7bIk z3UBfAoHO+P7YxhT/nSYl6k29yJUMwLPP437V+JZLRVdkToU6swMOW+Rg0pNC5OyJO/x T18flt0EVNTUzytIFMXAW6iv+l1rvENHKeI8P4eMo3rk0JesjOeftNwWaXsOTPDSR9A6 PCzM17YRVA0MTxom4MJ76S4btiC9G5lcMIhbUCIv40QPrL4EKnW3AHvJam6PZVevPznj fyDw== X-Gm-Message-State: AJaThX4+jgeaAIozpIiLwF9oMQnhe1RgQRla+E7ALo3IUz0zTJJD6F79 EwS+36ZVWAA9D+0fBvGm3/EOCdx/+/w= X-Received: by 10.28.113.71 with SMTP id m68mr188876wmc.1.1509723612019; Fri, 03 Nov 2017 08:40:12 -0700 (PDT) Received: from localhost (188.29.164.162.threembb.co.uk. [188.29.164.162]) by smtp.gmail.com with ESMTPSA id e6sm14492311wrg.53.2017.11.03.08.40.10 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 03 Nov 2017 08:40:11 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: PR82816: Widening multiplies of bitfields Date: Fri, 03 Nov 2017 15:40:09 +0000 Message-ID: <87mv43qskm.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 In this PR we tried to create a widening multiply of two 3-bit numbers, but that isn't a widening multiply at the optab/rtl level, since both the input and output still have the same mode. We could trap this either in is_widening_mult_p or (as the patch does) in the routines that actually ask for an optab. The latter seemed more natural since is_widening_mult_p doesn't otherwise care about modes. Tested on aarch64-linux-gnu, x86_64-linux-gnu and powerpc64-linux-gnu. OK to install? Richard 2017-11-03 Richard Sandiford Alan Hayward David Sherwood gcc/ PR tree-optimization/82816 * tree-ssa-math-opts.c (convert_mult_to_widen): Return false if the modes of the two types are the same. (convert_plusminus_to_widen): Likewise. gcc/testsuite/ * gcc.c-torture/compile/pr82816.c: New test. Index: gcc/tree-ssa-math-opts.c =================================================================== --- gcc/tree-ssa-math-opts.c 2017-11-01 12:29:40.203534002 +0000 +++ gcc/tree-ssa-math-opts.c 2017-11-03 11:18:03.046411241 +0000 @@ -3259,6 +3259,9 @@ convert_mult_to_widen (gimple *stmt, gim to_mode = SCALAR_INT_TYPE_MODE (type); from_mode = SCALAR_INT_TYPE_MODE (type1); + if (to_mode == from_mode) + return false; + from_unsigned1 = TYPE_UNSIGNED (type1); from_unsigned2 = TYPE_UNSIGNED (type2); @@ -3449,6 +3452,9 @@ convert_plusminus_to_widen (gimple_stmt_ to_mode = SCALAR_TYPE_MODE (type); from_mode = SCALAR_TYPE_MODE (type1); + if (to_mode == from_mode) + return false; + from_unsigned1 = TYPE_UNSIGNED (type1); from_unsigned2 = TYPE_UNSIGNED (type2); optype = type1; Index: gcc/testsuite/gcc.c-torture/compile/pr82816.c =================================================================== --- /dev/null 2017-11-03 10:40:07.002381728 +0000 +++ gcc/testsuite/gcc.c-torture/compile/pr82816.c 2017-11-03 11:18:03.045411265 +0000 @@ -0,0 +1,12 @@ +struct A +{ + int b:3; +} d, e; + +int c; + +void f () +{ + char g = d.b * e.b; + c = g; +}