[PATCH] D11866: transform fmin/fmax calls when possible (PR24314)
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 13 07:31:00 PDT 2015
spatel added a comment.
"rewriting an fmax() implementation in IR"
For reference, I think that would look like this:
define double @fmax(double %x, double %y) {
entry:
%cmp0 = fcmp uno double %x, %x
br i1 %cmp0, label %return, label %if.1
if.1:
%cmp1 = fcmp uno double %y, %y
br i1 %cmp1, label %return, label %if.2
if.2:
%cmp2 = fcmp ogt double %x, %y
%max = select i1 %cmp2, double %x, double %y
br label %return
return:
%retval = phi double [ %y, %entry ], [ %x, %if.1 ], [ %max, %if.2 ]
ret double %retval
}
This is based on the C reference code from:
http://www.opensource.apple.com/source/Libm/Libm-315/Source/PowerPC/minmaxdim.c
http://reviews.llvm.org/D11866
More information about the llvm-commits
mailing list