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 target/47920] New: strange code generated for expression (a+7)/8


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47920

           Summary: strange code generated for expression (a+7)/8
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: carrot@google.com
            Target: arm-linux-androideabi


Compile the following code with options -mthumb -march=armv7-a -O2

int t08(int a)
{
  return (a+7)/8;
}

GCC 4.6 generates

t08:
    add    r3, r0, #14
    adds    r0, r0, #7
    it    mi
    movmi    r0, r3
    asrs    r0, r0, #3
    bx    lr


Why not simply generate

    adds    r0, r0, #7
    asrs    r0, r0, #3
    bx    lr


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