Extra xor when icmp eq 0 compared to GCC
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
[Godbolt for Clang f8467698d8cdbac6e02cdc1aab643d1ac733ec19](https://godbolt.org/z/Pad7M5WMK)
Flags for GCC and Clang is -O3:
```
extern void fdecl_0 (int, long);
void fdef_9 (int a) {
if (a == 0) {
fdecl_0 (0, 0);
// __builtin_unreachable ();
}
return;
}
```
generates this x86 assembly:
```
fdef_9:
test edi, edi
je .LBB0_2
ret
.LBB0_2:
xor edi, edi
xor esi, esi
jmp fdecl_0@PLT
```
GCC x86 generated assembly:
```
"fdef_9":
test edi, edi
je .L4
ret
.L4:
xor esi, esi
jmp "fdecl_0"
```
GCC removes that extra xor edi, edi instruction.
LLVM assembly:
```
define dso_local void @fdef_9(i32 noundef %a) local_unnamed_addr {
entry:
%cmp = icmp eq i32 %a, 0
br i1 %cmp, label %if.then, label %if.end
if.then:
tail call void @fdecl_0(i32 noundef 0, i64 noundef 0) #2
br label %if.end
if.end:
ret void
}
declare void @fdecl_0(i32 noundef, i64 noundef) local_unnamed_addr #1
```
Contributor guide
Assessment
This issue has not been assessed yet.