Skip to content

Not implemented intrinsic @llvm.usub.sat.i32 #896

@zero9178

Description

@zero9178

Given the following C code:

#include <stdint.h>
void test32(uint32_t var1, uint32_t var3, float var0[4]) {
  var0[(var3 - var1) * (var1 >= var3)] = 0;
}

Dynamatic fails to compile the code, hitting an assertion for an LLVM intrinsic being unhandled:

dynamatic> set-dynamatic-path /home/mboeck/dynamatic
dynamatic> set-src test32.c
dynamatic> compile
[INFO] Compiled to LLVM IR
[INFO] Optimized LLVM IR
[INFO] Applied memory dependency analysis to LLVM IR
LLVM ERROR: Not implemented llvm intrinsic function handling!
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: /home/mboeck/dynamatic/build/bin/translate-llvm-to-std /home/mboeck/dynamatic/build/bin/bug56/out/comp/clang.opt.dep.ll -function-name test32 -csource /home/mboeck/dynamatic/build/bin/bug56/test32.c -dynamatic-path /home/mboeck/dynamatic -o /home/mboeck/dynamatic/build/bin/bug56/out/comp/cf.mlir
 #0 0x0000000000606bd8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/mboeck/dynamatic/build/bin/translate-llvm-to-std+0x606bd8)
 #1 0x000000000060485e llvm::sys::RunSignalHandlers() (/home/mboeck/dynamatic/build/bin/translate-llvm-to-std+0x60485e)
 #2 0x00000000006074ed SignalHandler(int) (/home/mboeck/dynamatic/build/bin/translate-llvm-to-std+0x6074ed)
 #3 0x00007f5fbd06f990 __restore_rt (/lib64/libpthread.so.0+0x12990)
 #4 0x00007f5fbc7285af raise (/lib64/libc.so.6+0x4e5af)
 #5 0x00007f5fbc6fbee5 abort (/lib64/libc.so.6+0x21ee5)
 #6 0x00000000005e0388 llvm::report_fatal_error(llvm::Twine const&, bool) (/home/mboeck/dynamatic/build/bin/translate-llvm-to-std+0x5e0388)
 #7 0x00000000005e0196 (/home/mboeck/dynamatic/build/bin/translate-llvm-to-std+0x5e0196)
 #8 0x0000000000588d73 (/home/mboeck/dynamatic/build/bin/translate-llvm-to-std+0x588d73)
 #9 0x0000000000582907 TranslateLLVMToStd::translateFunction(llvm::Function*) (/home/mboeck/dynamatic/build/bin/translate-llvm-to-std+0x582907)
#10 0x0000000000581889 TranslateLLVMToStd::translateLLVMModule() (/home/mboeck/dynamatic/build/bin/translate-llvm-to-std+0x581889)
#11 0x0000000000580153 main (/home/mboeck/dynamatic/build/bin/translate-llvm-to-std+0x580153)
#12 0x00007f5fbc714865 __libc_start_main (/lib64/libc.so.6+0x3a865)
#13 0x000000000057f28e _start (/home/mboeck/dynamatic/build/bin/translate-llvm-to-std+0x57f28e)
/home/mboeck/dynamatic/tools/dynamatic/scripts/compile.sh: line 203: 2269382 Aborted                 (core dumped) $LLVM_TO_STD_TRANSLATION_BIN "$F_CLANG_OPTIMIZED_DEPENDENCY" -function-name "$KERNEL_NAME" -csource "$F_C_SOURCE" -dynamatic-path "$DYNAMATIC_DIR" -o "$F_CF"
[FATAL] Failed to convert to std dialect

The root cause is the @llvm.usub.sat.i32 intrinsic that can be seen in the IR:

; Function Attrs: nounwind uwtable
define dso_local void @test32(i32 noundef %var1, i32 noundef %var3, ptr noundef %var0) #0 {
entry:
  %0 = call i32 @llvm.usub.sat.i32(i32 %var1, i32 %var3)
  %mul = sub i32 0, %0
  %idxprom = zext i32 %mul to i64
  %arrayidx = getelementptr inbounds float, ptr %var0, i64 %idxprom
  store float 0.000000e+00, ptr %arrayidx, align 4, !handshake.name !6
  ret void
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfuzzer-foundBugs found using an automated fuzzer

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions