[LLVMbugs] [Bug 15283] New: DAGCombiner: Fold pointless truncate, bitcast, buildvector series

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Feb 15 14:18:14 PST 2013


            Bug ID: 15283
           Summary: DAGCombiner: Fold pointless truncate, bitcast,
                    buildvector series
           Product: tools
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: llc
          Assignee: unassignedbugs at nondot.org
          Reporter: aschwaighofer at apple.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Compile the following code with a recent clang/llvm (r175057/r175054) for NEON
at -O3, something like "clang -arch armv7 -mcpu=swift -isysroot
-O3 -fvectorize":

define TYPE double
#define N 1024

void test_double_compare_to_double() {
  int i; 
    A[i] = (TYPE)(A[i] < B[i]);

Because the vector type of the setcc olt 2xdouble is legalized to 2xi64 (later
a buildvector of 2 x 2 select_cc extract elements) which in turn gets
truncated back to 2xi32 before it is zero extended we generate:
 vmov.i32  d16, #0x1
 vdup.32   d0, d0[0]
 vdup.32   d1, d1[0]
 vmovn.i64 d17, q0 
 vand      d16, d17, d16

If we would fold the truncate, bitcast, buildvector series

    (2xi32) (truncate ((2xi64) bitcast (buildvector i32 a, i32 x, i32 b, i32
    can be folded into a (2xi32) (buildvector i32 a, i32 b)
we would not be generating unnecessary vmovn and vdups.

Part of the optimized vector-legalized selection DAG:

0x7fb7a4030010:f64 = extract_vector_elt 0x7fb7a402fd10, 0x7fb7a402fa10
0x7fb7a4800b10:i32 = select_cc 0x7fb7a402ff10, 0x7fb7a4030010, 0x7fb7a4800110,
                               0x7fb7a402fa10, 0x7fb7a402fe10
0x7fb7a4801510:v4i32 = BUILD_VECTOR 0x7fb7a4800b10, 0x7fb7a4800b10,
                                    0x7fb7a4800610, 0x7fb7a4800610
0x7fb7a4801610:v2i64 = bitcast 0x7fb7a4801510
0x7fb7a4800210:v2i32 = truncate 0x7fb7a4801610
0x7fb7a4800310:v2i32 = BUILD_VECTOR 0x7fb7a4800010, 0x7fb7a4800010
0x7fb7a4800410:v2i32 = and 0x7fb7a4800210, 0x7fb7a4800310

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/20130215/1da3e048/attachment.html>

More information about the llvm-bugs mailing list