* gimple-ssa-store-merging.c (struct store_immediate_info): Add
[official-gcc.git] / gcc / testsuite / g++.dg / pr68991-1.C
blob744d13c791512c550d2505335a11968cc2af2917
1 // { dg-do compile { target i?86-*-* x86_64-*-* } }
2 // { dg-options "-std=c++11 -O3 -msse2 -mno-avx -fno-exceptions -fno-rtti -fdump-rtl-final" }
4 typedef unsigned int size_type;
6 #define _GLIBCXX_BITSET_BITS_PER_WORD  (__CHAR_BIT__ * __SIZEOF_INT__)
7 #define _GLIBCXX_BITSET_WORDS(__n) \
8   ((__n) / _GLIBCXX_BITSET_BITS_PER_WORD + \
9    ((__n) % _GLIBCXX_BITSET_BITS_PER_WORD == 0 ? 0 : 1))
11 namespace std
13   template<size_type _Nw>
14     struct _Base_bitset
15     {
16       typedef unsigned int _WordT;
17       _WordT            _M_w[_Nw];
19       _WordT&
20       _M_hiword()
21       { return _M_w[_Nw - 1]; }
23       void
24       _M_do_and(const _Base_bitset<_Nw>& __x)
25       {
26         for (size_type __i = 0; __i < _Nw; __i++)
27           _M_w[__i] &= __x._M_w[__i];
28       }
30       void
31       _M_do_flip()
32       {
33         for (size_type __i = 0; __i < _Nw; __i++)
34           _M_w[__i] = ~_M_w[__i];
35       }
37       bool
38       _M_is_equal(const _Base_bitset<_Nw>& __x) const
39       {
40         for (size_type __i = 0; __i < _Nw; ++__i)
41           if (_M_w[__i] != __x._M_w[__i])
42             return false;
43         return true;
44       }
46       bool
47       _M_is_any() const
48       {
49         for (size_type __i = 0; __i < _Nw; __i++)
50           if (_M_w[__i] != static_cast<_WordT>(0))
51             return true;
52         return false;
53       }
54     };
56   template<size_type _Extrabits>
57     struct _Sanitize
58     {
59       typedef unsigned int _WordT;
61       static void
62       _S_do_sanitize(_WordT& __val)
63       { __val &= ~((~static_cast<_WordT>(0)) << _Extrabits); }
64     };
66   template<size_type _Nb>
67     class bitset
68     : private _Base_bitset<_GLIBCXX_BITSET_WORDS(_Nb)>
69     {
70     private:
71       typedef _Base_bitset<_GLIBCXX_BITSET_WORDS(_Nb)> _Base;
72       typedef unsigned int _WordT;
74       void
75       _M_do_sanitize()
76       {
77         typedef _Sanitize<_Nb % _GLIBCXX_BITSET_BITS_PER_WORD> __sanitize_type;
78         __sanitize_type::_S_do_sanitize(this->_M_hiword());
79       }
81     public:
82       class reference
83       {
84         friend class bitset;
86         _WordT* _M_wp;
87         size_type       _M_bpos;
89       public:
90         reference&
91         flip()
92         {
93           *_M_wp ^= _Base::_S_maskbit(_M_bpos);
94           return *this;
95         }
96       };
98       bitset<_Nb>&
99       operator&=(const bitset<_Nb>& __rhs)
100       {
101         this->_M_do_and(__rhs);
102         return *this;
103       }
105       bitset<_Nb>&
106       flip()
107       {
108         this->_M_do_flip();
109         this->_M_do_sanitize();
110         return *this;
111       }
113       bitset<_Nb>
114       operator~() const
115       { return bitset<_Nb>(*this).flip(); }
117       bool
118       operator==(const bitset<_Nb>& __rhs) const
119       { return this->_M_is_equal(__rhs); }
121       bool
122       any() const
123       { return this->_M_is_any(); }
124     };
126   template<size_type _Nb>
127     inline bitset<_Nb>
128     operator&(const bitset<_Nb>& __x, const bitset<_Nb>& __y)
129     {
130       bitset<_Nb> __result(__x);
131       __result &= __y;
132       return __result;
133     }
135 template<typename T>
136 class ArrayRef {
137 public:
138     typedef const T *iterator;
140 private:
141     const T *Data;
142     size_type Length;
144 public:
145     iterator begin() const { return Data; }
146     iterator end() const { return Data + Length; }
149 const unsigned MAX_SUBTARGET_FEATURES = 128;
150 class FeatureBitset : public std::bitset<MAX_SUBTARGET_FEATURES> {
153 struct SubtargetFeatureKV {
154   FeatureBitset Value;
155   FeatureBitset Implies;
158 struct SubtargetInfoKV {
159   const void *Value;
161 class SubtargetFeatures {
162 public:
163     FeatureBitset ToggleFeature(FeatureBitset Bits,
164                                 const SubtargetFeatureKV *,
165                                 ArrayRef<SubtargetFeatureKV> FeatureTable);
168 static
169 void ClearImpliedBits(FeatureBitset &Bits,
170                       const SubtargetFeatureKV *FeatureEntry,
171                       ArrayRef<SubtargetFeatureKV> FeatureTable) {
172   for (auto &FE : FeatureTable) {
173     if ((FE.Implies & FeatureEntry->Value).any()) {
174       Bits &= ~FE.Value;
175       ClearImpliedBits(Bits, &FE, FeatureTable);
176     }
177   }
180 FeatureBitset
181 SubtargetFeatures::ToggleFeature(FeatureBitset Bits,
182                                  const SubtargetFeatureKV *FeatureEntry,
183                                  ArrayRef<SubtargetFeatureKV> FeatureTable) {
184     if ((Bits & FeatureEntry->Value) == FeatureEntry->Value) {
185       Bits &= ~FeatureEntry->Value;
186       ClearImpliedBits(Bits, FeatureEntry, FeatureTable);
187     }
188   return Bits;
191 // { dg-final { scan-rtl-dump-not "S16 A32\[^\n\]*\\\*xorv4si3" "final" } }