[PATCH] PR rtl-optimization/53352
Meador Inge
meadori@codesourcery.com
Tue May 15 19:39:00 GMT 2012
Hi All,
As reported in PR rtl-optimization/53352 CSE currently trips up on a
paradoxical subreg case. When compiling for ARM GNU/Linux with -O3
the expanded RTL of interest looks like:
(insn 12 11 13 3 (set (reg:SI 140)
(lshiftrt:SI (reg/v:SI 135 [ tmp1 ])
(const_int 16 [0x10])))
(nil))
(insn 13 12 14 3 (set (reg:QI 141)
(subreg:QI (reg:SI 140) 0))
(nil))
(insn 14 13 15 3 (set (reg:SI 142)
(subreg:SI (reg:QI 141) 0))
(nil))
(insn 15 14 16 3 (set (reg:SI 134 [ tmp1$2 ])
(and:SI (reg:SI 142)
(const_int 255 [0xff])))
(nil))
...
(insn 29 28 30 3 (set (reg:SI 0 r0)
(const_int 0 [0]))
(nil))
after "cse1" things look like:
(insn 12 11 13 2 (set (reg:SI 140)
(const_int 65280 [0xff00]))
(nil))
(insn 13 12 14 2 (set (reg:QI 141)
(subreg:QI (reg:SI 140) 0))
(expr_list:REG_EQUAL (const_int 0 [0])
(nil)))
;; This is *not* equal to zero because the upper
;; two bytes are undefined.
(insn 14 13 15 2 (set (reg:SI 142)
(subreg:SI (reg:QI 141) 0))
(expr_list:REG_EQUAL (const_int 0 [0])
(nil)))
(insn 15 14 16 2 (set (reg:SI 134 [ tmp1$2 ])
(reg:SI 142))
(expr_list:REG_EQUAL (const_int 0 [0])
(nil)))
...
(insn 29 28 30 2 (set (reg:SI 0 r0)
(reg:SI 142))
(expr_list:REG_EQUAL (const_int 0 [0])
(nil)))
I believe the REG_EQUAL note on the set involving a paradoxical subreg
is incorrect. It eventually causes 0xFF00 to be passed to the function
'foo'.
The attached patch fixes the issue by skipping the paradoxical subreg
in 'equiv_constant'. Compiler bootstrapped for i686-pc-linux-gnu and
full GCC test runs for i686-pc-linux-gnu and arm-none-linux-gnueabi (no
regressions). OK? (If this is OK, then can someone commit for me. I don't
have write access).
gcc/
2012-05-15 Meador Inge <meadori@codesourcery.com>
PR rtl-optimization/53352
* cse.c (equiv_constant): Ignore paradoxical subregs.
gcc/testsuite/
2012-05-15 Meador Inge <meadori@codesourcery.com>
PR rtl-optimization/53352
* gcc.dg/pr53352.c: New test.
--
Meador Inge
CodeSourcery / Mentor Embedded
http://www.mentor.com/embedded-software
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr53352.patch
Type: text/x-patch
Size: 1474 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20120515/9b32dc57/attachment.bin>
More information about the Gcc-patches
mailing list