https://bugs.llvm.org/show_bug.cgi?id=38852
Bug ID: 38852
Summary: clang uses adcx rather then adc when "arch=skylake"
Product: new-bugs
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: new bugs
Assignee: unassignedb...@nondot.org
Reporter: ilya.lesok...@gmail.com
CC: llvm-bugs@lists.llvm.org
Created attachment 20847
--> https://bugs.llvm.org/attachment.cgi?id=20847&action=edit
source file
clang uses adcx rather then adc when "arch=skylake"
This seems to be a bad idea for two reasons.
1. adcx is bigger then adc.
2. adcx doesn't update the sign flag which might result in worst code.
Just using -mbmi2, to enable adcx support, doesn't trigger the issue.
See for example:
https://godbolt.org/z/Yt32d9
Source:
#include <stdint.h>
__int128 good(__int128 a, __int128 b) {
b = a + b;
return b < 0 ? a : b;
}
__int128 __attribute__ ((__target__ ("arch=skylake"))) bad(__int128 a, __int128
b) {
b = a + b;
return b < 0 ? a : b;
}
Output:
good(__int128, __int128): # @good(__int128, __int128)
add rdx, rdi
adc rcx, rsi
cmovs rdx, rdi
cmovs rcx, rsi
mov rax, rdx
mov rdx, rcx
ret
bad(__int128, __int128): # @bad(__int128, __int128)
add rdx, rdi
adcx rcx, rsi
test rcx, rcx
cmovs rdx, rdi
cmovs rcx, rsi
mov rax, rdx
mov rdx, rcx
ret
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs