This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/62233] New: unnecessary shift instructions to prepare loop counter
- From: "carrot at google dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 22 Aug 2014 17:40:13 +0000
- Subject: [Bug target/62233] New: unnecessary shift instructions to prepare loop counter
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62233
Bug ID: 62233
Summary: unnecessary shift instructions to prepare loop counter
Product: gcc
Version: 5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: carrot at google dot com
Target: powerpc64le
Compile following source code with options -m64 -mcpu=power8 -O2
typedef struct {
int l;
int b[258];
} S;
void clear (S* s )
{
int i;
int len = s->l;
for (i = 0; i <= len; i++)
s->b[i] = 0;
}
Trunk gcc generates:
clear:
lwz 9,0(3)
cmpwi 7,9,0
extsw 9,9
bltlr- 7
sldi 9,9,2 // A
li 10,0
srdi 9,9,2 // B
addi 9,9,1
mtctr 9
.p2align 4,,15
.L3:
stwu 10,4(3)
bdnz .L3
blr
Instruction A shift loop counter left by 2 bits, instruction B shift loop
counter right by 2 bits, so they do nothing when combined together, and should
be removed.