1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
/* { dg-do compile } */
/* { dg-do run { target { s390_z14_hw } } } */
/* z14 only because we need msrkc, msc, msgrkc, msgc */
/* { dg-options "-O3 -march=z14 -mzarch --save-temps" } */
#include <stddef.h>
#include <limits.h>
int __attribute__((noinline,noclone))
smul (int a, int b, int *res)
{
return __builtin_smul_overflow(a, b, res);
}
int __attribute__((noinline,noclone))
smull (long a, long b, long *res)
{
return __builtin_smull_overflow(a, b, res);
}
int __attribute__((noinline,noclone))
smulll (long long a, long long b, long long *res)
{
return __builtin_smulll_overflow(a, b, res);
}
int
main ()
{
int ret = 0;
int result;
long lresult;
long long llresult;
ret += !!smul (INT_MAX, 2, &result);
ret += !!smull (LONG_MAX, 2, &lresult);
ret += !!smulll (LLONG_MAX, 2, &llresult);
if (ret != 3)
__builtin_abort ();
return 0;
}
/* Check that no compare or bitop instructions are emitted. */
/* { dg-final { scan-assembler-not "\tcr" } } */
/* { dg-final { scan-assembler-not "\txr" } } */
/* { dg-final { scan-assembler-not "\tnr" } } */
/* { dg-final { scan-assembler-not "\tcgr" } } */
/* { dg-final { scan-assembler-not "\txgr" } } */
/* { dg-final { scan-assembler-not "\tngr" } } */
/* On 31 bit the long long variants use risbgn to merge the 32 bit
regs into a 64 bit reg. */
/* { dg-final { scan-assembler-not "\trisbg" { target { lp64 } } } } */
/* Just one for the ret != 3 comparison. */
/* { dg-final { scan-assembler-times "ci" 1 } } */
/* { dg-final { scan-assembler-times "\tlochio\t" 3 { target { ! lp64 } } } } */
/* { dg-final { scan-assembler-times "\tlocghio\t" 3 { target lp64 } } } */
|