]>
git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/gcc.target/gcn/simd-math-4.c
1 /* Test that signed division and modulus give the correct result with
2 different variations of signedness. */
4 /* Setting it this way ensures the run tests use the same flag as the
6 #pragma GCC optimize("O2")
8 typedef char v64qi
__attribute__ ((vector_size (64)));
9 typedef short v64hi
__attribute__ ((vector_size (128)));
10 typedef int v64si
__attribute__ ((vector_size (256)));
11 typedef long v64di
__attribute__ ((vector_size (512)));
30 for (i
= 0; i
< 64; i
++)
32 a
[i
] = i
* (i
>> 2) * (i
&1 ? -1 : 1);
33 b
[i
] = i
* (i
&2 ? -1 : 1);
36 for (i
= 0; i
< N
; i
++)
38 /* Calculate reference values using regular scalar div and mod. */
39 refquot
[i
] = a
[i
] / b
[i
];
40 __asm__ ("" ::: "memory");
41 refrem
[i
] = a
[i
] % b
[i
];
44 __asm__ ("" ::: "memory");
45 /* Scalar with divmod. */
46 for (i
= 0; i
< N
; i
++)
48 squot
[i
] = a
[i
] / b
[i
];
49 srem
[i
] = a
[i
] % b
[i
];
52 __asm__ ("" ::: "memory");
53 /* Vectorized with divmod. */
57 __asm__ ("" ::: "memory");
58 /* Vectorized with separte div and mod. */
60 __asm__ ("" ::: "memory");
65 __builtin_printf ("%8s: ", #VAR); \
66 for (i = 0; i < N; i++) \
67 __builtin_printf ("%d ", (int)VAR[i]); \
68 __builtin_printf ("\n");
73 __builtin_printf ("\n");
78 __builtin_printf ("\n");
81 for (i
= 0; i
< N
; i
++)
82 if (squot
[i
] != refquot
[i
]
83 || vquot
[i
] != refquot
[i
]
84 || vquot2
[i
] != refquot
[i
]
85 || srem
[i
] != refrem
[i
]
86 || vrem
[i
] != refrem
[i
]
87 || vrem2
[i
] != refrem
[i
])
92 /* { dg-final { scan-assembler-times {__divmodv64si4@rel32@lo} 1 { xfail *-*-* } } } */
93 /* { dg-final { scan-assembler-times {__udivmodv64si4@rel32@lo} 0 } } */
94 /* { dg-final { scan-assembler-times {__divv64si3@rel32@lo} 1 } } */
95 /* { dg-final { scan-assembler-times {__udivv64si3@rel32@lo} 0 } } */
96 /* { dg-final { scan-assembler-times {__modv64si3@rel32@lo} 1 } } */
97 /* { dg-final { scan-assembler-times {__umodv64si3@rel32@lo} 0 } } */
98 /* { dg-final { scan-assembler-times {__divsi3@rel32@lo} 1 } } */
99 /* { dg-final { scan-assembler-times {__udivsi3@rel32@lo} 0 } } */