I am having a little trouble with the fcmp one instruction on doubles only.<br><br>For ordered comparisons, the LLVM manual states that true should be returned iff neither operands is QNAN.  (<a href="http://llvm.org/docs/LangRef.html#i_fcmp" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">

http://llvm.org/docs/LangRef.html#i_fcmp</a>)<br><br>If I do fcmp one which includes one or both operands as a NaN, the result is expected to be 0 then.<br><br>If I run the bitcode with lli (JIT off), no problem.  If I use the JIT (lli --force-interpreted=true), then it returns 1.
<br><br>(Converely, fcmp une with the JIT returns 0 instead of the expected 1 ... without JIT it returns the expected 0).
<br><br>The other operators (oeq, oge, ..., ueq, uge, ...) seem to work fine.<br><br><br>Is this a bug with the JIT or have I done to muck this up?  I've included source below which illustrates the problem (with doubles on fcmp one only ... ).
<br><br>Thanks for your help.<br><br>~ David<br><br>declare void @exit(i32)<br>declare void @llvm.memcpy.i32(i8*, i8*, i32, i32)<br><br>; see if (%f1!=%f2) gives the expected result %ne_expected (doubles)<br>define void @testFCmpOrdered( double %f1, double %f2, i1 %ne_expected ) {
<br>entry:<br>  %ne_result = fcmp one double %f1, %f2<br>  %matches = icmp eq i1 %ne_result, %ne_expected<br>  br i1 %matches, label %return, label %no_match<br><br>no_match:<br>  call void @exit( i32 1 )<br>  unreachable
<br><br>return:<br>  ret void<br>}<br><br>; see if NaN ne comparisons work as expected<br>define i32 @main() {<br>entry:<br>  %x = alloca i64, align 8<br>  %nan = alloca double, align 8<br><br>  ; build NaN<br>  store i64 -1, i64* %x
<br>  %nan_as_i8 = bitcast double* %nan to i8*<br>  %x_as_i8 = bitcast i64* %x to i8*<br>  call void @llvm.memcpy.i32( i8* %nan_as_i8, i8* %x_as_i8, i32 8, i32 8 )<br><br>  ; load two copies of our NaN<br>  %nan1 = load double* %nan
<br>  %nan2 = load double* %nan<br><br>  ; compare NaN to 0 (NaN != 0 should return 0)<br>  call void @testFCmpOrdered( double %nan1, double 0.000000e+00, i1 0 )<br><br>  ; compare NaN to itself (NaN != NaN should return 0)
<br>  call void @testFCmpOrdered( double %nan1, double %nan2, i1 0 )<br><br>  ret i32 0<br>}<br><br>