This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug rtl-optimization/34070] [4.1/4.2/4.3 Regression] Wrong code for (int)x%4
- From: "rguenth at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 12 Nov 2007 12:42:00 -0000
- Subject: [Bug rtl-optimization/34070] [4.1/4.2/4.3 Regression] Wrong code for (int)x%4
- References: <bug-34070-6341@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #1 from rguenth at gcc dot gnu dot org 2007-11-12 12:41 -------
The difference is that we now generate
f:
.LFB2:
andl $3, %edi
movl %edi, %eax
ret
while previously we'd get the correct
f:
.LFB3:
leal 3(%rdi), %eax
cmpl $-1, %edi
cmovg %edi, %eax
andl $-4, %eax
subl %eax, %edi
movl %edi, %eax
ret
for
int f(unsigned int x)
{
return ((int)x) % 4;
}
This is a problem in fold, as we get initially:
;; Function f (f)
;; enabled by -tree-original
{
return (int) x & 3;
}
which is wrong.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |rguenth at gcc dot gnu dot
| |org
Status|UNCONFIRMED |NEW
Component|c |rtl-optimization
Ever Confirmed|0 |1
Keywords| |wrong-code
Last reconfirmed|0000-00-00 00:00:00 |2007-11-12 12:41:59
date| |
Summary|Wrong code for (int)x%4 |[4.1/4.2/4.3 Regression]
| |Wrong code for (int)x%4
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34070