This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug rtl-optimization/46598] [4.5/4.6 Regression] Miscompiles computed goto
- From: "rguenth at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 23 Nov 2010 14:11:41 +0000
- Subject: [Bug rtl-optimization/46598] [4.5/4.6 Regression] Miscompiles computed goto
- Auto-submitted: auto-generated
- References: <bug-46598-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46598
--- Comment #5 from Richard Guenther <rguenth at gcc dot gnu.org> 2010-11-23 14:11:33 UTC ---
Even smaller testcase:
static int havege_bigarray [0x100000 + 16384];
static int andpt = 0;
static volatile int *havege_pwalk = 0;
static int PT = 0;
static int PT2 = 0;
void collect_ndrand(int xxx)
{
static const int jumps[] = { &&loop40-&&loop40 };
volatile int *const RESULT = havege_bigarray;
volatile int *Pt0, *Pt1, *Pt2, *Pt3;
int i, pt, havege_hardtick;
i = 0;
goto loop00;
loop40:
pt = (PT >> 18) & 7;
PT = PT & andpt;
__asm__ __volatile__("rdtsc":"=A"(havege_hardtick));
Pt0 = &havege_pwalk[PT];
Pt1 = &havege_pwalk[PT2];
Pt2 = &havege_pwalk[PT ^ 1];
Pt3 = &havege_pwalk[PT2 ^ 4];
RESULT[i++] ^= *Pt0;
RESULT[i++] ^= *Pt1;
RESULT[i++] ^= *Pt2;
RESULT[i++] ^= *Pt3;
PT = (((RESULT[(i - 8) ^ pt] ^ havege_pwalk[PT ^ pt ^ 7])) &
(0xffffffef)) ^ ((PT2 ^ 0x10) & 0x10);
loop00:
if (i < 0x100000) goto *(&&loop40+jumps[xxx]);
}
which shows, hah:
collect_ndrand:
.LFB0:
.cfi_startproc
movl PT(%rip), %edx
movl $havege_bigarray, %eax
...
#APP
# 19 "pr46598_0.i" 1
rdtsc
# 0 "" 2
#NO_APP
movl (%rax), %esi
Same thing after regalloc:
(insn 23 22 26 3 pr46598_0.i:19 (parallel [
(set (reg:SI 1 dx)
(asm_operands/v:SI ("rdtsc") ("=A") 0 []
[]
[] pr46598_0.i:35))
(clobber (reg:QI 18 fpsr))
(clobber (reg:QI 17 flags))
]) -1 (nil))
of course the output is now completely unused, still "=A" should have
clobbered both ax and dx.