Debian Codegraph @

gcc/testsuite/gcc.target/pdp11/pr108388.c

raw
1 /* { dg-do compile } */
2 /* { dg-options "-O2 -mlra" } */
3
4 typedef int SItype __attribute__ ((mode (SI)));
5 typedef unsigned int USItype __attribute__ ((mode (SI)));
6 typedef int DItype __attribute__ ((mode (DI)));
7 typedef unsigned int UDItype __attribute__ ((mode (DI)));
8 extern DItype __mulvdi3 (DItype, DItype);
9 struct DWstruct {SItype high, low;};
10
11 typedef union {
12 struct DWstruct s;
13 DItype ll;
14 } DWunion;
15
16 DItype __mulvdi3 (DItype u, DItype v) {
17 const DWunion uu = {.ll = u};
18 const DWunion vv = {.ll = v};
19
20 if (__builtin_expect (uu.s.high == uu.s.low >> ((4 * 8) - 1), 1)) {
21 if (__builtin_expect (vv.s.high == vv.s.low >> ((4 * 8) - 1), 1)) {
22 return (DItype) uu.s.low * (DItype) vv.s.low;
23 } else {
24 DWunion w0 = {.ll = (UDItype) (USItype) uu.s.low * (UDItype) (USItype) vv.s.low};
25 DWunion w1 = {.ll = (UDItype) (USItype) uu.s.low * (UDItype) (USItype) vv.s.high};
26
27 if (vv.s.high < 0)
28 w1.s.high -= uu.s.low;
29 if (uu.s.low < 0)
30 w1.ll -= vv.ll;
31 w1.ll += (USItype) w0.s.high;
32 if (__builtin_expect (w1.s.high == w1.s.low >> ((4 * 8) - 1), 1)) {
33 w0.s.high = w1.s.low;
34 return w0.ll;
35 }
36 }
37 } else {
38 if (__builtin_expect (vv.s.high == vv.s.low >> ((4 * 8) - 1), 1)) {
39 DWunion w0 = {.ll = (UDItype) (USItype) uu.s.low * (UDItype) (USItype) vv.s.low};
40 DWunion w1 = {.ll = (UDItype) (USItype) uu.s.high * (UDItype) (USItype) vv.s.low};
41
42 if (uu.s.high < 0)
43 w1.s.high -= vv.s.low;
44 if (vv.s.low < 0)
45 w1.ll -= uu.ll;
46 w1.ll += (USItype) w0.s.high;
47 if (__builtin_expect (w1.s.high == w1.s.low >> ((4 * 8) - 1), 1)) {
48 w0.s.high = w1.s.low;
49 return w0.ll;
50 }
51 } else {
52 if (uu.s.high >= 0) {
53 if (vv.s.high >= 0) {
54 if (uu.s.high == 0 && vv.s.high == 0) {
55 const DItype w = (UDItype) (USItype) uu.s.low * (UDItype) (USItype) vv.s.low;
56 if (__builtin_expect (w >= 0, 1))
57 return w;
58 }
59 } else {
60 if (uu.s.high == 0 && vv.s.high == (SItype) -1) {
61 DWunion ww = {.ll = (UDItype) (USItype) uu.s.low * (UDItype) (USItype) vv.s.low};
62 ww.s.high -= uu.s.low;
63 if (__builtin_expect (ww.s.high < 0, 1))
64 return ww.ll;
65 }
66 }
67 } else {
68 if (vv.s.high >= 0) {
69 if (uu.s.high == (SItype) -1 && vv.s.high == 0) {
70 DWunion ww = {.ll = (UDItype) (USItype) uu.s.low * (UDItype) (USItype) vv.s.low};
71
72 ww.s.high -= vv.s.low;
73 if (__builtin_expect (ww.s.high < 0, 1))
74 return ww.ll;
75 }
76 } else {
77 if ((uu.s.high & vv.s.high) == (SItype) -1 && (uu.s.low | vv.s.low) != 0) {
78 DWunion ww = {.ll = (UDItype) (USItype) uu.s.low * (UDItype) (USItype) vv.s.low};
79
80 ww.s.high -= uu.s.low;
81 ww.s.high -= vv.s.low;
82 if (__builtin_expect (ww.s.high >= 0, 1))
83 return ww.ll;
84 }
85 }
86 }
87 }
88 }
89 __builtin_trap ();
90 }