[llvm-bugs] [Bug 35907] New: Overeager side effect propagation generates suboptimal backend code
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Jan 11 05:57:10 PST 2018
https://bugs.llvm.org/show_bug.cgi?id=35907
Bug ID: 35907
Summary: Overeager side effect propagation generates suboptimal
backend code
Product: libraries
Version: trunk
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: Scalar Optimizations
Assignee: unassignedbugs at nondot.org
Reporter: dave at znu.io
CC: llvm-bugs at lists.llvm.org
Consider the following two functions:
int64_t test_signed( int64_t arg) { return (arg >> 4) & -16; }
uint64_t test_unsigned(uint64_t arg) { return (arg >> 4) & -16; }
They should generate the same "AND" instruction in the backend, but due to
intermediate side effect propagation, the unsigned version generates:
%3 = and i64 %2, 1152921504606846960
Rather than:
%3 = and i64 %2, -16
This leads to suboptimal code on x86 and probably other architectures due to
how immediate values are encoded into instructions via sign extension.
As a naive observer, it seems to me that this side effect propagation should
abort of the "sign" of the unsigned value changes. This will lead to better
real world code gen in the backend.
--
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/20180111/3d3a0fc4/attachment.html>
More information about the llvm-bugs
mailing list