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/21643] New: GCC fails to merge ranges in comparison.


I'd expect the result of compiling these two functions to be identical, but it
isn't:

int fish1(unsigned char c)
{
        if (c =='"' || c == 0x20 || c < 0x20)
                return 1;
}
int fish2(unsigned char c)
{
        if (c == '"' || c <= 0x20)
                return 1;
}

If I remove the 'c == '"' ||' from each, I do get the expected results.
$ gcc -O2 -S asd.c -o /dev/stdout
        .file   "asd.c"
        .section        ".text"
        .align 2
        .p2align 4,,15
        .globl fish1
        .type   fish1, @function
fish1:
        mr 0,3
        li 3,1
        cmpwi 7,0,34
        cmpwi 6,0,32
        beqlr 7
        cmplwi 7,0,31
        beqlr 6
        blelr 7
        blr
        .size   fish1,.-fish1
        .align 2
        .p2align 4,,15
        .globl fish2
        .type   fish2, @function
fish2:
        mr 0,3
        li 3,1
        cmpwi 7,0,34
        cmplwi 6,0,32
        beqlr 7
        blelr 6
        blr
        .size   fish2,.-fish2
        .ident  "GCC: (GNU) 4.0.0 20050512 (Red Hat 4.0.0-5)"
        .section        .note.GNU-stack,"",@progbits

-- 
           Summary: GCC fails to merge ranges in comparison.
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: rtl-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dwmw2 at infradead dot org
                CC: gcc-bugs at gcc dot gnu dot org,jakub at redhat dot com


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


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