This is the mail archive of the crossgcc@sources.redhat.com mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


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

Is this expected gcc behaviour?


I think I'm getting overly agressive optimization.

When I compile this function:
     extern unsigned long ptr;

     int func(void)
     {
         unsigned long val = (unsigned long)&ptr;

	 if (val == 0) {
	     return 1;
         } else {
             return 0;
         }
     }

with any optimization level > 0, I get this:
    func:
        clr.l %d0
        rts

It looks like it's assuming a pointer can't be NULL.

This is with gcc-3.4.0 [1]. If I use gcc-3.2.3, I get the following (which
I think is correct):
    func:
        move.l #ptr,%d1
        sne %d0
        extb.l %d0
        addq.l #1,%d0
        rts


It this behavior correct?


[1] These compilers are patched for RTEMS, but I don't think that
    should affect the code generated for this test.

Attachment: pgp00000.pgp
Description: PGP signature


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