[LLVMbugs] [Bug 9661] New: Missed optimization: unnecessary branching
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Fri Apr 8 11:24:13 PDT 2011
http://llvm.org/bugs/show_bug.cgi?id=9661
Summary: Missed optimization: unnecessary branching
Product: libraries
Version: trunk
Platform: PC
OS/Version: All
Status: NEW
Severity: normal
Priority: P
Component: Scalar Optimizations
AssignedTo: unassignedbugs at nondot.org
ReportedBy: jmuizelaar at mozilla.com
CC: llvmbugs at cs.uiuc.edu
This code:
float clamp_float(float a) {
if (a > 1.0f)
return 1.0f;
else if (a < 0.0f)
return 0.0f;
else
return a;
}
compiles to:
clamp_float: # @clamp_float
movss .LCPI0_0(%rip), %xmm1
ucomiss %xmm1, %xmm0
ja .LBB0_2
pxor %xmm1, %xmm1
maxss %xmm0, %xmm1
.LBB0_2: # %return
movaps %xmm1, %xmm0
ret
It should be able to be something like:
clamp_float: # @clamp_float
movss .LCPI0_0(%rip), %xmm1
minss %xmm1, %xmm0
pxor %xmm1, %xmm1
maxss %xmm1, %xmm0
ret
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list