https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104839

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
This goes wrong during fwprop1.
In #c3 testcase at -O2 in bar we have before fwprop1:
(call_insn 6 2 7 2 (parallel [
            (set (reg:DI 3 3)
                (call (mem:SI (symbol_ref:DI ("foo") [flags 0x3] 
<function_decl 0x7fb75851b400 foo>) [0 foo S4 A8])
                    (const_int 0 [0])))
            (use (const_int 0 [0]))
            (clobber (reg:DI 96 lr))
        ]) "pr104839.c":10:13 755 {*call_value_localdi}
     (expr_list:REG_CALL_DECL (symbol_ref:DI ("foo") [flags 0x3] 
<function_decl 0x7fb75851b400 foo>)
        (nil))
    (expr_list (use (reg:DI 2 2))
        (nil)))
(insn 7 6 8 2 (set (reg:DI 126)
        (reg:DI 3 3)) "pr104839.c":10:13 670 {*movdi_internal64}
     (nil))
(insn 8 7 9 2 (set (reg/v:HI 119 [ i ])
        (subreg/s/u:HI (reg:DI 126) 0)) "pr104839.c":10:13 552
{*movhi_internal}
     (nil))
(insn 9 8 10 2 (set (reg:SI 127)
        (sign_extend:SI (reg/v:HI 119 [ i ]))) "pr104839.c":11:6 25
{*extendhisi2}
     (nil))
(insn 10 9 11 2 (set (reg:SI 128)
        (const_int -2 [0xfffffffffffffffe])) "pr104839.c":11:6 546
{*movsi_internal1}
     (nil))
(insn 11 10 12 2 (set (reg:CC 129)
        (compare:CC (reg:SI 127)
            (reg:SI 128))) "pr104839.c":11:6 785 {*cmpsi_signed}
     (nil))
which looks good to me, the function returns signed short and ppc64{,le} ABI
says that in that case the value is returned sign-extended into %r3.
subreg/s/u stands for promoted sign-extended.
But fwprop changes insns 8 to 11 into:
(insn 11 7 12 2 (set (reg:CC 129)
        (compare:CC (subreg/s/v:SI (reg:DI 126) 0)
            (const_int -2 [0xfffffffffffffffe]))) "pr104839.c":11:6 785
{*cmpsi_signed}
     (nil))
where subreg/s/v stands for promoted zero-extended.  That is wrong.

Reply via email to