This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/64785] New: [5 Regression][SH] and|or|xor #imm not used
- From: "olegendo at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 25 Jan 2015 13:11:18 +0000
- Subject: [Bug target/64785] New: [5 Regression][SH] and|or|xor #imm not used
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64785
Bug ID: 64785
Summary: [5 Regression][SH] and|or|xor #imm not used
Product: gcc
Version: 5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: olegendo at gcc dot gnu.org
Target: sh*-*-*
It seems that for some reason loading a constant is now favored instead of
using the #imm,R0 alternative.
void test000 (int* x, int xb)
{
x[0] = xb & 128;
}
void test001 (int* x, int xb)
{
x[0] = xb | 128;
}
void test002 (int* x, int xb)
{
x[0] = xb ^ 128;
}
trunk:
_test000:
mov.w .L7,r1 ! 15 *movhi/1 [length = 2]
and r1,r5 ! 7 *andsi_compact/4 [length = 2]
rts ! 18 *return_i [length = 2]
mov.l r5,@r4 ! 8 movsi_ie/9 [length = 2]
4.9:
mov r5,r0 ! 15 movsi_ie/2 [length = 2]
and #128,r0 ! 7 *andsi_compact/3 [length = 2]
rts ! 18 *return_i [length = 2]
mov.l r0,@r4 ! 8 movsi_ie/9 [length = 2]
The RTL before RA is the same in both cases:
(insn 7 4 8 2 (set (reg:SI 163 [ D.1431 ])
(and:SI (reg:SI 5 r5 [ xb ])
(const_int 128 [0x80]))) sh_tmp.cpp:257 124 {*andsi_compact}
(expr_list:REG_DEAD (reg:SI 5 r5 [ xb ])
(nil)))
(insn 8 7 0 2 (set (mem:SI (reg:SI 4 r4 [ x ]) [1 *x_4(D)+0 S4 A32])
(reg:SI 163 [ D.1431 ])) sh_tmp.cpp:257 257 {movsi_ie}
(expr_list:REG_DEAD (reg:SI 4 r4 [ x ])
(expr_list:REG_DEAD (reg:SI 163 [ D.1431 ])
(nil))))
Reload on trunk says:
Reloads for insn # 7
Reload 0: reload_in (SI) = (const_int 128 [0x80])
GENERAL_REGS, RELOAD_FOR_INPUT (opnum = 2)
reload_in_reg: (const_int 128 [0x80])
reload_reg_rtx: (reg:SI 1 r1)
While reload on 4.9 says:
Reloads for insn # 7
Reload 0: reload_in (SI) = (reg:SI 5 r5 [ xb ])
reload_out (SI) = (reg:SI 0 r0 [orig:163 D.1377 ] [163])
R0_REGS, RELOAD_OTHER (opnum = 0)
reload_in_reg: (reg:SI 5 r5 [ xb ])
reload_out_reg: (reg:SI 0 r0 [orig:163 D.1377 ] [163])
reload_reg_rtx: (reg:SI 0 r0 [orig:163 D.1377 ] [163])
Maybe this is because the function argument from hardreg r5 is propagated into
the insn. This propagation is also causing unnecessary sign/zero extensions,
see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53987#c9