Issue 60976
Summary Why GCC can optimize call strcmp , but Clang does not ?
Labels new issue
Assignees
Reporter raidenluikang
    See result of https://godbolt.org/z/114scaYs1
```

#include <string.h>
#include <stdio.h>

 int parse(const char* ptr)
{
    if ( ::strcmp(ptr, "s"))
        return 42;

    if ( ::strcmp(ptr, "ms"))
 return 420;
    
    if  ( ::strcmp(ptr, "ns"))
        return 12;

    if ( ::strcmp(ptr, "us"))
        return 45;

 if ( ::strcmp(ptr, "m"))
        return 0;

    if  (::strcmp(ptr, "h"))
        return 5;

    return -1;
}

int main()
{
    int i = parse("s");

    return i;
}

```

GCC produced assembler code doesn't have call strcmp , but Clang call strcmp every time.

Why clang can't optimize call strcmp with compile time string literal ?

_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to