Debian Codegraph @

gcc/testsuite/gcc.target/msp430/pr87691.c

raw
1 /* PR 87691 - Test that a union containing __int20 and a float is not treated as
2 20-bits in size. */
3
4 /* { dg-do compile } */
5 /* { dg-skip-if "no __int20 for mcpu=msp430" { *-*-* } { "-mcpu=msp430" } { "" } } */
6 /* { dg-final { scan-assembler-not "MOVX.A" } } */
7
8 /* To move a 20-bit value from memory (using indexed or indirect register
9 mode), onto the stack (also addressed using indexed or indirect register
10 mode), MOVX.A must be used. MOVA does not support these addressing modes.
11 Therefore, to check that the union is not manipulated as a 20-bit type,
12 test that no MOVX.A instructions are present in the assembly.
13
14 MOVA is used to fill/spill u.i, but if the union is treated as 20 bits in
15 size, MOVX.A would be used. No other __int20 operations are present
16 in the source, so there will be no valid uses of MOVX.A in the resulting
17 assembly. */
18
19 union U1
20 {
21 float f;
22 __int20 i;
23 };
24
25 union U2
26 {
27 __int20 i;
28 float f;
29 };
30
31 float foo1 (union U1 u)
32 {
33 u.i += 42;
34 return u.f;
35 }
36
37 float foo2 (union U2 u)
38 {
39 u.i += 42;
40 return u.f;
41 }