[llvm-bugs] [Bug 43497] New: Missed optimization: Conditional multiply by -1.0 or 1.0 not simplified to negation
via llvm-bugs
llvm-bugs at lists.llvm.org
Sun Sep 29 01:38:58 PDT 2019
https://bugs.llvm.org/show_bug.cgi?id=43497
Bug ID: 43497
Summary: Missed optimization: Conditional multiply by -1.0 or
1.0 not simplified to negation
Product: libraries
Version: trunk
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: Scalar Optimizations
Assignee: unassignedbugs at nondot.org
Reporter: alvinhochun at gmail.com
CC: llvm-bugs at lists.llvm.org
Conditionally multiplying a f64 by -1.0 or 1.0 does not get optimized into a
conditional negation.
Code to reproduce:
pub fn a(num: f64, is_neg: bool) -> f64 {
num * if is_neg {
-1.0
} else {
1.0
}
}
pub fn b(num: f64, is_neg: bool) -> f64 {
if is_neg {
-num
} else {
num
}
}
https://rust.godbolt.org/z/wp28oz
Function a does not get optimized as the same as function b. The equivalent C++
code is properly optimized in GCC.
--
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/20190929/4e5b299e/attachment.html>
More information about the llvm-bugs
mailing list