From 4fa506063373b38bed842af53e6405dec7107534 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 17 Mar 2022 18:04:06 -0700 Subject: [PATCH] Sema: take advantage of checkIntOrVectorAllowComptime --- src/Sema.zig | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/src/Sema.zig b/src/Sema.zig index 7c7eef4818..8fda67b652 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -13489,23 +13489,7 @@ fn zirByteSwap(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg1 = inst_data.src_node }; const operand = sema.resolveInst(inst_data.operand); const operand_ty = sema.typeOf(operand); - - const scalar_ty = if (operand_ty.zigTypeTag() == .Vector) - operand_ty.elemType2() - else - operand_ty; - - switch (operand_ty.zigTypeTag()) { - .Int, .ComptimeInt => {}, - .Vector => { - switch (scalar_ty.zigTypeTag()) { - .Int, .ComptimeInt => {}, - else => return sema.fail(block, ty_src, "expected vector of integer type, found vector of '{}'", .{scalar_ty}), - } - }, - else => return sema.fail(block, ty_src, "expected integer type or vector of integer type, found '{}'", .{operand_ty}), - } - + const scalar_ty = try sema.checkIntOrVectorAllowComptime(block, operand, operand_src); const target = sema.mod.getTarget(); const bits = scalar_ty.intInfo(target).bits; if (bits % 8 != 0) {