| ... | ... | @@ -5899,26 +5899,30 @@ pub const FuncGen = struct { |
| 5899 | 5899 | |
| 5900 | 5900 | const lhs_ty = self.air.typeOf(extra.lhs); |
| 5901 | 5901 | const rhs_ty = self.air.typeOf(extra.rhs); |
| 5902 | const lhs_scalar_ty = lhs_ty.scalarType(); |
| 5903 | const rhs_scalar_ty = rhs_ty.scalarType(); |
| 5904 | |
| 5902 | 5905 | const dest_ty = self.air.typeOfIndex(inst); |
| 5903 | 5906 | const llvm_dest_ty = try self.dg.llvmType(dest_ty); |
| 5904 | 5907 | |
| 5905 | 5908 | const tg = self.dg.module.getTarget(); |
| 5906 | 5909 | |
| 5907 | | const casted_rhs = if (rhs_ty.bitSize(tg) < lhs_ty.bitSize(tg)) |
| 5910 | const casted_rhs = if (rhs_scalar_ty.bitSize(tg) < lhs_scalar_ty.bitSize(tg)) |
| 5908 | 5911 | self.builder.buildZExt(rhs, try self.dg.llvmType(lhs_ty), "") |
| 5909 | 5912 | else |
| 5910 | 5913 | rhs; |
| 5911 | 5914 | |
| 5912 | 5915 | const result = self.builder.buildShl(lhs, casted_rhs, ""); |
| 5913 | | const reconstructed = if (lhs_ty.isSignedInt()) |
| 5916 | const reconstructed = if (lhs_scalar_ty.isSignedInt()) |
| 5914 | 5917 | self.builder.buildAShr(result, casted_rhs, "") |
| 5915 | 5918 | else |
| 5916 | 5919 | self.builder.buildLShr(result, casted_rhs, ""); |
| 5917 | 5920 | |
| 5918 | 5921 | const overflow_bit = self.builder.buildICmp(.NE, lhs, reconstructed, ""); |
| 5919 | 5922 | |
| 5920 | | const partial = self.builder.buildInsertValue(llvm_dest_ty.getUndef(), result, 0, ""); |
| 5921 | | return self.builder.buildInsertValue(partial, overflow_bit, 1, ""); |
| 5923 | var ty_buf: Type.Payload.Pointer = undefined; |
| 5924 | const partial = self.builder.buildInsertValue(llvm_dest_ty.getUndef(), result, llvmFieldIndex(dest_ty, 0, tg, &ty_buf).?, ""); |
| 5925 | return self.builder.buildInsertValue(partial, overflow_bit, llvmFieldIndex(dest_ty, 1, tg, &ty_buf).?, ""); |
| 5922 | 5926 | } |
| 5923 | 5927 | |
| 5924 | 5928 | fn airAnd(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value { |