<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 --- - llc handles "sext" instruction with constants incorrect"
href="http://llvm.org/bugs/show_bug.cgi?id=18014">18014</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>llc handles "sext" instruction with constants incorrect
</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>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</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>ili.filippov@gmail.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>Created <span class=""><a href="attachment.cgi?id=11580" name="attach_11580" title="Reproducer">attachment 11580</a> <a href="attachment.cgi?id=11580&action=edit" title="Reproducer">[details]</a></span>
Reproducer
Reproducer for this issue:
; ModuleID = 'bad.bc'
target datalayout =
"e-p:64:64:64-S128-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f16:16:16-f32:32:32-f64:64:64-f128:128:128-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
target triple = "x86_64-unknown-linux-gnu"
; Function Attrs: nounwind
define i32 @f_fu(<8 x i32>* %RET, <8 x i32>* %temp) #2 {
allocas:
%temp_1 = load <8 x i32>* %temp
%sext_val = sext <8 x i1> <i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1> to
<8 x i32>
%mask = and <8 x i32> %sext_val, %temp_1
%one_of_mask = extractelement <8 x i32> %mask, i32 3
%new_mask = insertelement <8 x i32> zeroinitializer, i32 %one_of_mask, i32 1
%blend = select <8 x i1> <i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1>, <8
x i32> %new_mask, <8 x i32> zeroinitializer
store <8 x i32> %blend, <8 x i32>* %RET
ret i32 %one_of_mask
}
attributes #2 = { nounwind "target-cpu"="corei7-avx"
"target-features"="+sse,+sse2,+sse3,-sse4a,+ssse3,-popcnt,+cmov,+sse4.1,-sse4.2"
}
to reproduce:
llc bad.ll -mcpu=westmere
clang++ -O2 -m64 test.cpp bad.s -o test.run
./test.run
(File test.cpp is attached)
Here we sext i1 array of ones to i32 array of ones. Then and them with input
array and return third element of the result.
We should have an answer 4 (because it is the value of third element of input
array). But we will have answer 0 and it is incorrect. Possible it happens due
to missing pslld and psrad instructions before "and" instruction in generated
asm.
If we comment last strings:
; %new_mask = insertelement <8 x i32> zeroinitializer, i32 %one_of_mask, i32 1
; %blend = select <8 x i1> <i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1>,
<8 x i32> %new_mask, <8 x i32> zeroinitializer
; store <8 x i32> %blend, <8 x i32>* %RET
We will have right answer and right shifts in generated asm.</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>