This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/30484] Miscompilation of remainder expressions on CPUs of the i386 family
- From: "pinskia at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 16 Jan 2007 22:11:29 -0000
- Subject: [Bug target/30484] Miscompilation of remainder expressions on CPUs of the i386 family
- References: <bug-30484-1710@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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
<anything> / 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