Debian Codegraph @

gcc/testsuite/g++.dg/tree-ssa/pr49516.C

raw
1 /* { dg-do run } */
2 /* { dg-options "-O2" } */
3
4 extern "C" void abort (void);
5
6 typedef int int32 __attribute__((mode (__SI__)));
7 typedef unsigned uint32 __attribute__((mode (__SI__)));
8 typedef unsigned uint64 __attribute__((mode (__DI__)));;
9 typedef int int16 __attribute__((mode (__HI__)));;
10
11 class Tp {
12 public:
13 Tp(int32, const int32 segment, const int32 index) __attribute__((noinline));
14
15 inline bool operator==(const Tp& other) const;
16 inline bool operator!=(const Tp& other) const;
17 int32 GetType() const { return type_; }
18 int32 GetSegment() const { return segment_; }
19 int32 GetIndex() const { return index_; }
20 private:
21 inline static bool IsValidSegment(const int32 segment);
22 static const int32 kSegmentBits = 28;
23 static const int32 kTypeBits = 4;
24 static const int32 kMaxSegment = (1L << kSegmentBits) - 1;
25
26 union {
27
28 struct {
29 int32 index_;
30 uint32 segment_ : kSegmentBits;
31 uint32 type_ : kTypeBits;
32 };
33 struct {
34 int32 dummy_;
35 uint32 type_and_segment_;
36 };
37 uint64 value_;
38 };
39 };
40
41 Tp::Tp(int32 t, const int32 segment, const int32 index)
42 : index_(index), segment_(segment), type_(t) {}
43
44 inline bool Tp::operator==(const Tp& other) const {
45 return value_ == other.value_;
46 }
47 inline bool Tp::operator!=(const Tp& other) const {
48 return value_ != other.value_;
49 }
50
51 class Range {
52 public:
53 inline Range(const Tp& position, const int32 count) __attribute__((always_inline));
54 inline Tp GetBeginTokenPosition() const;
55 inline Tp GetEndTokenPosition() const;
56 private:
57 Tp position_;
58 int32 count_;
59 int16 begin_index_;
60 int16 end_index_;
61 };
62
63 inline Range::Range(const Tp& position,
64 const int32 count)
65 : position_(position), count_(count), begin_index_(0), end_index_(0)
66 { }
67
68 inline Tp Range::GetBeginTokenPosition() const {
69 return position_;
70 }
71 inline Tp Range::GetEndTokenPosition() const {
72 return Tp(position_.GetType(), position_.GetSegment(),
73 position_.GetIndex() + count_);
74 }
75
76 int main ()
77 {
78 Range range(Tp(0, 0, 3), 0);
79 if (!(range.GetBeginTokenPosition() == Tp(0, 0, 3)))
80 abort ();
81
82 if (!(range.GetEndTokenPosition() == Tp(0, 0, 3)))
83 abort();
84
85 return 0;
86 }