<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 fails at avx2 with trunc and extractelement instructions"
   href="http://llvm.org/bugs/show_bug.cgi?id=17546">17546</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>llc fails at avx2 with trunc and extractelement instructions
          </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.o'
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 void @f_f___un_3C_unf_3E_un_3C_unf_3E_(i32* noalias nocapture %RET, <8 x
i32> %__mask, i64 %BBBB) #0 {

  %QQQ = trunc i64 %BBBB to i32
  %1 = extractelement <8 x i32> %__mask, i32 %QQQ

  store i32 %1, i32* %RET
  ret void
}

attributes #0 = { nounwind readnone }


llc -mattr=avx2 a.s
will result in:


llc: lib/Target/X86/X86ISelLowering.cpp:7635: llvm::SDValue
llvm::X86TargetLowering::LowerEXTRACT_VECTOR_ELT(llvm::SDValue,
llvm::SelectionDAG &) const: Assertion `Idx.getSimpleValueType() == MaskEltVT
&& "Unexpected index in insertelement"' failed.
0  llc             0x0000000001066135 llvm::sys::PrintStackTrace(_IO_FILE*) +
37
1  llc             0x0000000001066583
2  libpthread.so.0 0x00007f2e6ff82000
3  libc.so.6       0x00007f2e6eda1ba5 gsignal + 53
4  libc.so.6       0x00007f2e6eda3358 abort + 328
5  libc.so.6       0x00007f2e6ed9a972
6  libc.so.6       0x00007f2e6ed9aa22
7  llc             0x00000000009bfb96
llvm::X86TargetLowering::LowerEXTRACT_VECTOR_ELT(llvm::SDValue,
llvm::SelectionDAG&) const + 5606
8  llc             0x00000000009d59a3
llvm::X86TargetLowering::LowerOperation(llvm::SDValue, llvm::SelectionDAG&)
const + 1715
9  llc             0x0000000000b40907
10 llc             0x0000000000b3f869 llvm::SelectionDAG::Legalize() + 361
11 llc             0x0000000000b12aa0
llvm::SelectionDAGISel::CodeGenAndEmitDAG() + 2816
12 llc             0x0000000000b11719
llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) + 6249
13 llc             0x0000000000b0f1b7
llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) + 1319
14 llc             0x0000000000c80f1c
llvm::MachineFunctionPass::runOnFunction(llvm::Function&) + 124
15 llc             0x0000000001006683
llvm::FPPassManager::runOnFunction(llvm::Function&) + 355
16 llc             0x00000000010068fb
llvm::FPPassManager::runOnModule(llvm::Module&) + 43
17 llc             0x0000000001006c44
llvm::MPPassManager::runOnModule(llvm::Module&) + 420
18 llc             0x00000000010072eb llvm::PassManagerImpl::run(llvm::Module&)
+ 539
19 llc             0x000000000100745a llvm::PassManager::run(llvm::Module&) +
10
20 llc             0x000000000054dd6c main + 6220
21 libc.so.6       0x00007f2e6ed8da05 __libc_start_main + 245
22 llc             0x000000000054c45d
Stack dump:
0.      Program arguments: llc -mattr=avx2 a.s 
1.      Running pass 'Function Pass Manager' on module 'a.s'.
2.      Running pass 'X86 DAG->DAG Instruction Selection' on function
'@f_f___un_3C_unf_3E_un_3C_unf_3E_'
Aborted (core dumped)


It is a regression between 3.3 version and trunk version.
If we remove trunc instruction everything will pass.</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>