<html>
<head>
<base href="http://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - DAGCombiner: Fold pointless truncate, bitcast, buildvector series"
href="http://llvm.org/bugs/show_bug.cgi?id=15283">15283</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>DAGCombiner: Fold pointless truncate, bitcast, buildvector series
</td>
</tr>
<tr>
<th>Product</th>
<td>tools
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>llc
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>aschwaighofer@apple.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Compile the following code with a recent clang/llvm (r175057/r175054) for NEON
at -O3, something like "clang -arch armv7 -mcpu=swift -isysroot
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/$IPHONESDK
-O3 -fvectorize":
define TYPE double
#define N 1024
TYPE A[N];
TYPE B[N];
void test_double_compare_to_double() {
int i;
for(i=0;i<N;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
y)))
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</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>