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: unassignedb...@nondot.org
          Reporter: lebedev...@gmail.com
                CC: llvm-bugs@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to