<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </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 - x86 instruction selection asserts on non-power-of-two partial dot product"
   href="https://bugs.llvm.org/show_bug.cgi?id=44976">44976</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>x86 instruction selection asserts on non-power-of-two partial dot product
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </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>Backend: X86
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>andrew.b.adams@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>craig.topper@gmail.com, llvm-bugs@lists.llvm.org, llvm-dev@redking.me.uk, spatel+llvm@rotateright.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=23151" name="attach_23151" title="ll that demonstrates assert fail">attachment 23151</a> <a href="attachment.cgi?id=23151&action=edit" title="ll that demonstrates assert fail">[details]</a></span>
ll that demonstrates assert fail

On a plain x86-64 target (i.e. no sse4 or avx enabled), doing a partial dot
product of two <12 x i16> vectors down to a <3 x i32> result using adds, muls,
and shuffles fails an assertion inside the x86 backend. Run llc with no args on
the attached ll to repro. If I change the input vectors to be size 8 (and the
output to be size 2) then there's no problem, so might be due to a
non-power-of-two vector size. Could also be pmaddwd related, as that's a useful
instruction for this operation. The input is:

define <3 x i32> @f_29(<12 x i16> %a, <12 x i16> %b) {
entry:
  %a32 = zext <12 x i16> %a to <12 x i32>
  %b32 = zext <12 x i16> %b to <12 x i32>
  %prod12 = mul nuw <12 x i32> %a32, %b32
  %odd12 = shufflevector <12 x i32> %prod12, <12 x i32> undef, <6 x i32> <i32
1, i32 3, i32 5, i32 7, i32 9, i32 11>
  %even12 = shufflevector <12 x i32> %prod12, <12 x i32> undef, <6 x i32> <i32
0, i32 2, i32 4, i32 6, i32 8, i32 10>
  %prod6 = add <6 x i32> %odd12, %even12
  %odd6 = shufflevector <6 x i32> %prod6, <6 x i32> undef, <3 x i32> <i32 1,
i32 3, i32 5>
  %even6 = shufflevector <6 x i32> %prod6, <6 x i32> undef, <3 x i32> <i32 0,
i32 2, i32 4>  
  %result = add <3 x i32> %odd6, %even6
  ret <3 x i32> %result
}

and the stack trace is:

llc: /home/abadams/projects/llvm-trunk/llvm/include/llvm/Support/Casting.h:105:
static bool llvm::isa_impl_cl<llvm::IntegerType, const llvm::Type
*>::doit(const From *) [To = llvm::IntegerType, From = const llvm::Type *]:
Assertion `Val && "isa<> used on a null pointer"' failed.
Stack dump:
0.      Program arguments: /home/abadams/projects/llvm-trunk/build/bin/llc
bugpoint-reduced-simplified.ll 
1.      Running pass 'Function Pass Manager' on module
'bugpoint-reduced-simplified.ll'.
2.      Running pass 'X86 DAG->DAG Instruction Selection' on function '@f_29'
 #0 0x0000000002f0e234 PrintStackTraceSignalHandler(void*)
(/home/abadams/projects/llvm-trunk/build/bin/llc+0x2f0e234)
 #1 0x0000000002f0bd0e llvm::sys::RunSignalHandlers()
(/home/abadams/projects/llvm-trunk/build/bin/llc+0x2f0bd0e)
 #2 0x0000000002f0e64c SignalHandler(int)
(/home/abadams/projects/llvm-trunk/build/bin/llc+0x2f0e64c)
 #3 0x00007f0fd75ee890 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x12890)
 #4 0x00007f0fd62c1e97 raise
/build/glibc-OTsEL5/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
 #5 0x00007f0fd62c3801 abort /build/glibc-OTsEL5/glibc-2.27/stdlib/abort.c:81:0
 #6 0x00007f0fd62b339a __assert_fail_base
/build/glibc-OTsEL5/glibc-2.27/assert/assert.c:89:0
 #7 0x00007f0fd62b3412 (/lib/x86_64-linux-gnu/libc.so.6+0x30412)
 #8 0x00000000026536b6 llvm::EVT::getExtendedSizeInBits() const
(/home/abadams/projects/llvm-trunk/build/bin/llc+0x26536b6)
 #9 0x0000000002d11276 llvm::SelectionDAG::getNode(unsigned int, llvm::SDLoc
const&, llvm::EVT, llvm::SDValue, llvm::SDNodeFlags)
(/home/abadams/projects/llvm-trunk/build/bin/llc+0x2d11276)
#10 0x0000000002d1be15 llvm::SelectionDAG::getBitcast(llvm::EVT, llvm::SDValue)
(/home/abadams/projects/llvm-trunk/build/bin/llc+0x2d1be15)
#11 0x000000000196c7a4 combineMul(llvm::SDNode*, llvm::SelectionDAG&,
llvm::TargetLowering::DAGCombinerInfo&, llvm::X86Subtarget const&)
(/home/abadams/projects/llvm-trunk/build/bin/llc+0x196c7a4)
#12 0x00000000019408b9
llvm::X86TargetLowering::PerformDAGCombine(llvm::SDNode*,
llvm::TargetLowering::DAGCombinerInfo&) const
(/home/abadams/projects/llvm-trunk/build/bin/llc+0x19408b9)
#13 0x0000000002bb8914 (anonymous
namespace)::DAGCombiner::combine(llvm::SDNode*)
(/home/abadams/projects/llvm-trunk/build/bin/llc+0x2bb8914)
#14 0x0000000002bb5e14 llvm::SelectionDAG::Combine(llvm::CombineLevel,
llvm::AAResults*, llvm::CodeGenOpt::Level)
(/home/abadams/projects/llvm-trunk/build/bin/llc+0x2bb5e14)
#15 0x0000000002d61c99 llvm::SelectionDAGISel::CodeGenAndEmitDAG()
(/home/abadams/projects/llvm-trunk/build/bin/llc+0x2d61c99)
#16 0x0000000002d60bf4
llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&)
(/home/abadams/projects/llvm-trunk/build/bin/llc+0x2d60bf4)
#17 0x0000000002d5d406
llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&)
(/home/abadams/projects/llvm-trunk/build/bin/llc+0x2d5d406)
#18 0x0000000001a401b6 (anonymous
namespace)::X86DAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&)
(/home/abadams/projects/llvm-trunk/build/bin/llc+0x1a401b6)
#19 0x00000000023d523a
llvm::MachineFunctionPass::runOnFunction(llvm::Function&)
(/home/abadams/projects/llvm-trunk/build/bin/llc+0x23d523a)
#20 0x00000000027b5d3e llvm::FPPassManager::runOnFunction(llvm::Function&)
(/home/abadams/projects/llvm-trunk/build/bin/llc+0x27b5d3e)
#21 0x00000000027b60b3 llvm::FPPassManager::runOnModule(llvm::Module&)
(/home/abadams/projects/llvm-trunk/build/bin/llc+0x27b60b3)
#22 0x00000000027b66ff llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/home/abadams/projects/llvm-trunk/build/bin/llc+0x27b66ff)
#23 0x000000000179e117 compileModule(char**, llvm::LLVMContext&)
(/home/abadams/projects/llvm-trunk/build/bin/llc+0x179e117)
#24 0x000000000179b6ed main
(/home/abadams/projects/llvm-trunk/build/bin/llc+0x179b6ed)
#25 0x00007f0fd62a4b97 __libc_start_main
/build/glibc-OTsEL5/glibc-2.27/csu/../csu/libc-start.c:344:0
#26 0x000000000179902a _start
(/home/abadams/projects/llvm-trunk/build/bin/llc+0x179902a)</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>