[LLVMbugs] [Bug 6230] New: Instruction combiner pass broken for Vectors over 32 elements

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Thu Feb 4 09:36:14 PST 2010


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

           Summary: Instruction combiner pass broken for Vectors over 32
                    elements
           Product: libraries
           Version: trunk
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Transformation Utilities
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: ddneff at hotmail.com
                CC: llvmbugs at cs.uiuc.edu


The instruction combiner is not creating demanded element bit masks correctly
when indexing into large vectors.  It is shifting 1 left by the index, and when
the index is larger than an integer, the mask is not correct.

===========================

InstCombineVectorOps.cpp contains these two lines inside of
InstCombiner::visitExtractElementInst:

APInt DemandedMask(VectorWidth, 1 << IndexVal);
if (Value *V = SimplifyDemandedVectorElts(EI.getOperand(0), 
                                          DemandedMask, UndefElts)) {
...

Shifting 1 left by IndexVal will overflow a 32 bit integer whenever IndexVal is
greater than 31. I believe the correct code should use the APInt to set the
mask along the lines of:

APInt DemandMask(VectorWidth, 0);
DemandMask.set(IndexVal);
if (Value *V = SimplifyDemandedVectorElts(EI.getOperand(0), 
                                          DemandedMask, UndefElts)) {

===============================

A similar problem exists in file InstCombineSimplifyDemanded.cpp in
InstCombiner::SimplifyDemandedVectorElts:

if (DemandedElts == ((1ULL << VWidth) -1))
      return 0;

This at least works until 64 element vectors, but I believe it should be
something like:

if (DemandedElts == APInt(VWidth, 0).set())
      return 0;


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