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: unassignedb...@nondot.org
Reporter: jmuizel...@mozilla.com
CC: llvm-bugs@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs