[llvm-bugs] [Bug 44976] New: x86 instruction selection asserts on non-power-of-two partial dot product

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Feb 20 10:37:12 PST 2020


https://bugs.llvm.org/show_bug.cgi?id=44976

            Bug ID: 44976
           Summary: x86 instruction selection asserts on non-power-of-two
                    partial dot product
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: andrew.b.adams at gmail.com
                CC: craig.topper at gmail.com, llvm-bugs at lists.llvm.org,
                    llvm-dev at redking.me.uk, spatel+llvm at rotateright.com

Created attachment 23151
  --> https://bugs.llvm.org/attachment.cgi?id=23151&action=edit
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)

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200220/f21e0536/attachment.html>


More information about the llvm-bugs mailing list