Bug 55024 - cse_process_notes_1/equiv_constant: missing mode check for hardware registers
Summary: cse_process_notes_1/equiv_constant: missing mode check for hardware registers
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 4.6.3
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: internal-improvement, wrong-code
Depends on:
Blocks:
 
Reported: 2012-10-22 15:21 UTC by Aurelien Buhrig
Modified: 2021-12-18 23:52 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
cse_process_notes_1/equiv_constant (379 bytes, patch)
2012-10-22 15:21 UTC, Aurelien Buhrig
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Aurelien Buhrig 2012-10-22 15:21:19 UTC
Created attachment 28509 [details]
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.