Skip to content

Commit bd48fd6

Browse files
committed
intrinsic-test: remove redundant bit pattern consts
This isn't strictly optimal as it means that the 5/6/7 bit cases are less likely to be tested with values at the edges (e.g. `0x7e` for 7 bits).
1 parent 1432d8f commit bd48fd6

1 file changed

Lines changed: 2 additions & 26 deletions

File tree

crates/intrinsic-test/src/common/values.rs

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -110,39 +110,15 @@ pub fn test_values_array_length(ty: &IntrinsicType) -> u32 {
110110
pub fn bit_pattern_for_test_values_array(bits: u32, index: u32) -> u64 {
111111
let index = index as usize;
112112
match bits {
113-
1 => BIT_PATTERNS_8[index % 2].into(),
114-
2 => BIT_PATTERNS_8[index % 4].into(),
115-
3 => BIT_PATTERNS_8[index % 8].into(),
116-
4 => BIT_PATTERNS_8[index % 16].into(),
117-
5 => BIT_PATTERNS_5[index % BIT_PATTERNS_5.len()].into(),
118-
6 => BIT_PATTERNS_6[index % BIT_PATTERNS_6.len()].into(),
119-
7 => BIT_PATTERNS_7[index % BIT_PATTERNS_7.len()].into(),
120-
8 => BIT_PATTERNS_8[index % BIT_PATTERNS_8.len()].into(),
113+
bits @ (1 | 2 | 3 | 4 | 5 | 6 | 7 | 8) => BIT_PATTERNS_8[index % (1 << bits)].into(),
121114
16 => BIT_PATTERNS_16[index % BIT_PATTERNS_16.len()].into(),
122115
32 => BIT_PATTERNS_32[index % BIT_PATTERNS_32.len()].into(),
123116
64 => BIT_PATTERNS_64[index % BIT_PATTERNS_64.len()],
124117
_ => unimplemented!("bit_pattern_for_test_values_array(bits: {bits}, ..)"),
125118
}
126119
}
127120

128-
pub const BIT_PATTERNS_5: &[u8] = &[
129-
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
130-
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x019, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e,
131-
0x1f,
132-
];
133-
134-
pub const BIT_PATTERNS_6: &[u8] = &[
135-
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
136-
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x039, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e,
137-
0x3f,
138-
];
139-
140-
pub const BIT_PATTERNS_7: &[u8] = &[
141-
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
142-
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x079, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e,
143-
0x7f,
144-
];
145-
121+
// Contains every possible 8-bit value in order
146122
pub const BIT_PATTERNS_8: &[u8] = &[
147123
0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0x10, 0x11,
148124
0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21,

0 commit comments

Comments
 (0)