From c4d0f97b4c3f85796c4953d6e87b5c0186616bc1 Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Sun, 9 Feb 2020 17:12:43 +0100 Subject: [PATCH] compiler_rt: Fix clzsi2 implementation for Thumb1 The LUT contains the number of bits set, not the number of leading zeros as we're subtracting from the total number of bits in a word. Closes #4415 --- lib/std/special/compiler_rt/clzsi2.zig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/std/special/compiler_rt/clzsi2.zig b/lib/std/special/compiler_rt/clzsi2.zig index 6a69ae75f1..0c9c5d4318 100644 --- a/lib/std/special/compiler_rt/clzsi2.zig +++ b/lib/std/special/compiler_rt/clzsi2.zig @@ -45,8 +45,9 @@ fn __clzsi2_thumb1() callconv(.Naked) void { \\ subs r0, r1, r0 \\ bx lr \\ .p2align 2 + \\ // Number of bits set in the 0-15 range \\ LUT: - \\ .byte 4,3,2,2,1,1,1,1,0,0,0,0,0,0,0,0 + \\ .byte 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4 ); unreachable;