This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug rtl-optimization/34070] [4.1/4.2/4.3 Regression] Wrong code for (int)x%4



------- 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]