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



             Bug #: 55024

           Summary: cse_process_notes_1/equiv_constant: missing mode check

                    for hardware registers

    Classification: Unclassified

           Product: gcc

           Version: 4.6.3

            Status: UNCONFIRMED

          Severity: normal

          Priority: P3

         Component: middle-end

        AssignedTo: unassig...@gcc.gnu.org

        ReportedBy: aurelien.buhrig....@gmail.com





Created attachment 28509

  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28509

cse_process_notes_1/equiv_constant



It seems there is a bug in cse_process_notes_1 (gcc 4.6.3, but should occurs on

trunk), for a private backend. The testcase is pr27364.c, compiled with -Os.



In the following RTL, the hardware register (reg:HI r2), whose natural mode is

HImode, is set to 0, but when analysing the REG_EQUAL notes of the MULT

insn during CSE pass, the (reg:SI r2) is computed to be equivalent to

(const_int 0), which is wrong (the target is big endian).



(insn 51 9 52 3 (set (reg:HI 2 r2)

        (const_int 0 [0])) gcc.c-torture/execute/pr27364.c:5 18 {*movhi1}

     (expr_list:REG_DEAD (reg:HI 31)

        (expr_list:REG_EQUAL (const_int 0 [0])

            (nil))))



(insn 52 51 12 3 (set (reg:HI 3 r3 [orig:2+2 ] [2])

        (reg/v:HI 20 [ number_of_digits_to_use ]))

gcc.c-torture/execute/pr27364.c:5 18 {*movhi1}

     (expr_list:REG_DEAD (reg/v:HI 20 [ number_of_digits_to_use ])

        (nil)))



(insn 12 52 13 3 (set (reg:SI 0 r0)

        (const_int 3321928 [0x32b048]))

gcc.c-torture/execute/pr27364.c:5 19 {movsi}

     (nil))



(insn 13 12 16 3 (parallel [

            (set (reg:SI 0 r0)

                (mult:SI (reg:SI 2 r2)

                    (reg:SI 0 r0)))

            (clobber (reg:SI 2 r2))

        ]) gcc.c-torture/execute/pr27364.c:5 54 {*mulsi3_call}

     (expr_list:REG_EQUAL (mult:SI (reg:SI 2 r2)

            (const_int 3321928 [0x32b048]))

        (expr_list:REG_DEAD (reg:HI 3 r3)

            (expr_list:REG_UNUSED (reg:SI 2 r2)

                (nil)))))



I think a mode size check is missing when processing REG code in

cse_process_notes_1. Adding such a check prevents the CSE pass from

elimintating the MULT instruction.



The attached patch fixes this issue.

I added the same check in equiv_constant as suggested by Eric Botcazou:

http://gcc.gnu.org/ml/gcc/2012-10/msg00263.html



Not yet bootstraped on trunk.

Reply via email to