I have a problem with 4.1 on m68k-linux, which miscompiles the following
test case during the gcse pass:
struct b {
unsigned a : 1;
unsigned b : 1;
unsigned c : 1;
unsigned d : 1;
};
unsigned int x = 1;
void f(int y, struct b *p)
{
switch (y) {
case 1:
p->a = 0;
p->b = 0;
break;
case 3:
p->a = 0;
p->b = 1;
break;
default:
return;
}
p->c = x;
p->d = 1;
}
The assignment to p->c is done via zero_extract:
(insn 46 45 48 5 (set (zero_extract:SI (mem/s/j:QI (reg/v/f:SI 31 [ p ]) [0 S1
A8])
(const_int 1 [0x1])
(const_int 2 [0x2]))
(reg:SI 40 [ x ])) 278 {*m68k.md:4815} (nil)
(nil))
The other assignments are done with (and) and (ior). When propagating the
mem expression, gcse misses this assignment and the assignment to p->d
overwrites it, because the earlier mem expression was propagated past it
in a register.
Currently I'm using the attached patch, which simply invalidates the
load/store. Now I need some help from someone, who is more familiar with
this code, whether this is the correct approach.
It would be nice if above could be changed into (zero_extract:SI (reg)),
but I guess that would be a little too complex.
--
Summary: problem with zero_extract during gcse
Product: gcc
Version: 4.1.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: rtl-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: zippel at linux-m68k dot org
GCC target triplet: m68k-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28925