aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWilliam Sengir <william@sengir.com>2022-03-26 15:45:30 -0700
committerAndrew Kelley <andrew@ziglang.org>2022-05-16 13:55:26 -0700
commit6b5c87957b37df89d2ea53f1b39a7e4be0bf1326 (patch)
treeb9b3760736e790a204745a42949b10bb1960570a /src
parentca1ab38d3a037239fc1399c2f9d5b2967acb6757 (diff)
downloadzig-6b5c87957b37df89d2ea53f1b39a7e4be0bf1326.tar.gz
zig-6b5c87957b37df89d2ea53f1b39a7e4be0bf1326.zip
stage2: handle vectors in `Value.intFitsInType`
Diffstat (limited to 'src')
-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,
}
}