Skip to content

UB when sdiv overflows #655

Description

@katrinafyi

The semantics provided for the SDIV instruction trigger undefined behaviour on INT_MIN / -1.

For example, 010cc19a sdiv x1, x0, x1 gives us something like:

%4 = load i64, ptr %X0, align 8
%5 = load i64, ptr %X1, align 8
// ....
%div.i.i = sdiv i64 %4, %5

Since this overflows a 64-bit int, LLVM semantics specify it is UB.

However, the ARM reference does not raise an exception in such a case; it simply evaluates to INT_MIN.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions