<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 generates wrong asm at AVX2 from instructions trunc + select"
   href="http://llvm.org/bugs/show_bug.cgi?id=17764">17764</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>llc generates wrong asm at AVX2 from instructions trunc + select
          </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>Reproducer for this issue:

; ModuleID = 'a.s'
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 <16 x i16> @foo() {
allocas:
  %mask_1 = alloca <16 x i32>
  %second = alloca <16 x i16>
  %first = alloca <16 x i16>

  store <16 x i32> <i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32
-1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1, i32 -1>, <16 x
i32>* %mask_1
  store <16 x i16> <i16 2, i16 2, i16 2, i16 2, i16 2, i16 2, i16 2, i16 2, i16
2, i16 2, i16 2, i16 2, i16 2, i16 2, i16 2, i16 2>, <16 x i16>* %first
  store <16 x i16> <i16 7, i16 7, i16 7, i16 7, i16 7, i16 7, i16 7, i16 7, i16
7, i16 7, i16 7, i16 7, i16 7, i16 7, i16 7, i16 7>, <16 x i16>* %second

  %first_load = load <16 x i16>* %first
  %second_load = load <16 x i16>* %second
  %mask_2 = load <16 x i32>* %mask_1

  %mask_3 = trunc <16 x i32> %mask_2 to <16 x i1>
  %result = select <16 x i1> %mask_3, <16 x i16> %first_load, <16 x i16>
%second_load

  ret <16 x i16> %result
}

At AVX2 llc generates asm code which ends in instuction:
vpblendvb       %ymm2, %ymm0, %ymm1, %ymm0
where ymm2 = 16 x -1, ymm0 = 16 x 7, and ymm1 = 16 x 2.
This instruction makes ymm0 = 16 x 7 and it is wrong because LLVM instrunction
select <16 x i1> %mask_3, <16 x i16> %first_load, <16 x i16> %second_load
should return first_load which is 16 x 2.

So function returns 16 x 7 instead of 16 x 2</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>