How to implement sign function with SSE3?
<p><strong>1)</strong> Is there a way to efficiently implement <a href="https://en.wikipedia.org/wiki/Sign_function" rel="nofollow noreferrer">sign function</a> using SSE3 (no SSE4) with the following characteristics?</p>

<ul>
<li>the input is a float vector <code>__m128</code>.  </li>
<li>the output should be also <code>__m128</code> with [-1.0f, 0.0f, 1.0f] as its values  </li>
</ul>

<p>I tried this, but it didn't work (though I think it should):</p>

<pre><code>inputVal = _mm_set_ps(-0.5, 0.5, 0.0, 3.0);
comp1 = _mm_cmpgt_ps(_mm_setzero_ps(), inputVal);
comp2 = _mm_cmpgt_ps(inputVal, _mm_setzero_ps());
comp1 = _mm_castsi128_ps(_mm_castps_si128(comp1));
comp2 = _mm_castsi128_ps(_mm_castps_si128(comp2));
signVal = _mm_sub_ps(comp1, comp2);
</code></pre>

<hr>

<p><strong>2)</strong> Is there a way to create a "flag" function (I'm not sure about the right name). Namely, if <code>A &gt; B</code> the result will be <code>1</code> and <code>0</code> otherwise. The result should be floating-point (<code>__m128</code>) just like its input.</p>

<p><strong>UPDATE</strong>: It seems Cory Nelson answer will work here:</p>

<pre><code>__m128 greatherThanFlag = _mm_and_ps(_mm_cmpgt_ps(valA, valB), _mm_set1_ps(1.0f));    
__m128 lessThanFlag = _mm_and_ps(_mm_cmplt_ps(valA, valB), _mm_set1_ps(1.0f));
</code></pre>