This resolves the majority of what I've been able to spot actually happening due to my last README entry. I've been able to think of at least one more really trivial fold that we could do: (cvtsd2si (sitofp x)) -> x. However, I don't yet have any benchmark that shows this is useful.<div>
<br></div><div>At the very least, my examples:</div><div><br></div><div><div>#include <emmintrin.h></div><div>int f(double x) { return _mm_cvtsd_si32(_mm_set_sd(x)); }</div><div>int g(double x) { return _mm_cvttsd_si32(_mm_set_sd(x)); }</div>
</div><div>int h() { return f(1.1) + g(2.2); }</div><div><br></div><div>Now compiles to:</div><div><div>define i32 @_Z1fd(double %x) nounwind readnone {</div><div>entry:</div><div>  %vecinit.i = insertelement <2 x double> undef, double %x, i32 0</div>
<div>  %0 = tail call i32 @llvm.x86.sse2.cvtsd2si(<2 x double> %vecinit.i) nounwind</div><div>  ret i32 %0</div><div>}</div><div><br></div><div>define i32 @_Z1gd(double %x) nounwind readnone {</div><div>entry:</div>
<div>  %conv.i = fptosi double %x to i32</div><div>  ret i32 %conv.i</div><div>}</div><div><br></div><div>define i32 @_Z1av() nounwind readnone {</div><div>entry:</div><div>  ret i32 3</div><div>}</div></div><div><br></div>
<div>which looks pretty good to me. =]</div><div><br></div><div>One question, where is the best place to test this? I couldn't find a direct test for ConstantFolding.</div>