[llvm-bugs] [Bug 43199] New: [InstCombine?] Failure to simplify branch-less logic code

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Sep 2 16:59:05 PDT 2019


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

            Bug ID: 43199
           Summary: [InstCombine?] Failure to simplify branch-less logic
                    code
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: lebedev.ri at gmail.com
                CC: llvm-bugs at lists.llvm.org

https://godbolt.org/z/MVN3j-
https://rise4fun.com/Alive/UCaS

bool is_not_ub_naive(char *Base, unsigned long Offset, char *&Offseted) {
    Offseted = reinterpret_cast<char*>(intptr_t(Base) + Offset);

    return ((Base != nullptr     || Offset == 0) &&
            (Offseted != nullptr || Offset == 0));
}

bool is_not_ub_best(char *Base, unsigned long Offset, char *&Offseted) {
    Offseted = reinterpret_cast<char*>(intptr_t(Base) + Offset);

    return ((Base != nullptr) == (Offseted != nullptr));
}

`is_not_ub_naive()` doesn't get flattened but that isn't the point here.
Even if i flatten it manually down to `@is_not_ub_flat_naive`, it still
doesn't get optimized down to `@is_not_ub_best`...

-- 
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/20190902/68a70345/attachment.html>


More information about the llvm-bugs mailing list