[LLVMbugs] [Bug 13837] New: Creating vector from casted operations is not vectorized

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Sep 13 11:17:55 PDT 2012


             Bug #: 13837
           Summary: Creating vector from casted operations is not
           Product: new-bugs
           Version: trunk
          Platform: PC
        OS/Version: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: weimingz at codeaurora.org
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

When a vector is created by casting each element from another vector, it fails
to generate vectorized cast. For example:

int4 conv4i(float4 in)
  int4 out={ (int)in.x, (int)in.y, (int)in.z, (int)in.w};
  return out;
where int4 and float4 are vector data type.

LLVM generates scalar casts. For example, on ARM, the code look like:
    vmov    d1, r2, r3
    vmov    d0, r0, r1
    vcvt.s32.f32    s7, s3
    vcvt.s32.f32    s6, s2
    vcvt.s32.f32    s5, s1
    vcvt.s32.f32    s4, s0
    vmov    r0, r1, d2
    vmov    r2, r3, d3
    bx    lr
instead of:
    vmov    d17, r2, r3
    vmov    d16, r0, r1
    vcvt.s32.f32    q8, q8
    vmov    r0, r1, d16
    vmov    r2, r3, d17
    bx    lr

The reason is that, in DAGCombine, when visit BUILD_VECTOR, it fails to check
if all its elements come from the same cast. If it is, then it should do
BUILD_VECOTR first, followed by casting.

Take the above C code for example:
before DAGCombine, the DAG look like
                    <float x 4>
      /             |        |          \
 extract_0    extract_1  extract_2  extract_3
     |              |        |          |
   fp2int          fp2int  fp2int      fp2int
     \              |        |          /
                 BUILD_VECTOR(int x 4)

It should be folded into:
                   <float x 4>
      /             |        |          \
 extract_0    extract_1  extract_2  extract_3
      \              |        |          /  
               BUILD_VECTOR(float x 4)

Later, the extraction and BUILD_VECTOR will be cancelled each other.

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