From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20701 invoked by alias); 16 Jan 2007 22:11:41 -0000 Received: (qmail 20653 invoked by uid 48); 16 Jan 2007 22:11:29 -0000 Date: Tue, 16 Jan 2007 22:11:00 -0000 Message-ID: <20070116221129.20652.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug target/30484] Miscompilation of remainder expressions on CPUs of the i386 family In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "pinskia at gcc dot gnu dot org" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2007-01/txt/msg01314.txt.bz2 ------- Comment #3 from pinskia at gcc dot gnu dot org 2007-01-16 22:11 ------- (In reply to comment #1) > Is this specific to x86? On PowerPC (gcc 4.0.1 from Mac OS X), I get: This is because the PPC ISA says for divide: If an attempt is made to perform either of the divisions -- 0x8000_0000 / -1 or / 0, then the contents of rD are undefined, as are the contents of the LT, GT, and EQ bits of the CR0 field (if Rc = 1). In this case, if OE = 1 then OV is set. The 32-bit signed remainder of diving the contents of rA by the contents of rB can be computed as follows, exept in the case that hthe constnat of ra = - 2^31 and the constants of rB = -1. divw rD, rA, rB mullw rD, rD, rB subf rD, rD, rA ---------------------- So the ISA in fact even mentions this case :). -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30484