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/55025] New: reg_nonzero_bits_for_combine/get_last_value: missing mode check for hardware registers


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

             Bug #: 55025
           Summary: reg_nonzero_bits_for_combine/get_last_value: missing
                    mode check for hardware registers
    Classification: Unclassified
           Product: gcc
           Version: 4.6.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: aurelien.buhrig.gcc@gmail.com


Created attachment 28511
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28511
patch

This bug occurs with gcc 4.6.3 for a private backend (big endian), but should
occurs on trunk. 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 combining insn 12 and insn 13 insn (during
combine pass), the (reg:SI r2) is computed to be equivalent to
(const_int 0), which is wrong (it is (reg:HI r2) which is (const_int 0)). 

(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)))))

The problem comes from a missing mode check in both
reg_nonzero_bits_for_combine and get_last_value.

See http://gcc.gnu.org/ml/gcc/2012-10/msg00263.html for more information.

Note that the problem in get_last_value has already been reported (bug 49884).

The attached patch fixes the issue in gcc-4.6.3. Not yet boostraped on trunk.


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