2013-04-24 Vladimir Makarov <vmakarov@redhat.com>
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / pr57046.c
blob0aa43f9df6a6b9ad5e023e33c7b267895b23280f
1 /* { dg-do run } */
2 /* { dg-options "-O2" } */
4 struct emac {
5 unsigned reg[23];
6 };
8 struct mop {
9 unsigned long long addr;
10 unsigned int size;
13 unsigned int __attribute__((__noinline__))
14 level(const struct emac *obj)
16 return 0;
19 void __attribute__((__noinline__))
20 info(struct emac *dev, unsigned long long addr)
22 asm("" : : : "memory");
25 unsigned long long __attribute__((__noinline__))
26 get_value(const struct mop *mop)
28 return 0x1234567890abcdefull;
31 int __attribute__((__noinline__))
32 emac_operation(struct emac *obj, struct mop *mop)
34 unsigned long long addr = mop->addr;
35 int index = addr >> 2;
36 unsigned int value, old_value;
38 if (mop->size != 4)
39 return 0;
41 if (index >= 23) {
42 if (level(obj) >= 1)
43 info(obj, addr);
44 return 0;
47 value = get_value(mop);
48 old_value = obj->reg[index];
50 info(obj, 0);
52 switch (index) {
53 case 0:
54 obj->reg[0] = old_value;
55 break;
56 case 7:
57 case 8:
58 obj->reg[index] = value;
59 break;
62 return 0;
65 int main(void)
67 struct emac e = { { 0 } };
68 struct mop mop = { 32, 4 };
70 e.reg[8] = 0xdeadbeef;
71 emac_operation(&e, &mop);
73 if (e.reg[8] != 0x90abcdef)
74 __builtin_abort();
76 return 0;