[llvm-bugs] [Bug 31754] New: replacing variable by a constant breaks subtract-with-borrow (sbb) optimization
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Jan 25 04:06:18 PST 2017
https://llvm.org/bugs/show_bug.cgi?id=31754
Bug ID: 31754
Summary: replacing variable by a constant breaks
subtract-with-borrow (sbb) optimization
Product: new-bugs
Version: 3.9
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: new bugs
Assignee: unassignedbugs at nondot.org
Reporter: vincent-llvm at vinc17.net
CC: llvm-bugs at lists.llvm.org
Classification: Unclassified
In some C code, the generated x86_64 code gets worse when I replace a variable
by a constant. Example:
typedef unsigned long T;
void sub (T *p, T u, T v, T w)
{
p[0] = w - v;
p[1] = u - (w < v);
}
void sub0 (T *p, T u, T v)
{
T w = 0;
p[0] = w - v;
p[1] = u - (w < v);
}
void sub1 (T *p, T u, T v)
{
T w = 1;
p[0] = w - v;
p[1] = u - (w < v);
}
sub0 and sub1 are like sub, except that w is 0 and 1 respectively.
With Clang 3.9.1 under Debian/unstable, I get from "clang-3.9 -O3 -S":
sub: # @sub
.cfi_startproc
# BB#0:
subq %rdx, %rcx
movq %rcx, (%rdi)
sbbq $0, %rsi
movq %rsi, 8(%rdi)
retq
sub0: # @sub0
.cfi_startproc
# BB#0:
movq %rdx, %rax
negq %rax
movq %rax, (%rdi)
cmpq $1, %rdx
adcq $-1, %rsi
movq %rsi, 8(%rdi)
retq
sub1: # @sub1
.cfi_startproc
# BB#0:
movl $1, %eax
subq %rdx, %rax
movq %rax, (%rdi)
xorl %eax, %eax
cmpq $1, %rdx
seta %al
subq %rax, %rsi
movq %rsi, 8(%rdi)
retq
For sub0 and sub1, I would expect
sbbq $0, %rsi
like for sub.
--
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/20170125/7f8c9e14/attachment.html>
More information about the llvm-bugs
mailing list