Debian Codegraph @

gcc/testsuite/gcc.dg/pr113982.c

raw
1 /* PR middle-end/113982 */
2 /* { dg-do compile } */
3 /* { dg-options "-O2 -fdump-tree-widening_mul" } */
4
5 #if __SIZEOF_INT128__
6 typedef __uint128_t W;
7 typedef unsigned long long T;
8 #else
9 typedef unsigned long long W;
10 typedef unsigned int T;
11 #endif
12 #define B __CHAR_BIT__ * sizeof (T)
13
14 struct S { int p; T r; };
15
16 struct S
17 foo (T x, T y)
18 {
19 W z = (W) x + y;
20 return (struct S) { z >> B, (T) z };
21 }
22
23 struct S
24 bar (T x)
25 {
26 W z = (W) x + 132;
27 return (struct S) { z >> B, (T) z };
28 }
29
30 struct S
31 baz (T x, unsigned short y)
32 {
33 W z = (W) x + y;
34 return (struct S) { z >> B, (T) z };
35 }
36
37 struct S
38 qux (unsigned short x, T y)
39 {
40 W z = (W) x + y;
41 return (struct S) { z >> B, (T) z };
42 }
43
44 struct S
45 corge (T x, T y)
46 {
47 T w = x + y;
48 W z = (W) x + y;
49 return (struct S) { z >> B, w };
50 }
51
52 struct S
53 garple (T x, T y)
54 {
55 W z = (W) x + y;
56 T w = x + y;
57 return (struct S) { z >> B, w };
58 }
59
60 /* { dg-final { scan-tree-dump-times "ADD_OVERFLOW" 6 "widening_mul" { target { i?86-*-* x86_64-*-* } } } } */