[LLVMbugs] [Bug 21199] New: InstCombine removes an icmp and select

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Oct 7 17:58:10 PDT 2014


http://llvm.org/bugs/show_bug.cgi?id=21199

            Bug ID: 21199
           Summary: InstCombine removes an icmp and select
           Product: libraries
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: hans at chromium.org
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Consider the following IR:


; ModuleID = '<stdin>'
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

declare void @f(i32)

define void @test(i32 %len) {
entry:
  %cmp = icmp ult i32 %len, 8
  %cond = select i1 %cmp, i32 %len, i32 8
  %cmp11 = icmp ult i32 0, %cond
  br i1 %cmp11, label %for.body, label %for.end

for.body:                                         ; preds = %entry, %for.body
  %i.02 = phi i32 [ %inc, %for.body ], [ 0, %entry ]
  tail call void @f(i32 %cond)
  %inc = add i32 %i.02, 1
  %cmp1 = icmp ult i32 %inc, %cond
  br i1 %cmp1, label %for.body, label %for.end

for.end:                                          ; preds = %for.body, %entry
  ret void
}

Passing it through instcombine like so:

$ bin/opt -instcombine < /tmp/c.ll -S -o -

Results in the first comparison and select going missing:

define void @test(i32 %len) {
entry:
  %0 = icmp eq i32 %len, 0
  br i1 %0, label %for.end, label %for.body

for.body:                                         ; preds = %entry, %for.body
  %i.02 = phi i32 [ %inc, %for.body ], [ 0, %entry ]
  tail call void @f(i32 %len)
  %inc = add i32 %i.02, 1
  %cmp1 = icmp ult i32 %inc, %len
  br i1 %cmp1, label %for.body, label %for.end

-- 
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/20141008/b4df9f45/attachment.html>


More information about the llvm-bugs mailing list