Skip to content

Commit 1adeec5

Browse files
committed
More fixes
1 parent 10ee71f commit 1adeec5

File tree

5 files changed

+38
-15
lines changed

5 files changed

+38
-15
lines changed

crates/core_arch/src/aarch64/neon/generated.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4455,7 +4455,7 @@ pub unsafe fn vnegq_s64(a: int64x2_t) -> int64x2_t {
44554455
#[target_feature(enable = "neon")]
44564456
#[cfg_attr(test, assert_instr(neg))]
44574457
pub unsafe fn vnegd_s64(a: i64) -> i64 {
4458-
-a
4458+
a.wrapping_neg()
44594459
}
44604460

44614461
/// Negate
@@ -7512,31 +7512,31 @@ pub unsafe fn vsubq_f64(a: float64x2_t, b: float64x2_t) -> float64x2_t {
75127512
#[target_feature(enable = "neon")]
75137513
#[cfg_attr(test, assert_instr(nop))]
75147514
pub unsafe fn vsubd_s64(a: i64, b: i64) -> i64 {
7515-
a - b
7515+
a.wrapping_sub(b)
75167516
}
75177517

75187518
/// Subtract
75197519
#[inline]
75207520
#[target_feature(enable = "neon")]
75217521
#[cfg_attr(test, assert_instr(nop))]
75227522
pub unsafe fn vsubd_u64(a: u64, b: u64) -> u64 {
7523-
a - b
7523+
a.wrapping_sub(b)
75247524
}
75257525

75267526
/// Add
75277527
#[inline]
75287528
#[target_feature(enable = "neon")]
75297529
#[cfg_attr(test, assert_instr(nop))]
75307530
pub unsafe fn vaddd_s64(a: i64, b: i64) -> i64 {
7531-
a + b
7531+
a.wrapping_add(b)
75327532
}
75337533

75347534
/// Add
75357535
#[inline]
75367536
#[target_feature(enable = "neon")]
75377537
#[cfg_attr(test, assert_instr(nop))]
75387538
pub unsafe fn vaddd_u64(a: u64, b: u64) -> u64 {
7539-
a + b
7539+
a.wrapping_add(b)
75407540
}
75417541

75427542
/// Floating-point add across vector
@@ -11536,7 +11536,7 @@ pub unsafe fn vrshrn_high_n_u64<const N: i32>(a: uint32x2_t, b: uint64x2_t) -> u
1153611536
pub unsafe fn vrsrad_n_s64<const N: i32>(a: i64, b: i64) -> i64 {
1153711537
static_assert!(N : i32 where N >= 1 && N <= 64);
1153811538
let b: i64 = vrshrd_n_s64::<N>(b);
11539-
a + b
11539+
a.wrapping_add(b)
1154011540
}
1154111541

1154211542
/// Ungisned rounding shift right and accumulate.
@@ -11547,7 +11547,7 @@ pub unsafe fn vrsrad_n_s64<const N: i32>(a: i64, b: i64) -> i64 {
1154711547
pub unsafe fn vrsrad_n_u64<const N: i32>(a: u64, b: u64) -> u64 {
1154811548
static_assert!(N : i32 where N >= 1 && N <= 64);
1154911549
let b: u64 = vrshrd_n_u64::<N>(b);
11550-
a + b
11550+
a.wrapping_add(b)
1155111551
}
1155211552

1155311553
/// Rounding subtract returning high narrow

crates/core_arch/src/aarch64/neon/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2814,7 +2814,7 @@ pub unsafe fn vshrd_n_u64<const N: i32>(a: u64) -> u64 {
28142814
#[rustc_legacy_const_generics(2)]
28152815
pub unsafe fn vsrad_n_s64<const N: i32>(a: i64, b: i64) -> i64 {
28162816
static_assert!(N : i32 where N >= 1 && N <= 64);
2817-
a + vshrd_n_s64::<N>(b)
2817+
a.wrapping_add(vshrd_n_s64::<N>(b))
28182818
}
28192819

28202820
/// Unsigned shift right and accumulate
@@ -2824,7 +2824,7 @@ pub unsafe fn vsrad_n_s64<const N: i32>(a: i64, b: i64) -> i64 {
28242824
#[rustc_legacy_const_generics(2)]
28252825
pub unsafe fn vsrad_n_u64<const N: i32>(a: u64, b: u64) -> u64 {
28262826
static_assert!(N : i32 where N >= 1 && N <= 64);
2827-
a + vshrd_n_u64::<N>(b)
2827+
a.wrapping_add(vshrd_n_u64::<N>(b))
28282828
}
28292829

28302830
/// Shift Left and Insert (immediate)

crates/intrinsic-test/missing_aarch64.txt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,26 @@ vqshluq_n_s32
108108
vqshluq_n_s64
109109
vqshluq_n_s8
110110
vqshlus_n_s32
111+
112+
# These tests produce a different result from C but only in debug builds of
113+
# stdarch. This likely both a bug in stdarch (expanding to a different LLVM
114+
# intrinsic) and a bug in LLVM (incorrect optimization changing the behavior of
115+
# integer operations).
116+
vqrdmlah_lane_s16
117+
vqrdmlah_lane_s32
118+
vqrdmlah_laneq_s16
119+
vqrdmlah_laneq_s32
120+
vqrdmlah_s16
121+
vqrdmlah_s32
122+
vqrdmlahh_lane_s16
123+
vqrdmlahh_laneq_s16
124+
vqrdmlahh_s16
125+
vqrdmlahq_lane_s16
126+
vqrdmlahq_lane_s32
127+
vqrdmlahq_laneq_s16
128+
vqrdmlahq_laneq_s32
129+
vqrdmlahq_s16
130+
vqrdmlahq_s32
131+
vqrdmlahs_lane_s32
132+
vqrdmlahs_laneq_s32
133+
vqrdmlahs_s32

crates/intrinsic-test/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ fn compile_c(c_filename: &str, intrinsic: &Intrinsic, compiler: &str, a32: bool)
168168
let output = Command::new("sh")
169169
.arg("-c")
170170
.arg(format!(
171-
"{cpp} {cppflags} {arch_flags} -Wno-narrowing -O0 -target {target} -o c_programs/{intrinsic} {filename}",
171+
"{cpp} {cppflags} {arch_flags} -Wno-narrowing -O2 -target {target} -o c_programs/{intrinsic} {filename}",
172172
target = if a32 { "armv7-unknown-linux-gnueabihf" } else { "aarch64-unknown-linux-gnu" },
173173
arch_flags = if a32 { "-march=armv8.6-a+crypto+crc+dotprod" } else { "-march=armv8.6-a+crypto+sha3+crc+dotprod" },
174174
filename = c_filename,

crates/stdarch-gen/neon.spec

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2058,7 +2058,7 @@ generate int*_t
20582058

20592059
/// Negate
20602060
name = vneg
2061-
multi_fn = -a
2061+
multi_fn = a.wrapping_neg()
20622062
a = 1
20632063
validate -1
20642064

@@ -4055,7 +4055,7 @@ generate float*_t
40554055

40564056
/// Subtract
40574057
name = vsub
4058-
multi_fn = a - b
4058+
multi_fn = a.wrapping_sub(b)
40594059
a = 3
40604060
b = 2
40614061
validate 1
@@ -4065,7 +4065,7 @@ generate i64, u64
40654065

40664066
/// Add
40674067
name = vadd
4068-
multi_fn = a + b
4068+
multi_fn = a.wrapping_add(b)
40694069
a = 1
40704070
b = 2
40714071
validate 3
@@ -6613,7 +6613,7 @@ n-suffix
66136613
constn = N
66146614
multi_fn = static_assert-N-1-bits
66156615
multi_fn = vrshr-nself-::<N>, b:in_t, b
6616-
multi_fn = a + b
6616+
multi_fn = a.wrapping_add(b)
66176617
a = 1
66186618
b = 4
66196619
n = 2
@@ -6628,7 +6628,7 @@ n-suffix
66286628
constn = N
66296629
multi_fn = static_assert-N-1-bits
66306630
multi_fn = vrshr-nself-::<N>, b:in_t, b
6631-
multi_fn = a + b
6631+
multi_fn = a.wrapping_add(b)
66326632
a = 1
66336633
b = 4
66346634
n = 2

0 commit comments

Comments
 (0)