aboutsummaryrefslogtreecommitdiff
path: root/src/codegen/llvm.zig
diff options
context:
space:
mode:
authorWilliam Sengir <william@sengir.com>2022-03-26 15:41:44 -0700
committerAndrew Kelley <andrew@ziglang.org>2022-05-16 13:55:26 -0700
commitc2cb9b7cade597bc967620174b31db3895681f96 (patch)
tree133169b0604665eb374abea29774fc8b8d972b25 /src/codegen/llvm.zig
parentc641fb8f05cfbca7484a09496f33bc9c2d95941e (diff)
downloadzig-c2cb9b7cade597bc967620174b31db3895681f96.tar.gz
zig-c2cb9b7cade597bc967620174b31db3895681f96.zip
stage2: vectorize shl_with_overflow in LLVM backend
Diffstat (limited to 'src/codegen/llvm.zig')
-rw-r--r--src/codegen/llvm.zig12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig
index 3e15bd8d9a..3abdccfbe2 100644
--- a/src/codegen/llvm.zig
+++ b/src/codegen/llvm.zig
@@ -5899,26 +5899,30 @@ pub const FuncGen = struct {
const lhs_ty = self.air.typeOf(extra.lhs);
const rhs_ty = self.air.typeOf(extra.rhs);
+ const lhs_scalar_ty = lhs_ty.scalarType();
+ const rhs_scalar_ty = rhs_ty.scalarType();
+
const dest_ty = self.air.typeOfIndex(inst);
const llvm_dest_ty = try self.dg.llvmType(dest_ty);
const tg = self.dg.module.getTarget();
- const casted_rhs = if (rhs_ty.bitSize(tg) < lhs_ty.bitSize(tg))
+ const casted_rhs = if (rhs_scalar_ty.bitSize(tg) < lhs_scalar_ty.bitSize(tg))
self.builder.buildZExt(rhs, try self.dg.llvmType(lhs_ty), "")
else
rhs;
const result = self.builder.buildShl(lhs, casted_rhs, "");
- const reconstructed = if (lhs_ty.isSignedInt())
+ const reconstructed = if (lhs_scalar_ty.isSignedInt())
self.builder.buildAShr(result, casted_rhs, "")
else
self.builder.buildLShr(result, casted_rhs, "");
const overflow_bit = self.builder.buildICmp(.NE, lhs, reconstructed, "");
- const partial = self.builder.buildInsertValue(llvm_dest_ty.getUndef(), result, 0, "");
- return self.builder.buildInsertValue(partial, overflow_bit, 1, "");
+ var ty_buf: Type.Payload.Pointer = undefined;
+ const partial = self.builder.buildInsertValue(llvm_dest_ty.getUndef(), result, llvmFieldIndex(dest_ty, 0, tg, &ty_buf).?, "");
+ return self.builder.buildInsertValue(partial, overflow_bit, llvmFieldIndex(dest_ty, 1, tg, &ty_buf).?, "");
}
fn airAnd(self: *FuncGen, inst: Air.Inst.Index) !?*const llvm.Value {