[LLVMbugs] [Bug 11682] New: redundant overflow test not eliminated

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sun Jan 1 00:51:30 PST 2012


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

             Bug #: 11682
           Summary: redundant overflow test not eliminated
           Product: libraries
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: nicholas at mxc.ca
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


This testcase is simplified from std::vector::_M_insert_aux, the function
called by push_back that doesn't get inlined. 

declare {i8, i1} @llvm.uadd.with.overflow.i8(i8, i8)

declare void @use(i8, i1)

define void @test(i8 %a) {
  %A = ashr i8 %a, 3  ; [-32..31]
  %B = lshr i8 -1, 3  ; 31
  %uadd = tail call { i8, i1 } @llvm.uadd.with.overflow.i8(i8 %A, i8 %A)
  %sum = extractvalue { i8, i1 } %uadd, 0  ; [-64..62]
  %overflow = extractvalue { i8, i1 } %uadd, 1
; %overflow is true iff %a is negative
  %C = icmp ugt i8 %sum, %B
; %C is true iff %sum is [32..255]
; %C is true iff %A is [16..255]
; %C is true iff %a is [128..255]
; %C is true iff %a is negative
  %D = or i1 %overflow, %C
  call void @use(i8 %sum, i1 %D)
  ret void
}

In this case, %C is equal to %overflow. opt -O2 does not remove the redundant
computation, which would be helpful.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list