[llvm-bugs] [Bug 32124] New: memchr("", 0, 1) optimized incorrectly

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Mar 2 16:34:27 PST 2017


            Bug ID: 32124
           Summary: memchr("", 0, 1) optimized incorrectly
           Product: libraries
           Version: 4.0
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: alex at crichton.co
                CC: llvm-bugs at lists.llvm.org

We've got an upstream rust-lang/rust bug at
https://github.com/rust-lang/rust/issues/40165 which is exhibiting some odd
behavior! I've managed to reduce it to a small snippet of IR which optimizes

@s = internal constant [1 x i8] [i8 0], align 1

define i8* @foo() {
  %0 = tail call i8* @memchr(i8* getelementptr ([1 x i8], [1 x i8]* @s, i64 0,
i64 0), i32 0, i64 1)
  ret i8* %0

declare i8* @memchr(i8*, i32, i64)

When optimized,that entire function optimizes to returning null, but I'd expect
it to return @s itself (as the first byte is zero)

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/20170303/d9ef9540/attachment.html>

More information about the llvm-bugs mailing list