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

            Bug ID: 39854
           Summary: Missing optimization opportunity: overlapping ranges
                    optimization (condition simplification) after inlining
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangb...@nondot.org
          Reporter: nok.ra...@gmail.com
                CC: llvm-bugs@lists.llvm.org, neeil...@live.com,
                    richard-l...@metafoo.co.uk

bool foo(char c)
{
    return c >= '0' && c <= '9';
}

bool bar(char c)
{
    return c != '\0' && foo(c);
}

bool foobar(char c)
{
    return c != '\0' && c >= '0' && c <= '9';
}

All the functions above must result in the same instruction sequence (after
inlining and optimization), but Clang fails to optimize the condition in the
`bar` function. GCC makes the optimization perfectly in all cases (since 4.8.1
version). https://godbolt.org/z/fmXuT5

-- 
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

Reply via email to