[llvm-bugs] [Bug 46244] New: Clang does not propagate range when using uint8_t type while gcc does.
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Jun 8 09:12:13 PDT 2020
https://bugs.llvm.org/show_bug.cgi?id=46244
Bug ID: 46244
Summary: Clang does not propagate range when using uint8_t type
while gcc does.
Product: libraries
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: Scalar Optimizations
Assignee: unassignedbugs at nondot.org
Reporter: jmuizelaar at mozilla.com
CC: llvm-bugs at lists.llvm.org
The following program compiles to:
#include <stdint.h>
#include <stdlib.h>
int foo(uint8_t *a , int q) {
if (q == 5) {
*a = 1;
} else {
*a = 2;
};
switch (*a) {
case 1: return 1;
case 2: return 2;
default: exit(1);
}
}
compiles to:
foo(unsigned char*, int): # @foo(unsigned char*,
int)
pushq %rax
xorl %ecx, %ecx
cmpl $5, %esi
sete %cl
movb $2, %dl
subb %cl, %dl
movb %dl, (%rdi)
movl $2, %eax
subl %ecx, %eax
cmpb $1, %dl
je .LBB0_3
cmpl $2, %eax
jne .LBB0_4
movl $2, %eax
.LBB0_3:
popq %rcx
retq
.LBB0_4:
movl $1, %edi
callq exit
GCC compiles it to:
foo(unsigned char*, int):
cmpl $5, %esi
setne %dl
xorl %eax, %eax
addl $1, %edx
cmpl $5, %esi
setne %al
movb %dl, (%rdi)
addl $1, %eax
ret
Changing the type of `a` from `uint8_t *` to `int *` fixes the problem.
--
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/20200608/5d88004f/attachment.html>
More information about the llvm-bugs
mailing list