[llvm-bugs] [Bug 49662] New: Miscompilation in middle-end (pointer arithmetic and comparisons)

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Mar 20 10:16:19 PDT 2021


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

            Bug ID: 49662
           Summary: Miscompilation in middle-end (pointer arithmetic and
                    comparisons)
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: maltsevm at gmail.com
                CC: llvm-bugs at lists.llvm.org

Created attachment 24663
  --> https://bugs.llvm.org/attachment.cgi?id=24663&action=edit
Reproducer as C source code

The attached source code is miscompiled with trunk build of Clang:

$ clang -O2 test.c -o test && ./test
failed: distance(i, j) >= 2

(the expected output is "passed")

Git bisect points to the following commit:
https://github.com/llvm/llvm-project/commit/2ad1f5eb1a47275593bd9baf75dcf3e9c3977473
(although it might not be the root cause)

I tried to reduce the test case in such a way that LLVM IR still looked
reasonable to me and got the following result:

$ lli test-reduced.ll
passed
$ opt -indvars -inline -instcombine -jump-threading test-reduced.ll -o test.bc
$ lli test.bc
failed: distance(i, j) >= 2

-- 
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/20210320/dec4e8d5/attachment.html>


More information about the llvm-bugs mailing list