From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 39680 invoked by alias); 23 Jul 2015 13:26:08 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 39669 invoked by uid 89); 23 Jul 2015 13:26:07 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-ig0-f171.google.com Received: from mail-ig0-f171.google.com (HELO mail-ig0-f171.google.com) (209.85.213.171) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Thu, 23 Jul 2015 13:26:06 +0000 Received: by igr7 with SMTP id 7so93996349igr.0 for ; Thu, 23 Jul 2015 06:26:04 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.107.130.230 with SMTP id m99mr15374089ioi.34.1437657964610; Thu, 23 Jul 2015 06:26:04 -0700 (PDT) Received: by 10.107.142.7 with HTTP; Thu, 23 Jul 2015 06:26:04 -0700 (PDT) In-Reply-To: References: Date: Thu, 23 Jul 2015 13:36:00 -0000 Message-ID: Subject: Re: [PR25529] Convert (unsigned t * 2)/2 into unsigned (t & 0x7FFFFFFF) From: Richard Biener To: "Hurugalawadi, Naveen" Cc: "marc.glisse@inria.fr" , GCC Patches Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2015-07/txt/msg01939.txt.bz2 On Thu, Jul 23, 2015 at 5:47 AM, Hurugalawadi, Naveen wrote: >>> so using wi::mask is prefered here. > > Thanks for your review and comments. > > Please find attached the modified patch as per your comments. > > Please let me know if this version is okay? Ok with adding /* { dg-require-effective-target int32 } */ to the testcase. Please omit the +/* Simplify (t * 2)/2 -> t. */ +(simplify + (exact_div (mult @0 INTEGER_CST@1) @1) + (if (TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (@0))) + @0)) pattern. As a followup extend it - it shoudl also work for non-INTEGER_CST divisors and it should work for any kind of division, not just exact_div. The key here is TYPE_OVERFLOW_UNDEFINED. I believe you should find the equivalent operation in extract_trunc_div_1. Richard. > Thanks, > Naveen > > 2015-07-22 Naveen H.S > > gcc/testsuite/ChangeLog: > PR middle-end/25529 > * gcc.dg/pr25529.c: New test. > > gcc/ChangeLog: > PR middle-end/25529 > * match.pd (exact_div (mult @0 INTEGER_CST@1) @1) : New simplifier. > (trunc_div (mult @0 integer_pow2p@1) @1) : New simplifier.