------- Comment #4 from rguenth at gcc dot gnu dot org  2009-11-27 13:22 -------
Actually it is some RTL optimization pass that miscompiles this (func_2).
With -fno-delete-null-pointer-checks we defer evaluating &g != 0 until
expansion which then exposes CCP opportunities.

With -O1 -fno-delete-null-pointer-checks -m32 -ftree-vrp -fno-if-conversion we
generate

func_2:
        pushl   %ebp
        movl    %esp, %ebp
        cmpl    $9, g
        jg      .L5
        movl    $1, g
        jmp     .L1
.L5:
        movl    $2, g
.L1:
        popl    %ebp
        ret

which looks good apart from that we have deleted the comparison against p.
This seems to happen between initial/final RTL during expansion.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |matz at gcc dot gnu dot org
          Component|tree-optimization           |rtl-optimization


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

Reply via email to