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: unassignedb...@nondot.org Reporter: prathamesh.kulka...@linaro.org CC: llvm-bugs@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,@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","",@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.
_______________________________________________ llvm-bugs mailing list llvm-bugs@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs