zig
zig copied to clipboard
aarch64 llvm 14 regression with vectors: Assertion `mutationIsSane(Rule, Query, Mutation) && "legality mutation invalid for match"' failed
Zig Version: 0.10.0-dev.2876+fbd6c8832
This test case regressed with the update from LLVM 13 to 14:
test "@ctz vectors" {
try testCtzVectors();
comptime try testCtzVectors();
}
fn testCtzVectors() !void {
@setEvalBranchQuota(10_000);
try testOneCtzVector(u8, 64, @splat(64, @as(u8, 0b10100000)), @splat(64, @as(u4, 5)));
try testOneCtzVector(u8, 64, @splat(64, @as(u8, 0b10001010)), @splat(64, @as(u4, 1)));
try testOneCtzVector(u8, 64, @splat(64, @as(u8, 0b00000000)), @splat(64, @as(u4, 8)));
try testOneCtzVector(u16, 64, @splat(64, @as(u16, 0b00000000)), @splat(64, @as(u5, 16)));
}
fn testOneCtzVector(
comptime T: type,
comptime len: u32,
x: @Vector(len, T),
expected: @Vector(len, u32),
) !void {
try expectVectorsEqual(@ctz(T, x), expected);
}
[nix-shell:~/dev/zig/build-llvm14-debug]$ stage1/bin/zig build-obj test.ll -target aarch64-linux-none
zig: /home/andy/Downloads/llvm-project-14/llvm/lib/CodeGen/GlobalISel/LegalizerInfo.cpp:198: llvm::LegalizeActionStep llvm::LegalizeRuleSet::apply(const llvm::LegalityQuery&) const: Assertion `mutationIsSane(Rule, Query, Mutation) && "legality mutation invalid for match"' failed.
Reduced LLVM IR:
define internal fastcc i16 @testOneCtzVector.2() {
Entry:
%0 = call <64 x i16> @llvm.cttz.v64i16(<64 x i16> zeroinitializer, i1 false)
%1 = trunc <64 x i16> %0 to <64 x i5>
store <64 x i5> %1, <64 x i5>* null, align 64
ret i16 0
}
; Function Attrs: nofree nosync nounwind readnone speculatable willreturn
declare <64 x i16> @llvm.cttz.v64i16(<64 x i16>, i1 immarg) #0
attributes #0 = { nofree nosync nounwind readnone speculatable willreturn }
Upstream bug report: https://github.com/llvm/llvm-project/issues/56398
Reopened by 5ca1753ff175379c7847ae82243774c79a75879c