@@ -6641,21 +6641,42 @@ fn airByteSwap(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
66416641 break :result try (try func .binOp (tmp , lsb , ty , .@"or" )).toLocal (func , ty );
66426642 },
66436643 32 = > {
6644- const shl_tmp = try func .binOp (operand , .{ .imm32 = 8 }, ty , .shl );
6645- var lhs = try (try func .binOp (shl_tmp , .{ .imm32 = 0xFF00FF00 }, ty , .@"and" )).toLocal (func , ty );
6646- defer lhs .free (func );
6647- const shr_tmp = try func .binOp (operand , .{ .imm32 = 8 }, ty , .shr );
6648- var rhs = try (try func .binOp (shr_tmp , .{ .imm32 = 0xFF00FF }, ty , .@"and" )).toLocal (func , ty );
6649- defer rhs .free (func );
6650- var tmp_or = try (try func .binOp (lhs , rhs , ty , .@"or" )).toLocal (func , ty );
6651- defer tmp_or .free (func );
6652-
6653- const shl = try func .binOp (tmp_or , .{ .imm32 = 16 }, ty , .shl );
6654- const shr = try func .binOp (tmp_or , .{ .imm32 = 16 }, ty , .shr );
6655- const res = if (int_info .signedness == .signed ) blk : {
6656- break :blk try func .wrapOperand (shr , Type .u16 );
6657- } else shr ;
6658- break :result try (try func .binOp (shl , res , ty , .@"or" )).toLocal (func , ty );
6644+ const shl_tmp = try func .binOp (operand , .{ .imm32 = 8 }, Type .u32 , .shl );
6645+ const lhs = try func .binOp (shl_tmp , .{ .imm32 = 0xFF00FF00 }, Type .u32 , .@"and" );
6646+ const shr_tmp = try func .binOp (operand , .{ .imm32 = 8 }, Type .u32 , .shr );
6647+ const rhs = try func .binOp (shr_tmp , .{ .imm32 = 0x00FF00FF }, Type .u32 , .@"and" );
6648+ var tmp_or = try (try func .binOp (lhs , rhs , Type .u32 , .@"or" )).toLocal (func , Type .u32 );
6649+
6650+ const shl = try func .binOp (tmp_or , .{ .imm32 = 16 }, Type .u32 , .shl );
6651+ const shr = try func .binOp (tmp_or , .{ .imm32 = 16 }, Type .u32 , .shr );
6652+
6653+ tmp_or .free (func );
6654+
6655+ break :result try (try func .binOp (shl , shr , Type .u32 , .@"or" )).toLocal (func , Type .u32 );
6656+ },
6657+ 64 = > {
6658+ const shl_tmp_1 = try func .binOp (operand , .{ .imm64 = 8 }, Type .u64 , .shl );
6659+ const lhs_1 = try func .binOp (shl_tmp_1 , .{ .imm64 = 0xFF00FF00FF00FF00 }, Type .u64 , .@"and" );
6660+
6661+ const shr_tmp_1 = try func .binOp (operand , .{ .imm64 = 8 }, Type .u64 , .shr );
6662+ const rhs_1 = try func .binOp (shr_tmp_1 , .{ .imm64 = 0x00FF00FF00FF00FF }, Type .u64 , .@"and" );
6663+
6664+ var tmp_or_1 = try (try func .binOp (lhs_1 , rhs_1 , Type .u64 , .@"or" )).toLocal (func , Type .u64 );
6665+
6666+ const shl_tmp_2 = try func .binOp (tmp_or_1 , .{ .imm64 = 16 }, Type .u64 , .shl );
6667+ const lhs_2 = try func .binOp (shl_tmp_2 , .{ .imm64 = 0xFFFF0000FFFF0000 }, Type .u64 , .@"and" );
6668+
6669+ const shr_tmp_2 = try func .binOp (tmp_or_1 , .{ .imm64 = 16 }, Type .u64 , .shr );
6670+ tmp_or_1 .free (func );
6671+ const rhs_2 = try func .binOp (shr_tmp_2 , .{ .imm64 = 0x0000FFFF0000FFFF }, Type .u64 , .@"and" );
6672+
6673+ var tmp_or_2 = try (try func .binOp (lhs_2 , rhs_2 , Type .u64 , .@"or" )).toLocal (func , Type .u64 );
6674+
6675+ const shl = try func .binOp (tmp_or_2 , .{ .imm64 = 32 }, Type .u64 , .shl );
6676+ const shr = try func .binOp (tmp_or_2 , .{ .imm64 = 32 }, Type .u64 , .shr );
6677+ tmp_or_2 .free (func );
6678+
6679+ break :result try (try func .binOp (shl , shr , Type .u64 , .@"or" )).toLocal (func , Type .u64 );
66596680 },
66606681 else = > return func .fail ("TODO: @byteSwap for integers with bitsize {d}" , .{int_info .bits }),
66616682 }
0 commit comments