Skip to content

4 x i8 u/srem causes internal compiler error in nvptx instruction selection #69124

Closed
@abadams

Description

@abadams

The failures below are with commit 546c3d7

I believe this started happening last week (Oct 9-13) . The obvious commit to suspect is cbafb6f

The following .ll:

target datalayout = "e-i64:64-v16:16-v32:32-n16:32:64"
target triple = "nvptx64--"

define void @f(ptr %a, ptr %b, ptr %c) {
entry:
  %t57 = load <4 x i8>, ptr %a, align 1
  %t59 = load <4 x i8>, ptr %b, align 1
  %x = srem <4 x i8> %t57, %t59
  store <4 x i8> %x, ptr %c, align 1
  ret void
}

When compiled with llc with no args, produces the crash dump below:

LLVM ERROR: Cannot select: t21: v4i8,v4i8 = sdivrem t28, t25
  t28: v4i8 = bitcast t36
    t36: i32 = or t117, t83
      t117: i32 = or t115, t116
        t115: i32 = shl t75, Constant:i32<24>
          t75: i32,ch = load<(load (s8) from %ir.a + 3), zext from i8> t0, t88, undef:i64
            t88: i64 = add t18, Constant:i64<3>
              t18: i64,ch = load<(dereferenceable invariant load (s64) from `ptr addrspace(101) null`, addrspace 101)> t0, TargetExternalSymbol:i64'f_param_0', undef:i64
                t1: i64 = TargetExternalSymbol'f_param_0'
                t3: i64 = undef
              t87: i64 = Constant<3>
            t3: i64 = undef
          t106: i32 = Constant<24>
        t116: i32 = shl t73, Constant:i32<16>
          t73: i32,ch = load<(load (s8) from %ir.a + 2), zext from i8> t0, t32, undef:i64
            t32: i64 = add nuw t18, Constant:i64<2>
              t18: i64,ch = load<(dereferenceable invariant load (s64) from `ptr addrspace(101) null`, addrspace 101)> t0, TargetExternalSymbol:i64'f_param_0', undef:i64
                t1: i64 = TargetExternalSymbol'f_param_0'
                t3: i64 = undef
              t31: i64 = Constant<2>
            t3: i64 = undef
          t34: i32 = Constant<16>
      t83: i32 = or t82, t79
        t82: i32 = shl t81, Constant:i32<8>
          t81: i32,ch = load<(load (s8) from %ir.a + 1), zext from i8> t0, t80, undef:i64
            t80: i64 = add nuw t18, Constant:i64<1>
              t18: i64,ch = load<(dereferenceable invariant load (s64) from `ptr addrspace(101) null`, addrspace 101)> t0, TargetExternalSymbol:i64'f_param_0', undef:i64
                t1: i64 = TargetExternalSymbol'f_param_0'
                t3: i64 = undef
              t52: i64 = Constant<1>
            t3: i64 = undef
          t49: i32 = Constant<8>
        t79: i32,ch = load<(load (s8) from %ir.a), zext from i8> t0, t18, undef:i64
          t18: i64,ch = load<(dereferenceable invariant load (s64) from `ptr addrspace(101) null`, addrspace 101)> t0, TargetExternalSymbol:i64'f_param_0', undef:i64
            t1: i64 = TargetExternalSymbol'f_param_0'
            t3: i64 = undef
          t3: i64 = undef
  t25: v4i8 = bitcast t42
    t42: i32 = or t112, t71
      t112: i32 = or t110, t111
        t110: i32 = shl t63, Constant:i32<24>
          t63: i32,ch = load<(load (s8) from %ir.b + 3), zext from i8> t0, t91, undef:i64
            t91: i64 = add t19, Constant:i64<3>
              t19: i64,ch = load<(dereferenceable invariant load (s64) from `ptr addrspace(101) null`, addrspace 101)> t0, TargetExternalSymbol:i64'f_param_1', undef:i64
                t6: i64 = TargetExternalSymbol'f_param_1'
                t3: i64 = undef
              t87: i64 = Constant<3>
            t3: i64 = undef
          t106: i32 = Constant<24>
        t111: i32 = shl t61, Constant:i32<16>
          t61: i32,ch = load<(load (s8) from %ir.b + 2), zext from i8> t0, t39, undef:i64
            t39: i64 = add nuw t19, Constant:i64<2>
              t19: i64,ch = load<(dereferenceable invariant load (s64) from `ptr addrspace(101) null`, addrspace 101)> t0, TargetExternalSymbol:i64'f_param_1', undef:i64
                t6: i64 = TargetExternalSymbol'f_param_1'
                t3: i64 = undef
              t31: i64 = Constant<2>
            t3: i64 = undef
          t34: i32 = Constant<16>
      t71: i32 = or t70, t67
        t70: i32 = shl t69, Constant:i32<8>
          t69: i32,ch = load<(load (s8) from %ir.b + 1), zext from i8> t0, t68, undef:i64
            t68: i64 = add nuw t19, Constant:i64<1>
              t19: i64,ch = load<(dereferenceable invariant load (s64) from `ptr addrspace(101) null`, addrspace 101)> t0, TargetExternalSymbol:i64'f_param_1', undef:i64
                t6: i64 = TargetExternalSymbol'f_param_1'
                t3: i64 = undef
              t52: i64 = Constant<1>
            t3: i64 = undef
          t49: i32 = Constant<8>
        t67: i32,ch = load<(load (s8) from %ir.b), zext from i8> t0, t19, undef:i64
          t19: i64,ch = load<(dereferenceable invariant load (s64) from `ptr addrspace(101) null`, addrspace 101)> t0, TargetExternalSymbol:i64'f_param_1', undef:i64
            t6: i64 = TargetExternalSymbol'f_param_1'
            t3: i64 = undef
          t3: i64 = undef
In function: f
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: /home/abadams/projects/llvm-main/install/bin/llc test2.ll
1.	Running pass 'Function Pass Manager' on module 'test2.ll'.
2.	Running pass 'NVPTX DAG->DAG Pattern Instruction Selection' on function '@f'
 #0 0x00000000026d3fb7 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/abadams/projects/llvm-main/install/bin/llc+0x26d3fb7)
 #1 0x00000000026d18ae llvm::sys::RunSignalHandlers() (/home/abadams/projects/llvm-main/install/bin/llc+0x26d18ae)
 #2 0x00000000026d47da SignalHandler(int) Signals.cpp:0:0
 #3 0x00007f04f843d520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007f04f84919fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #5 0x00007f04f84919fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10
 #6 0x00007f04f84919fc pthread_kill ./nptl/pthread_kill.c:89:10
 #7 0x00007f04f843d476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
 #8 0x00007f04f84237f3 abort ./stdlib/abort.c:81:7
 #9 0x00000000026419ec llvm::report_fatal_error(llvm::Twine const&, bool) (/home/abadams/projects/llvm-main/install/bin/llc+0x26419ec)
#10 0x00000000024cc48a llvm::SelectionDAGISel::CannotYetSelect(llvm::SDNode*) (/home/abadams/projects/llvm-main/install/bin/llc+0x24cc48a)
#11 0x00000000024cad3e llvm::SelectionDAGISel::SelectCodeCommon(llvm::SDNode*, unsigned char const*, unsigned int) (/home/abadams/projects/llvm-main/install/bin/llc+0x24cad3e)
#12 0x00000000024bf575 llvm::SelectionDAGISel::DoInstructionSelection() (/home/abadams/projects/llvm-main/install/bin/llc+0x24bf575)
#13 0x00000000024be06e llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/home/abadams/projects/llvm-main/install/bin/llc+0x24be06e)
#14 0x00000000024bb88e llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/home/abadams/projects/llvm-main/install/bin/llc+0x24bb88e)
#15 0x00000000024b820b llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/home/abadams/projects/llvm-main/install/bin/llc+0x24b820b)
#16 0x0000000001a2b0a8 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/home/abadams/projects/llvm-main/install/bin/llc+0x1a2b0a8)
#17 0x0000000001f763bc llvm::FPPassManager::runOnFunction(llvm::Function&) (/home/abadams/projects/llvm-main/install/bin/llc+0x1f763bc)
#18 0x0000000001f7dbc1 llvm::FPPassManager::runOnModule(llvm::Module&) (/home/abadams/projects/llvm-main/install/bin/llc+0x1f7dbc1)
#19 0x0000000001f76cd8 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/home/abadams/projects/llvm-main/install/bin/llc+0x1f76cd8)
#20 0x000000000070fbf4 compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0
#21 0x000000000070dbcd main (/home/abadams/projects/llvm-main/install/bin/llc+0x70dbcd)
#22 0x00007f04f8424d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#23 0x00007f04f8424e40 call_init ./csu/../csu/libc-start.c:128:20
#24 0x00007f04f8424e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#25 0x000000000070ab15 _start (/home/abadams/projects/llvm-main/install/bin/llc+0x70ab15)
Aborted (core dumped)

Trying out some variants, I found that:

  • Changing it to <2 x i8> produces no error.
  • Changing it to <4 x i16> also produces no error.
  • Changing the srem to a urem produces the same error (but with udivrem instead of sdivrem).
  • Increasing the vector size above 4 produces the same error.
  • Changing it to <3 x i8> produces a different error:
LLVM ERROR: Cannot select: t35: v2i16 = scalar_to_vector t115
  t115: i16 = or t114, t111
    t114: i16 = shl t113, Constant:i32<8>
      t113: i16,ch = load<(load (s8) from %ir.b + 1), zext from i8> t0, t112, undef:i64
        t112: i64 = add nuw t30, Constant:i64<1>
          t30: i64,ch = load<(dereferenceable invariant load (s64) from `ptr addrspace(101) null`, addrspace 101)> t0, TargetExternalSymbol:i64'f_param_1', undef:i64
            t6: i64 = TargetExternalSymbol'f_param_1'
            t3: i64 = undef
          t23: i64 = Constant<1>
        t3: i64 = undef
      t86: i32 = Constant<8>
    t111: i16,ch = load<(load (s8) from %ir.b), zext from i8> t0, t30, undef:i64
      t30: i64,ch = load<(dereferenceable invariant load (s64) from `ptr addrspace(101) null`, addrspace 101)> t0, TargetExternalSymbol:i64'f_param_1', undef:i64
        t6: i64 = TargetExternalSymbol'f_param_1'
        t3: i64 = undef
      t3: i64 = undef
In function: f
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: /home/abadams/projects/llvm-main/install/bin/llc test2.ll
1.	Running pass 'Function Pass Manager' on module 'test2.ll'.
2.	Running pass 'NVPTX DAG->DAG Pattern Instruction Selection' on function '@f'
 #0 0x00000000026d3fb7 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/abadams/projects/llvm-main/install/bin/llc+0x26d3fb7)
 #1 0x00000000026d18ae llvm::sys::RunSignalHandlers() (/home/abadams/projects/llvm-main/install/bin/llc+0x26d18ae)
 #2 0x00000000026d47da SignalHandler(int) Signals.cpp:0:0
 #3 0x00007f43ccf4b520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007f43ccf9f9fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #5 0x00007f43ccf9f9fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10
 #6 0x00007f43ccf9f9fc pthread_kill ./nptl/pthread_kill.c:89:10
 #7 0x00007f43ccf4b476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
 #8 0x00007f43ccf317f3 abort ./stdlib/abort.c:81:7
 #9 0x00000000026419ec llvm::report_fatal_error(llvm::Twine const&, bool) (/home/abadams/projects/llvm-main/install/bin/llc+0x26419ec)
#10 0x00000000024cc48a llvm::SelectionDAGISel::CannotYetSelect(llvm::SDNode*) (/home/abadams/projects/llvm-main/install/bin/llc+0x24cc48a)
#11 0x00000000024cad3e llvm::SelectionDAGISel::SelectCodeCommon(llvm::SDNode*, unsigned char const*, unsigned int) (/home/abadams/projects/llvm-main/install/bin/llc+0x24cad3e)
#12 0x00000000024bf575 llvm::SelectionDAGISel::DoInstructionSelection() (/home/abadams/projects/llvm-main/install/bin/llc+0x24bf575)
#13 0x00000000024be06e llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/home/abadams/projects/llvm-main/install/bin/llc+0x24be06e)
#14 0x00000000024bb88e llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/home/abadams/projects/llvm-main/install/bin/llc+0x24bb88e)
#15 0x00000000024b820b llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/home/abadams/projects/llvm-main/install/bin/llc+0x24b820b)
#16 0x0000000001a2b0a8 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/home/abadams/projects/llvm-main/install/bin/llc+0x1a2b0a8)
#17 0x0000000001f763bc llvm::FPPassManager::runOnFunction(llvm::Function&) (/home/abadams/projects/llvm-main/install/bin/llc+0x1f763bc)
#18 0x0000000001f7dbc1 llvm::FPPassManager::runOnModule(llvm::Module&) (/home/abadams/projects/llvm-main/install/bin/llc+0x1f7dbc1)
#19 0x0000000001f76cd8 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/home/abadams/projects/llvm-main/install/bin/llc+0x1f76cd8)
#20 0x000000000070fbf4 compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0
#21 0x000000000070dbcd main (/home/abadams/projects/llvm-main/install/bin/llc+0x70dbcd)
#22 0x00007f43ccf32d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#23 0x00007f43ccf32e40 call_init ./csu/../csu/libc-start.c:128:20
#24 0x00007f43ccf32e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#25 0x000000000070ab15 _start (/home/abadams/projects/llvm-main/install/bin/llc+0x70ab15)
Aborted (core dumped)

Increasing the alignment on the loads and store to 4 produces a simpler error:

LLVM ERROR: Cannot select: t21: v4i8,v4i8 = udivrem t12, t13
  t12: v4i8,ch = load<(load (s32) from %ir.a)> t0, t18, undef:i64
    t18: i64,ch = load<(dereferenceable invariant load (s64) from `ptr addrspace(101) null`, addrspace 101)> t0, TargetExternalSymbol:i64'f_param_0', undef:i64
      t1: i64 = TargetExternalSymbol'f_param_0'
      t3: i64 = undef
    t3: i64 = undef
  t13: v4i8,ch = load<(load (s32) from %ir.b)> t0, t19, undef:i64
    t19: i64,ch = load<(dereferenceable invariant load (s64) from `ptr addrspace(101) null`, addrspace 101)> t0, TargetExternalSymbol:i64'f_param_1', undef:i64
      t6: i64 = TargetExternalSymbol'f_param_1'
      t3: i64 = undef
    t3: i64 = undef
In function: f
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: /home/abadams/projects/llvm-main/install/bin/llc test2.ll
1.	Running pass 'Function Pass Manager' on module 'test2.ll'.
2.	Running pass 'NVPTX DAG->DAG Pattern Instruction Selection' on function '@f'
 #0 0x00000000026d3fb7 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/abadams/projects/llvm-main/install/bin/llc+0x26d3fb7)
 #1 0x00000000026d18ae llvm::sys::RunSignalHandlers() (/home/abadams/projects/llvm-main/install/bin/llc+0x26d18ae)
 #2 0x00000000026d47da SignalHandler(int) Signals.cpp:0:0
 #3 0x00007f5eabd6c520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007f5eabdc09fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #5 0x00007f5eabdc09fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10
 #6 0x00007f5eabdc09fc pthread_kill ./nptl/pthread_kill.c:89:10
 #7 0x00007f5eabd6c476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
 #8 0x00007f5eabd527f3 abort ./stdlib/abort.c:81:7
 #9 0x00000000026419ec llvm::report_fatal_error(llvm::Twine const&, bool) (/home/abadams/projects/llvm-main/install/bin/llc+0x26419ec)
#10 0x00000000024cc48a llvm::SelectionDAGISel::CannotYetSelect(llvm::SDNode*) (/home/abadams/projects/llvm-main/install/bin/llc+0x24cc48a)
#11 0x00000000024cad3e llvm::SelectionDAGISel::SelectCodeCommon(llvm::SDNode*, unsigned char const*, unsigned int) (/home/abadams/projects/llvm-main/install/bin/llc+0x24cad3e)
#12 0x00000000024bf575 llvm::SelectionDAGISel::DoInstructionSelection() (/home/abadams/projects/llvm-main/install/bin/llc+0x24bf575)
#13 0x00000000024be06e llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/home/abadams/projects/llvm-main/install/bin/llc+0x24be06e)
#14 0x00000000024bb88e llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/home/abadams/projects/llvm-main/install/bin/llc+0x24bb88e)
#15 0x00000000024b820b llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/home/abadams/projects/llvm-main/install/bin/llc+0x24b820b)
#16 0x0000000001a2b0a8 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/home/abadams/projects/llvm-main/install/bin/llc+0x1a2b0a8)
#17 0x0000000001f763bc llvm::FPPassManager::runOnFunction(llvm::Function&) (/home/abadams/projects/llvm-main/install/bin/llc+0x1f763bc)
#18 0x0000000001f7dbc1 llvm::FPPassManager::runOnModule(llvm::Module&) (/home/abadams/projects/llvm-main/install/bin/llc+0x1f7dbc1)
#19 0x0000000001f76cd8 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/home/abadams/projects/llvm-main/install/bin/llc+0x1f76cd8)
#20 0x000000000070fbf4 compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0
#21 0x000000000070dbcd main (/home/abadams/projects/llvm-main/install/bin/llc+0x70dbcd)
#22 0x00007f5eabd53d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#23 0x00007f5eabd53e40 call_init ./csu/../csu/libc-start.c:128:20
#24 0x00007f5eabd53e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#25 0x000000000070ab15 _start (/home/abadams/projects/llvm-main/install/bin/llc+0x70ab15)
Aborted (core dumped)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions