[LLVMdev] Floating-point range checks

Robison, Arch arch.robison at intel.com
Tue Jan 13 11:27:03 PST 2015


After writing a simple FPRange, I've hit a stumbling block.  I don't know what LLVM code should be extended to use it.  I was initially thinking of extending LazyValueInfo, but it appears to be used for passes that don’t address the case that I need for Julia.  I’m now wondering if I’m better off extending SimplifyFCmpInst to handle the few cases in question instead of trying to be more general.  Here’s an example case for Julia where a trivially true domain check should be removed:



%jl_value_t = type {}

@jl_domain_exception = external global %jl_value_t*

declare void @jl_throw_with_superfluous_argument(%jl_value_t*, i32)

declare float @llvm.sqrt.f32(float %Val)



define float @julia_f_64805(float) {

top:

  %1 = fmul float %0, %0

  %2 = fcmp uge float %1, 0.000000e+00

  br i1 %2, label %pass, label %fail



fail:                                             ; preds = %top

  %3 = load %jl_value_t** @jl_domain_exception, align 8

  call void @jl_throw_with_superfluous_argument(%jl_value_t* %3, i32 2)

  unreachable



pass:                                             ; preds = %top

  %4 = call float @llvm.sqrt.f32(float %1)

  ret float %4

}



I just want to fold the branch.  Following Philip’s earlier suggestion, adding a routine CannotBeOrderedLessThanZero (that’s analogous to CannotBeNegativeZero) and making SimplifyFCmpInst use it would be enough to cover the cases of primary interest.  Comments?



- Arch
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150113/403987d3/attachment.html>


More information about the llvm-dev mailing list