[llvm-bugs] [Bug 51286] New: Regression: Missed fold for x * 0

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Jul 30 18:24:50 PDT 2021


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

            Bug ID: 51286
           Summary: Regression: Missed fold for x * 0
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: llvm at rifkin.dev
                CC: llvm-bugs at lists.llvm.org

Clang trunk is not generating optimal code for a (very poor) multiplication
routine https://godbolt.org/z/GrjMhsTcv.

int mul(int x, int y) {
    int p = 0;
    while(x--) p += y;
    return p;
}

Should compile to:

mul(int, int):
        mov     eax, edi
        imul    eax, esi
        ret

And it does in clang 12 but not in clang trunk.

If I'm not mistaken it appears a select i1 (icmp eq i32 %x, 0), i32 0, i32 (mul
i32 %x, %y) -> mul i32 %x, %y fold is not firing.

-- 
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/20210731/5de64777/attachment.html>


More information about the llvm-bugs mailing list