[llvm-bugs] [Bug 43657] New: Redundant computations should be optimized out
via llvm-bugs
llvm-bugs at lists.llvm.org
Sat Oct 12 13:19:50 PDT 2019
https://bugs.llvm.org/show_bug.cgi?id=43657
Bug ID: 43657
Summary: Redundant computations should be optimized out
Product: clang
Version: unspecified
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: LLVM Codegen
Assignee: unassignedclangbugs at nondot.org
Reporter: zamazan4ik at tut.by
CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
richard-llvm at metafoo.co.uk
For the following code:
#include <vector>
int foo(std::vector<int> a, std::vector<int> b)
{
int res = 0;
if(a.size() == b.size())
{
res = a.size() - b.size();
}
return res;
}
clang(trunk) with -O3 generates:
foo(std::vector<int, std::allocator<int> >, std::vector<int,
std::allocator<int> >): # @foo(std::vector<int, std::allocator<int>
>, std::vector<int, std::allocator<int> >)
mov rcx, qword ptr [rdi + 8]
sub rcx, qword ptr [rdi]
sar rcx, 2
mov rdx, qword ptr [rsi + 8]
sub rdx, qword ptr [rsi]
sar rdx, 2
mov esi, ecx
sub esi, edx
xor eax, eax
cmp rcx, rdx
cmove eax, esi
ret
gcc(trunk) with -O3 generates:
foo(std::vector<int, std::allocator<int> >, std::vector<int,
std::allocator<int> >):
xor eax, eax
ret
Godbolt link: https://godbolt.org/z/s1cwUt
--
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/20191012/7ed61f9c/attachment.html>
More information about the llvm-bugs
mailing list