From patchwork Tue Nov 26 16:33:05 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kenneth Zadeck X-Patchwork-Id: 294352 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 704562C00AB for ; Wed, 27 Nov 2013 03:33:27 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type:content-transfer-encoding; q=dns; s= default; b=SVW5TWvVmjIyPLahuAYRPFUk16LT19Q4OsVMQmtyT4xvEw+MZ1+LY 17w4ZR78PgvayH4LTqggm6prdL1+1R4mpR890s0JxCla5xeX3Mx891qVYsMC4kvo J1MYnlXyREfIUknirLV5oNQde4dxYJMcQGuvfpusYxDLeHVNL6qqVM= 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 :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type:content-transfer-encoding; s=default; bh=64JQJh2oLI3W51ILzaFfl3kA6CU=; b=xuDXSxzwPmeBegsANiGgcm5YK6BY Ayznyvb6vfNScsyPe8xrJV3MtLo8saKZeE5L3z1/6i0AR5OKGnv49MshVtj7pqKZ Cjy2SvBkSV0spGFpHVQdpqiamzLmFz8l52y7Mbh+04++XhU6j8Yo7gpQ6EiuK488 r5l8V/+I0RrT84k= Received: (qmail 18844 invoked by alias); 26 Nov 2013 16:33:17 -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 18831 invoked by uid 89); 26 Nov 2013 16:33:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.9 required=5.0 tests=AWL, BAYES_50, RDNS_NONE, URIBL_BLOCKED autolearn=no version=3.3.2 X-HELO: mail-qe0-f46.google.com Received: from Unknown (HELO mail-qe0-f46.google.com) (209.85.128.46) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Tue, 26 Nov 2013 16:33:15 +0000 Received: by mail-qe0-f46.google.com with SMTP id a11so5789650qen.5 for ; Tue, 26 Nov 2013 08:33:07 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :cc:subject:references:in-reply-to:content-type :content-transfer-encoding; bh=aJOqq+KLSZe4n0t765bF7mkQpnYes9j0mGVRZbyTMCQ=; b=hl7uce4t3vfHTL/DZ9d7dNUWH1O4flgMAWr2Q1XgjiC9+uOw9tVugE9GFibVuMoIR7 oxNAHBE6KTch/ulVyVYYmX9PK3rZa5JTiGUTNAxbQgBQBizKnC1rCzKfhf9e4/4cpPEj DmQdB5nZu7L5Lgr/HLLYfq95zfcR1gBEMg8QC+EbdYpNWYnyWdy6qTcQxyE/q1D2gQUX fD9mpZwKnvXGyDarD20Aofz1N1FlEvH9x0tJdM42/r3p/1kxeVqJcJU2D1tQLLHAsIzL t6zHoQG+X63/y+/RCtc2C5uIq7XvDFXCAs9pc69L21dGPU+gy7qmKVx7QZcVgIaRJsVX rCPQ== X-Gm-Message-State: ALoCoQlJ8S30xUG4NTfPZEBJmL1TCfEu2PjvoDqd+Z65cFHVtrKXjcs9csrxjmvpBX7mwMOoFSjH X-Received: by 10.224.0.139 with SMTP id 11mr57112775qab.34.1385483587325; Tue, 26 Nov 2013 08:33:07 -0800 (PST) Received: from [192.168.1.12] (pool-98-113-157-168.nycmny.fios.verizon.net. [98.113.157.168]) by mx.google.com with ESMTPSA id n7sm6694368qai.1.2013.11.26.08.33.05 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 26 Nov 2013 08:33:05 -0800 (PST) Message-ID: <5294CD41.1040008@naturalbridge.com> Date: Tue, 26 Nov 2013 11:33:05 -0500 From: Kenneth Zadeck User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.1 MIME-Version: 1.0 To: Richard Biener CC: "Joseph S. Myers" , GCC Patches , Mike Stump , Richard Sandiford Subject: Re: Some wide-int review comments References: <87mwlfgp8s.fsf@talisman.default> <527E456B.4050203@naturalbridge.com> <5280E914.2060501@naturalbridge.com> <5280F219.6050000@naturalbridge.com> <52825432.5070502@naturalbridge.com> <52825AC9.9050604@naturalbridge.com> <528D4649.5020804@naturalbridge.com> In-Reply-To: <528D4649.5020804@naturalbridge.com> Richi, patch ping also two more pieces of information. With further testing, this seems to fix Tests that now work, but didn't before: ================ On 11/20/2013 06:31 PM, Kenneth Zadeck wrote: > On 11/13/2013 04:59 AM, Richard Biener wrote: >> On Tue, Nov 12, 2013 at 5:43 PM, Kenneth Zadeck >> wrote: >>> On 11/12/2013 11:27 AM, Joseph S. Myers wrote: >>>> On Tue, 12 Nov 2013, Kenneth Zadeck wrote: >>>> >>>>> Richi, >>>>> >>>>> i am having a little trouble putting this back the way that you want. >>>>> The >>>>> issue is rem. >>>>> what is supposed to happen for INT_MIN % -1? >>>>> >>>>> I would assume because i am failing the last case of >>>>> gcc.dg/c90-const-expr-8.c >>>>> that INT_MIN %-1 should not overflow even if INT_MIN / -1 does. >>>>> however, >>>> Given the conclusion in C11 that a%b should be considered undefined >>>> if a/b >>>> is not representable, I think it's reasonable to say INT_MIN % -1 >>>> *should* >>>> be considered to overflow (for all C standard versions) (and bug >>>> 30484 is >>>> only a bug for -fwrapv). >>>> >>> however, my local question is what do we want the api to be >>> int-const-binop-1? The existing behavior seems to be that at >>> least for >>> common modes this function silently returns 0 and it is up to the >>> front ends >>> to put their own spin on it. >> For wide-int you create 1:1 the behavior of current trunk (if a >> change of >> behavior in TImode is not tested in the testsuite then you can ignore >> that). >> Whatever change you do to semantics of functions you do separately >> from wide-int (preferably first on trunk, or at your choice after the >> wide-int >> merge). >> >> For this case in question I'd say a % -1 should return 0, but for >> INT_MIN % -1 that 0 should have TREE_OVERFLOW set (and >> thus you need to adjust that c90-const-expr-8.c testcase). >> >> Richard. >> >>> kenny > richi, > I have done this exactly as you suggested. bootstrapped and > regression tested on x86-64. > > 2013-11-20 Kenneth Zadeck > > * fold-const.c > (int_const_binop_1): Make INT_MIN % -1 return 0 with the overflow > bit set. > > > 2013-11-20 Kenneth Zadeck > > * gcc.dg/c90-const-expr-8.c: Look for overflow on INT_MIN % -1. > * gcc.dg/c99-const-expr-8.c: Look for overflow on INT_MIN % -1. > > ok to commit? > > kenny > =============== ext/random/hypergeometric_distribution/operators/values.cc (test for excess errors) New tests that PASS: ext/random/hypergeometric_distribution/operators/values.cc execution test ================ also, the corresponding frag for fold-const.c on the wide-int branch will look like ================ Index: gcc/fold-const.c =================================================================== --- gcc/fold-const.c (revision 205224) +++ gcc/fold-const.c (working copy) @@ -1030,51 +1030,51 @@ int_const_binop_1 (enum tree_code code, case TRUNC_DIV_EXPR: case EXACT_DIV_EXPR: - res = wi::div_trunc (arg1, arg2, sign, &overflow); - if (overflow) + if (arg2 == 0) return NULL_TREE; + res = wi::div_trunc (arg1, arg2, sign, &overflow); break; case FLOOR_DIV_EXPR: - res = wi::div_floor (arg1, arg2, sign, &overflow); - if (overflow) + if (arg2 == 0) return NULL_TREE; + res = wi::div_floor (arg1, arg2, sign, &overflow); break; case CEIL_DIV_EXPR: - res = wi::div_ceil (arg1, arg2, sign, &overflow); - if (overflow) + if (arg2 == 0) return NULL_TREE; + res = wi::div_ceil (arg1, arg2, sign, &overflow); break; case ROUND_DIV_EXPR: - res = wi::div_round (arg1, arg2, sign, &overflow); - if (overflow) + if (arg2 == 0) return NULL_TREE; + res = wi::div_round (arg1, arg2, sign, &overflow); break; case TRUNC_MOD_EXPR: - res = wi::mod_trunc (arg1, arg2, sign, &overflow); - if (overflow) + if (arg2 == 0) return NULL_TREE; + res = wi::mod_trunc (arg1, arg2, sign, &overflow); break; case FLOOR_MOD_EXPR: - res = wi::mod_floor (arg1, arg2, sign, &overflow); - if (overflow) + if (arg2 == 0) return NULL_TREE; + res = wi::mod_floor (arg1, arg2, sign, &overflow); break; case CEIL_MOD_EXPR: - res = wi::mod_ceil (arg1, arg2, sign, &overflow); - if (overflow) + if (arg2 == 0) return NULL_TREE; + res = wi::mod_ceil (arg1, arg2, sign, &overflow); break; case ROUND_MOD_EXPR: - res = wi::mod_round (arg1, arg2, sign, &overflow); - if (overflow) + if (arg2 == 0) return NULL_TREE; + res = wi::mod_round (arg1, arg2, sign, &overflow); break; case MIN_EXPR: