aboutsummaryrefslogtreecommitdiff
path: root/src/value.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/value.zig')
-rw-r--r--src/value.zig11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/value.zig b/src/value.zig
index 1e70ad0c54..2ebabe3a27 100644
--- a/src/value.zig
+++ b/src/value.zig
@@ -1671,6 +1671,7 @@ pub const Value = extern union {
}
/// Asserts the value is an integer, and the destination type is ComptimeInt or Int.
+ /// Vectors are also accepted. Vector results are reduced with AND.
pub fn intFitsInType(self: Value, ty: Type, target: Target) bool {
switch (self.tag()) {
.zero,
@@ -1767,6 +1768,16 @@ pub const Value = extern union {
else => unreachable,
},
+ .aggregate => {
+ assert(ty.zigTypeTag() == .Vector);
+ for (self.castTag(.aggregate).?.data) |elem| {
+ if (!elem.intFitsInType(ty.scalarType(), target)) {
+ return false;
+ }
+ }
+ return true;
+ },
+
else => unreachable,
}
}