IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
IsGreaterRegImpl.h
Go to the documentation of this file.
1 // IsGreaterRegImpl.h:
3 // -------------------
4 //
14 
15 #ifndef __IPSDKUTIL_INSTRUCTIONSET_COMPARISON_DETAIL_SSE2_ISGREATERREGIMPL_H__
16 #define __IPSDKUTIL_INSTRUCTIONSET_COMPARISON_DETAIL_SSE2_ISGREATERREGIMPL_H__
17 
22 
23 namespace ipsdk {
24 namespace simd {
25 namespace detail {
26 
29 
30 template <>
31 IPSDK_FORCEINLINE
32 RegMaskType<eInstructionSet::eIS_Sse2, ipInt8>::Type
33 IsGreaterReg<eInstructionSet::eIS_Sse2, ipInt8>::act(
34  const Sse2Type<ipInt8>::Type& in1,
35  const Sse2Type<ipInt8>::Type& in2)
36 {
37  return _mm_cmpgt_epi8(in1, in2);
38 }
39 
40 template <>
41 IPSDK_FORCEINLINE
42 void
43 IsGreaterReg<eInstructionSet::eIS_Sse2, ipInt8>::act(
44  const Sse2Type<ipInt8>::Type& in1,
45  const Sse2Type<ipInt8>::Type& in2,
46  RegMaskType<eInstructionSet::eIS_Sse2, ipInt8>::Type& out)
47 {
48  out = _mm_cmpgt_epi8(in1, in2);
49 }
50 
51 template <>
52 IPSDK_FORCEINLINE
53 RegMaskType<eInstructionSet::eIS_Sse2, ipUInt8>::Type
54 IsGreaterReg<eInstructionSet::eIS_Sse2, ipUInt8>::act(
55  const Sse2Type<ipUInt8>::Type& in1,
56  const Sse2Type<ipUInt8>::Type& in2)
57 {
58  const Sse2Type<ipUInt8>::Type& c =
59  AssignReg<eInstructionSet::eIS_Sse2, ipUInt8>::act(0x80);
60  const Sse2Type<ipUInt8>::Type& in1Cvt =
61  BitwiseXOrReg<eInstructionSet::eIS_Sse2, ipUInt8>::act(in1, c);
62  const Sse2Type<ipUInt8>::Type& in2Cvt =
63  BitwiseXOrReg<eInstructionSet::eIS_Sse2, ipUInt8>::act(in2, c);
64 
65  return _mm_cmpgt_epi8(in1Cvt, in2Cvt);
66 }
67 
68 template <>
69 IPSDK_FORCEINLINE
70 void
71 IsGreaterReg<eInstructionSet::eIS_Sse2, ipUInt8>::act(
72  const Sse2Type<ipUInt8>::Type& in1,
73  const Sse2Type<ipUInt8>::Type& in2,
74  RegMaskType<eInstructionSet::eIS_Sse2, ipUInt8>::Type& out)
75 {
76  Sse2Type<ipUInt8>::Type c;
77  AssignReg<eInstructionSet::eIS_Sse2, ipUInt8>::act(c, 0x80);
78  Sse2Type<ipUInt8>::Type in1Cvt;
79  BitwiseXOrReg<eInstructionSet::eIS_Sse2, ipUInt8>::act(in1, c, in1Cvt);
80  Sse2Type<ipUInt8>::Type in2Cvt;
81  BitwiseXOrReg<eInstructionSet::eIS_Sse2, ipUInt8>::act(in2, c, in2Cvt);
82 
83  out = _mm_cmpgt_epi8(in1Cvt, in2Cvt);
84 }
85 
86 template <>
87 IPSDK_FORCEINLINE
88 RegMaskType<eInstructionSet::eIS_Sse2, ipInt16>::Type
89 IsGreaterReg<eInstructionSet::eIS_Sse2, ipInt16>::act(
90  const Sse2Type<ipInt16>::Type& in1,
91  const Sse2Type<ipInt16>::Type& in2)
92 {
93  return _mm_cmpgt_epi16(in1, in2);
94 }
95 
96 template <>
97 IPSDK_FORCEINLINE
98 void
99 IsGreaterReg<eInstructionSet::eIS_Sse2, ipInt16>::act(
100  const Sse2Type<ipInt16>::Type& in1,
101  const Sse2Type<ipInt16>::Type& in2,
102  RegMaskType<eInstructionSet::eIS_Sse2, ipInt16>::Type& out)
103 {
104  out = _mm_cmpgt_epi16(in1, in2);
105 }
106 
107 template <>
108 IPSDK_FORCEINLINE
109 RegMaskType<eInstructionSet::eIS_Sse2, ipUInt16>::Type
110 IsGreaterReg<eInstructionSet::eIS_Sse2, ipUInt16>::act(
111  const Sse2Type<ipUInt16>::Type& in1,
112  const Sse2Type<ipUInt16>::Type& in2)
113 {
114  const Sse2Type<ipUInt16>::Type& c =
115  AssignReg<eInstructionSet::eIS_Sse2, ipUInt16>::act(0x8000);
116  const Sse2Type<ipUInt16>::Type& in1Cvt =
117  BitwiseXOrReg<eInstructionSet::eIS_Sse2, ipUInt16>::act(in1, c);
118  const Sse2Type<ipUInt16>::Type& in2Cvt =
119  BitwiseXOrReg<eInstructionSet::eIS_Sse2, ipUInt16>::act(in2, c);
120 
121  return _mm_cmpgt_epi16(in1Cvt, in2Cvt);
122 }
123 
124 template <>
125 IPSDK_FORCEINLINE
126 void
127 IsGreaterReg<eInstructionSet::eIS_Sse2, ipUInt16>::act(
128  const Sse2Type<ipUInt16>::Type& in1,
129  const Sse2Type<ipUInt16>::Type& in2,
130  RegMaskType<eInstructionSet::eIS_Sse2, ipInt8>::Type& out)
131 {
132  Sse2Type<ipUInt16>::Type c;
133  AssignReg<eInstructionSet::eIS_Sse2, ipUInt16>::act(c, 0x8000);
134  Sse2Type<ipUInt16>::Type in1Cvt;
135  BitwiseXOrReg<eInstructionSet::eIS_Sse2, ipUInt16>::act(in1, c, in1Cvt);
136  Sse2Type<ipUInt16>::Type in2Cvt;
137  BitwiseXOrReg<eInstructionSet::eIS_Sse2, ipUInt16>::act(in2, c, in2Cvt);
138 
139  out = _mm_cmpgt_epi16(in1Cvt, in2Cvt);
140 }
141 
142 template <>
143 IPSDK_FORCEINLINE
144 RegMaskType<eInstructionSet::eIS_Sse2, ipInt32>::Type
145 IsGreaterReg<eInstructionSet::eIS_Sse2, ipInt32>::act(
146  const Sse2Type<ipInt32>::Type& in1,
147  const Sse2Type<ipInt32>::Type& in2)
148 {
149  return _mm_cmpgt_epi32(in1, in2);
150 }
151 
152 template <>
153 IPSDK_FORCEINLINE
154 void
155 IsGreaterReg<eInstructionSet::eIS_Sse2, ipInt32>::act(
156  const Sse2Type<ipInt32>::Type& in1,
157  const Sse2Type<ipInt32>::Type& in2,
158  RegMaskType<eInstructionSet::eIS_Sse2, ipInt32>::Type& out)
159 {
160  out = _mm_cmpgt_epi32(in1, in2);
161 }
162 
163 template <>
164 IPSDK_FORCEINLINE
165 RegMaskType<eInstructionSet::eIS_Sse2, ipUInt32>::Type
166 IsGreaterReg<eInstructionSet::eIS_Sse2, ipUInt32>::act(
167  const Sse2Type<ipUInt32>::Type& in1,
168  const Sse2Type<ipUInt32>::Type& in2)
169 {
170  const Sse2Type<ipUInt32>::Type& c =
171  AssignReg<eInstructionSet::eIS_Sse2, ipUInt32>::act(0x80000000);
172  const Sse2Type<ipUInt32>::Type& in1Cvt =
173  BitwiseXOrReg<eInstructionSet::eIS_Sse2, ipUInt32>::act(in1, c);
174  const Sse2Type<ipUInt32>::Type& in2Cvt =
175  BitwiseXOrReg<eInstructionSet::eIS_Sse2, ipUInt32>::act(in2, c);
176 
177  return _mm_cmpgt_epi32(in1Cvt, in2Cvt);
178 }
179 
180 template <>
181 IPSDK_FORCEINLINE
182 void
183 IsGreaterReg<eInstructionSet::eIS_Sse2, ipUInt32>::act(
184  const Sse2Type<ipUInt32>::Type& in1,
185  const Sse2Type<ipUInt32>::Type& in2,
186  RegMaskType<eInstructionSet::eIS_Sse2, ipUInt32>::Type& out)
187 {
188  Sse2Type<ipUInt32>::Type c;
189  AssignReg<eInstructionSet::eIS_Sse2, ipUInt32>::act(c, 0x80000000);
190  Sse2Type<ipUInt32>::Type in1Cvt;
191  BitwiseXOrReg<eInstructionSet::eIS_Sse2, ipUInt32>::act(in1, c, in1Cvt);
192  Sse2Type<ipUInt32>::Type in2Cvt;
193  BitwiseXOrReg<eInstructionSet::eIS_Sse2, ipUInt32>::act(in2, c, in2Cvt);
194 
195  out = _mm_cmpgt_epi32(in1Cvt, in2Cvt);
196 }
197 
198 template <>
199 IPSDK_FORCEINLINE
200 RegMaskType<eInstructionSet::eIS_Sse2, ipReal32>::Type
201 IsGreaterReg<eInstructionSet::eIS_Sse2, ipReal32>::act(
202  const Sse2Type<ipReal32>::Type& in1,
203  const Sse2Type<ipReal32>::Type& in2)
204 {
205  return _mm_cmpgt_ps(in1, in2);
206 }
207 
208 template <>
209 IPSDK_FORCEINLINE
210 void
211 IsGreaterReg<eInstructionSet::eIS_Sse2, ipReal32>::act(
212  const Sse2Type<ipReal32>::Type& in1,
213  const Sse2Type<ipReal32>::Type& in2,
214  RegMaskType<eInstructionSet::eIS_Sse2, ipReal32>::Type& out)
215 {
216  out = _mm_cmpgt_ps(in1, in2);
217 }
218 
219 template <>
220 IPSDK_FORCEINLINE
221 RegMaskType<eInstructionSet::eIS_Sse2, ipReal64>::Type
222 IsGreaterReg<eInstructionSet::eIS_Sse2, ipReal64>::act(
223  const Sse2Type<ipReal64>::Type& in1,
224  const Sse2Type<ipReal64>::Type& in2)
225 {
226  return _mm_cmpgt_pd(in1, in2);
227 }
228 
229 template <>
230 IPSDK_FORCEINLINE
231 void
232 IsGreaterReg<eInstructionSet::eIS_Sse2, ipReal64>::act(
233  const Sse2Type<ipReal64>::Type& in1,
234  const Sse2Type<ipReal64>::Type& in2,
235  RegMaskType<eInstructionSet::eIS_Sse2, ipReal64>::Type& out)
236 {
237  out = _mm_cmpgt_pd(in1, in2);
238 }
239 
242 
243 } // end of namespace detail
244 } // end of namespace simd
245 } // end of namespace ipsdk
246 
247 #endif // __IPSDKUTIL_INSTRUCTIONSET_COMPARISON_DETAIL_SSE2_ISGREATERREGIMPL_H__
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
function assigning a given value of type T to a given Pack<instructionSet, T>
Predefined types for Sse2 instruction set management.