From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9864 invoked by alias); 3 Sep 2011 21:20:17 -0000 Received: (qmail 9856 invoked by uid 22791); 3 Sep 2011 21:20:16 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from VLSI1.ULTRA.NYU.EDU (HELO vlsi1.ultra.nyu.edu) (128.122.140.213) by sourceware.org (qpsmtpd/0.43rc1) with SMTP; Sat, 03 Sep 2011 21:20:03 +0000 Received: by vlsi1.ultra.nyu.edu (4.1/1.34) id AA29161; Sat, 3 Sep 11 17:19:58 EDT From: kenner@vlsi1.ultra.nyu.edu (Richard Kenner) Message-Id: <11109032119.AA29161@vlsi1.ultra.nyu.edu> Date: Sat, 03 Sep 2011 21:20:00 -0000 To: richard.guenther@gmail.com Subject: Re: [PATCH] Remove bogus TYPE_IS_SIZETYPE special-casing in extract_muldiv_1 Cc: ebotcazou@adacore.com, gcc-patches@gcc.gnu.org, rguenther@suse.de In-Reply-To: References: <201109031124.37807.ebotcazou@adacore.com> <201109031708.52403.ebotcazou@adacore.com> <11109031947.AA28670@vlsi1.ultra.nyu.edu> 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 X-SW-Source: 2011-09/txt/msg00233.txt.bz2 > So what's your opinion on the "bug" that triggered the patch in question? > Namely extract_muldiv_1 folding > > (((10240 - (sizetype) first) + 1) * 8) /[cl] 8 > > to > > ((sizetype) first * 0x0fffffffffffffff8 + 81928) /[cl] 8 > > to > > ((sizetype) first * 2305843009213693951 + 10241) > > thus, folding A - B to -B + A, which is valid for unsigned types only > if overflow wraps. I think the tricky part is the optimization of (-X) * 8 to (-8 * X), especially if you then try to compute the -8 as unsigned. I don't think that's valid no matter what overflow does, but I still have a hard time reasoning about these things. > Can you give a formal definition of sizetype behavior that can be > used to prove that both transforms are valid? No, that's what I said before: I don't now have and never did have a formal definition. Which was not good.