https://bugs.llvm.org/show_bug.cgi?id=49596

            Bug ID: 49596
           Summary: Optimize strlen(foo) > x to strnlen(foo, x+1) > x
           Product: libraries
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Transformation Utilities
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]

A lot of code has comparisons of the form:

  strlen(foo) > x

This is inefficient, because always we read every byte of the string, even
after we already know it's longer than x. This could be optimized to:

  strnlen(foo, x + 1) > x

But Clang doesn't do this. (Neither does GCC.) I'd like to take a shot at
implementing this, but I wanted to make sure I'm not missing some obvious
reason it wouldn't work.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to