[llvm-bugs] [Bug 28833] New: strlen (s) == 0 not folded when return type is casted to unsigned
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Aug 3 13:29:24 PDT 2016
https://llvm.org/bugs/show_bug.cgi?id=28833
Bug ID: 28833
Summary: strlen (s) == 0 not folded when return type is casted
to unsigned
Product: libraries
Version: 3.6
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: Transformation Utilities
Assignee: unassignedbugs at nondot.org
Reporter: prathamesh.kulkarni at linaro.org
CC: llvm-bugs at lists.llvm.org
Classification: Unclassified
Hi,
For the following test-case, strlen (s) == 0 is not folded to *s == 0.
_Bool f2(const char *s)
{
unsigned len = __builtin_strlen (s);
return len == 0;
}
Assembly with clang -O2 -S:
.text
.file "test-2.c"
.globl f2
.align 16, 0x90
.type f2, at function
f2: # @f2
.cfi_startproc
# BB#0:
pushq %rax
.Ltmp0:
.cfi_def_cfa_offset 16
callq strlen
testl %eax, %eax
sete %al
popq %rdx
retq
.Ltmp1:
.size f2, .Ltmp1-f2
.cfi_endproc
.ident "Ubuntu clang version 3.6.2-1 (tags/RELEASE_362/final) (based
on LLVM 3.6.2)"
.section ".note.GNU-stack","", at progbits
However if type of len is changed from unsigned to unsigned long,
then the transform takes place.
Is there a reason why the transform is disabled if the return
value (unsigned long) is stored in a smaller type (unsigned) ?
Thanks,
Prathamesh
--
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/20160803/308ee670/attachment.html>
More information about the llvm-bugs
mailing list