https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93504
Bug ID: 93504
Summary: Missed reassociation with constants and not of that
constant with IORs
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Keywords: missed-optimization, TREE
Severity: enhancement
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: pinskia at gcc dot gnu.org
Target Milestone: ---
Take:
#define N 0x202
#define OP |
unsigned f(unsigned a, unsigned b)
{
unsigned t = a OP b;
unsigned t1 = t&N;
unsigned t2 = a&~N;
return t1 | t2;
}
unsigned f1(unsigned a, unsigned b)
{
return b&N OP a;
}
---- CUT ---
Both of these functions are the same. On x86_64, we get the same assembly code
in the end; one most RISC targets we don't because the constants force out to
be too many instructions for combine to handle.
If N was a non-constant, we would get the same code at the tree level even.
I found this while working on bit-field lowering, when I was making sure
gcc.dg/store_merging_14.c (f7) is optimized to the best it could be.