https://bugs.llvm.org/show_bug.cgi?id=49594
Bug ID: 49594
Summary: weird codegen: xor eax, eax; test al, al; jne
Product: clang
Version: 11.0
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: -New Bugs
Assignee: unassignedclangb...@nondot.org
Reporter: redbeard0...@gmail.com
CC: htmldevelo...@gmail.com, llvm-bugs@lists.llvm.org,
neeil...@live.com, richard-l...@metafoo.co.uk
https://godbolt.org/z/nsGj55
I noticed this while trying to minrepro another codegen issue, so the input
code is a bit odd. I can't think of any reason to ever generate this
instruction sequence, since the value of al is well known after zeroing it. It
also seems odd that it is doing anything with eax/al at all here, given that it
is clobbering it a few instructions later.
#include <cassert>
#include <cstdint>
template<int V> int f(int = V);
int test1(const char* p) {
switch(auto byte = uint8_t(*p)) {
case 0: return f<0>();
case 1: return f<1>();
case 2: return f<2>();
case 3 ... 10: return f<3>(byte);
case 11 ... 100: return f<4>(byte);
case 111 ... 120: return f<5>(byte);
case 121 ... 130: return f<6>(byte);
case 131 ... 140: return f<7>(byte);
case 141 ... 150: return f<8>(byte);
case 151 ... 160: return f<9>(byte);
case 161 ... 170: return f<10>(byte);
case 171 ... 180: return f<5>(byte);
case 181 ... 190: return f<5>(byte);
case 191 ... 200: return f<5>(byte);
default: assert(false);
}
}
test1(char const*): # @test1(char const*)
push rax
movzx edi, byte ptr [rdi]
xor eax, eax # <-- zeros eax, including al
test al, al # <-- why ?!?!?!?
jne .LBB0_6 # <-- never taken
lea eax, [rdi - 128]
movzx eax, al
jmp qword ptr [8*rax + .LJTI0_0]
...
(snipping rest since the interesting bit is above)
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs