Skip to content

regression: @divExact no longer emits *div exact LLVM IR #19527

@xdBronch

Description

@xdBronch

Zig Version

0.12.0-dev.3518+d2be725e4

Steps to Reproduce and Observed Behavior

export fn div(a: i32) i32 {
    return @divExact(a, 2);
}

https://godbolt.org/z/zEhYTY1h9
because of @divExacts semantics with safety disabled this should be turned into a shift which happened until 0.12 where it emits %1 = sdiv i32 %0, 2 LLVM IR rather than %1 = ashr exact i32 %0, 1

Expected Behavior

zig should emit a right shift to llvm in unsafe modes

Metadata

Metadata

Assignees

No one assigned

    Labels

    backend-llvmThe LLVM backend outputs an LLVM IR Module.bugObserved behavior contradicts documented or intended behaviorregressionIt worked in a previous version of Zig, but stopped working.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions