[LLVMbugs] [Bug 11948] New: A bug in InstructionSimplify.cpp (icmp with a select operand)

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Feb 8 09:15:52 PST 2012


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

             Bug #: 11948
           Summary: A bug in InstructionSimplify.cpp (icmp with a select
                    operand)
           Product: libraries
           Version: trunk
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: release blocker
          Priority: P
         Component: Global Analyses
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: vslugovsky at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


The following code will cause an assertion:

; ModuleID = '3.cl'

define <2 x i1> @entry(i32 %arg1) nounwind {
entry:
  %tobool40 = icmp ne i32 %arg1, 0
  %cond43 = select i1 %tobool40, <2 x i16> <i16 -5, i16 66>, <2 x i16> <i16 46,
i16 1>
  %cmp45 = icmp ugt <2 x i16> %cond43, <i16 73, i16 21>
  ret <2 x i1> %cmp45
}


The problem is with this optimisation:

  if (match(FCmp, m_Zero()))
    if (Value *V = SimplifyAndInst(Cond, TCmp, TD, TLI, DT, MaxRecurse))
      return V;

here, Cond is i1 and TCmp is <2 x i1>, which results in a nonsense code.

A trivial temporary fix is to return 0 if Cond type does not match TCmp or FCmp
type. A more elaborate fix would require widening Cond (which can be more
expensive than just leaving select and icmp as is).

-- 
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