This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/86106] New: powerpc: Suboptimal logical operation
- From: "christophe dot leroy at c-s dot fr" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 11 Jun 2018 09:23:37 +0000
- Subject: [Bug c/86106] New: powerpc: Suboptimal logical operation
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86106
Bug ID: 86106
Summary: powerpc: Suboptimal logical operation
Product: gcc
Version: 8.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: christophe.leroy@c-s.fr
Target Milestone: ---
unsigned int g(unsigned int val)
{
unsigned int mask = 0x7f7f7f7f;
return ~(((val & mask) + mask) | val | mask);
}
generates the following:
00000020 <g>:
20: 3d 20 7f 7f lis r9,32639
24: 61 29 7f 7f ori r9,r9,32639
28: 7c 69 48 38 and r9,r3,r9
2c: 3d 29 7f 7f addis r9,r9,32639
30: 39 29 7f 7f addi r9,r9,32639
34: 7d 23 1b 78 or r3,r9,r3
38: 64 63 7f 7f oris r3,r3,32639
3c: 60 63 7f 7f ori r3,r3,32639
40: 7c 63 18 f8 not r3,r3
44: 4e 80 00 20 blr
Whereas I'd expect something like:
lis r4,32639
ori r4,r4,32639
and r9,r3,r4
or r3,r3,r4
add r9,r9,r4
nor r3,r9,r3
blr