Skip to content

llvm-mos divmod.cc ported from C++ to C incorrectly #7

@asiekierka

Description

@asiekierka
static __inlinefunc unsigned udiv(unsigned a, unsigned b)
{

This implementation of udiv (and umod, udivmod) will only work on numbers <= 16 bits. As the pi benchmark utilizes division of long (32 bit) numbers, this will not work correctly and lead to a result error.

Using divmod.cc and family directly from llvm-mos-sdk, as opposed to this patched version, allows the pi benchmark to give the correct result; as verified by compiling pi.c directly with llvm-mos-sdk (after patching _putc and _puts calls).

The same applies to mul.c, and potentially other files, I have not checked them all.

I'm getting similar results with merge-sort completing in reasonable time compiled directly with llvm-mos-sdk's standard library on the atari800 emulator, but failing when compiled through oricCompilerBenchmark's suite, but I haven't been able to track those down yet.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions