Compile the attached source code with options -march=armv7-a -mthumb -Os, gcc
generates following instructions for "if (start == -1 || end == -1)":

        ...
        cmp     r4, #-1
        ite     ne
        movne   r3, #0
        moveq   r3, #1
        cmp     r0, #-1
        it      eq
        orreq   r3, r3, #1
        cbnz    r3, .L4
        ...

A simplified code sequence is:

        ...
        cmp r4, #-1
        bne .L4
        cmp r0, #-1
        bne .L4
        ...

The if statement is trivially translated into the following gimple statements:

  D.2530 = start == -1;
  D.2531 = end == -1;
  D.2532 = D.2530 || D.2531;
  if (D.2532 != 0) goto <D.2533>; else goto <D.2534>;

And then expanded into rtl insns without further optimizations.


-- 
           Summary: A lot of instructions for condition (start == -1 || end
                    == -1)
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: carrot at google dot com
 GCC build triplet: i686-linux
  GCC host triplet: i686-linux
GCC target triplet: arm-eabi


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

Reply via email to