zig/test/behavior/bugs/10147.zig
LemonBoy 952d865bd2 stage1: Fix caching of LLVM builtin fns
The cache entry must take into account the fact some functions operate on scalar types and some other on vectors of scalar types.

Fixes #10147
2021-11-16 16:35:56 -05:00

13 lines
463 B
Zig

const std = @import("std");
test "uses correct LLVM builtin" {
var x: u32 = 0x1;
var y: @Vector(4, u32) = [_]u32{ 0x1, 0x1, 0x1, 0x1 };
// The stage1 compiler used to call the same builtin function for both
// scalar and vector inputs, causing the LLVM module verification to fail.
var a = @clz(u32, x);
var b = @clz(u32, y);
try std.testing.expectEqual(@as(u6, 31), a);
try std.testing.expectEqual([_]u6{ 31, 31, 31, 31 }, b);
}