| ... | ... | @@ -4714,12 +4714,31 @@ fn airByteSwap(self: *Self, inst: Air.Inst.Index) InnerError!WValue { |
| 4714 | 4714 | switch (int_info.bits) { |
| 4715 | 4715 | 16 => { |
| 4716 | 4716 | const shl_res = try self.binOp(operand, .{ .imm32 = 8 }, ty, .shl); |
| 4717 | | const tmp = try self.binOp(operand, .{ .imm32 = 0xFF00 }, ty, .@"and"); |
| 4718 | | const shr_res = try self.binOp(tmp, .{ .imm32 = 8 }, ty, .shr); |
| 4717 | const lhs = try self.binOp(shl_res, .{ .imm32 = 0xFF00 }, ty, .@"and"); |
| 4718 | const shr_res = try self.binOp(operand, .{ .imm32 = 8 }, ty, .shr); |
| 4719 | 4719 | const res = if (int_info.signedness == .signed) blk: { |
| 4720 | 4720 | break :blk try self.wrapOperand(shr_res, Type.u8); |
| 4721 | 4721 | } else shr_res; |
| 4722 | | return self.binOp(shl_res, res, ty, .@"or"); |
| 4722 | return self.binOp(lhs, res, ty, .@"or"); |
| 4723 | }, |
| 4724 | 24 => { |
| 4725 | const msb = try self.wrapOperand(operand, Type.u16); |
| 4726 | const lsb = try self.wrapBinOp(operand, .{ .imm32 = 16 }, Type.u8, .shr); |
| 4727 | |
| 4728 | const shl_res = try self.binOp(msb, .{ .imm32 = 8 }, Type.u16, .shl); |
| 4729 | const lhs = try self.binOp(shl_res, .{ .imm32 = 0xFF0000 }, Type.u16, .@"and"); |
| 4730 | const shr_res = try self.binOp(msb, .{ .imm32 = 8 }, ty, .shr); |
| 4731 | |
| 4732 | const res = if (int_info.signedness == .signed) blk: { |
| 4733 | break :blk try self.wrapOperand(shr_res, Type.u8); |
| 4734 | } else shr_res; |
| 4735 | const lhs_tmp = try self.binOp(lhs, res, ty, .@"or"); |
| 4736 | const lhs_result = try self.binOp(lhs_tmp, .{ .imm32 = 8 }, ty, .shr); |
| 4737 | const rhs_wrap = try self.wrapOperand(msb, Type.u8); |
| 4738 | const rhs_result = try self.binOp(rhs_wrap, .{ .imm32 = 16 }, ty, .shl); |
| 4739 | |
| 4740 | const tmp = try self.binOp(lhs_result, rhs_result, ty, .@"or"); |
| 4741 | return self.binOp(tmp, lsb, ty, .@"or"); |
| 4723 | 4742 | }, |
| 4724 | 4743 | 32 => { |
| 4725 | 4744 | const shl_tmp = try self.binOp(operand, .{ .imm32 = 8 }, ty, .shl); |