[llvm-bugs] [Bug 24818] New: hoisting expensive ops like FP division is bad for perf
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Sep 14 16:39:24 PDT 2015
https://llvm.org/bugs/show_bug.cgi?id=24818
Bug ID: 24818
Summary: hoisting expensive ops like FP division is bad for
perf
Product: libraries
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P
Component: Transformation Utilities
Assignee: unassignedbugs at nondot.org
Reporter: spatel+llvm at rotateright.com
CC: llvm-bugs at lists.llvm.org
Classification: Unclassified
Test case based on bug 24807:
double foo(double a, double b) {
return (a > 0.0) ? b/a : 0.0;
}
If 'a' is always less than zero, then we should never clog up an FPU with a
potentially very expensive, non-pipelined division instruction. But we're
hoisting that op with 'opt' built from r247615:
target triple = "x86_64-apple-macosx10.10.0"
define double @foo(double %a, double %b) #0 {
entry:
%cmp = fcmp ogt double %a, 0.000000e+00
%div = fdiv double %b, %a
%cond = select i1 %cmp, double %div, double 0.000000e+00
ret double %cond
}
This is a relatively recent change; it doesn't happen with the clang shipped
with Xcode based on 3.6.0:
define double @foo(double %a, double %b) #0 {
%1 = fcmp ogt double %a, 0.000000e+00
br i1 %1, label %2, label %4
; <label>:2 ; preds = %0
%3 = fdiv double %b, %a
br label %4
; <label>:4 ; preds = %0, %2
%5 = phi double [ %3, %2 ], [ 0.000000e+00, %0 ]
ret double %5
}
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150914/97df1c17/attachment.html>
More information about the llvm-bugs
mailing list