[llvm-bugs] [Bug 38590] New: Clang doesn't use add with carry when adding constants
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Aug 15 21:58:05 PDT 2018
https://bugs.llvm.org/show_bug.cgi?id=38590
Bug ID: 38590
Summary: Clang doesn't use add with carry when adding constants
Product: new-bugs
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: new bugs
Assignee: unassignedbugs at nondot.org
Reporter: ilya.lesokhin at gmail.com
CC: llvm-bugs at lists.llvm.org
Created attachment 20729
--> https://bugs.llvm.org/attachment.cgi?id=20729&action=edit
source file
When adding a register or a memory operand clang is able to use add with carry
to generate more efficient code.
See for example add_with_memory or add_with_register.
However, when adding a constant this optimization is missed.
See add_with_small_constants and add_with_large_constants
https://godbolt.org/g/2gb1ow
add_with_register():
add %rcx,%rdi
adc %r10,%rsi
adc %r9,%rdx
adc %r8,%rax
retq
nopl (%rax)
add_with_memory():
add 0x200b09(%rip),%rcx # 601030 <mem>
adc 0x200b0a(%rip),%rdx # 601038 <mem+0x8>
adc 0x200b0b(%rip),%rsi # 601040 <mem+0x10>
adc 0x200b0c(%rip),%rax # 601048 <mem+0x18>
retq
nopl (%rax)
add_with_small_constants():
add $0x1,%rcx
adc $0x0,%rdx
setb %al
movzbl %al,%esi
add $0x2,%rdx
adc %rdi,%rsi
setb %al
movzbl %al,%eax
add $0x3,%rsi
adc %r8,%rax
add $0x4,%rax
retq
nopw 0x0(%rax,%rax,1)
add_with_large_constants_constant():
movabs $0x3c208c16d87cfd47,%rdi
add %rax,%rdi
adc $0x0,%rcx
setb %al
movzbl %al,%eax
movabs $0x97816a916871ca8d,%rsi
add %rcx,%rsi
adc %rdx,%rax
setb %cl
movzbl %cl,%ecx
movabs $0xb85045b68181585d,%rdx
add %rax,%rdx
adc %r8,%rcx
movabs $0x30644e72e131a029,%rax
add %rcx,%rax
retq
nopl 0x0(%rax,%rax,1)
--
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/20180816/932a1f62/attachment-0001.html>
More information about the llvm-bugs
mailing list