[Bug tree-optimization/63568] New: Missed optimization (a & ~mask) | (b & mask) = a ^ ((a ^ b) & mask)
olegendo at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Oct 16 23:55:00 GMT 2014
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63568
Bug ID: 63568
Summary: Missed optimization (a & ~mask) | (b & mask) = a ^ ((a
^ b) & mask)
Product: gcc
Version: 5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: olegendo at gcc dot gnu.org
Target: sh*-*-*
As of 216350, compiling the following example on SH with -O2
unsigned int test (unsigned int a, unsigned int b, unsigned int m)
{
return (a & ~m) | (b & m);
}
results in:
not r6,r0
and r0,r4
and r6,r5
mov r4,r0
rts
or r5,r0
A shorter way is to do the same is:
xor r4,r5
and r5,r6
mov r6,r0
rts
xor r4,r0
If this kind of stuff is done as part of tree optimization, then this is
probably not SH specific, although I haven't checked with other targets.
More information about the Gcc-bugs
mailing list