[PATCH] D12882: [SimplifyCFG] do not speculate fdiv by default; it's expensive (PR24818)
Dimitry Andric via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 16 02:46:43 PDT 2015
dim added a subscriber: dim.
dim added a comment.
FWIW, this works for my test case in bug 24343 <https://llvm.org/bugs/show_bug.cgi?id=24343>. Before http://reviews.llvm.org/D12282:
double foo(int n, double d)
{
if (n > 0)
d = 1.0 / d;
return d;
}
compiles to:
foo: # @foo
# BB#0: # %entry
pushl %ebp
movl %esp, %ebp
fldl 12(%ebp)
cmpl $0, 8(%ebp)
fld1
fdiv %st(1)
jg .LBB0_2
# BB#1: # %entry
fstp %st(0)
fldz
fxch %st(1)
.LBB0_2: # %entry
fstp %st(1)
popl %ebp
retl
After http://reviews.llvm.org/D12282, it compiles to:
foo: # @foo
# BB#0: # %entry
pushl %ebp
movl %esp, %ebp
fldl 12(%ebp)
cmpl $0, 8(%ebp)
jle .LBB0_2
# BB#1: # %if.then
fld1
fdivp %st(1)
.LBB0_2: # %if.end
popl %ebp
retl
So the fdiv is no longer executed before the comparison.
http://reviews.llvm.org/D12882
More information about the llvm-commits
mailing list