Skip to content

Commit 097af1f

Browse files
committed
Update example.
1 parent c6e1ef0 commit 097af1f

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

library/core/src/primitive_docs.rs

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,9 +1326,10 @@ mod prim_f16 {}
13261326
/// This can give a great performance boost since it may unlock vectorization.
13271327
///
13281328
/// The exact set of optimizations is unspecified but typically allows combining operations,
1329-
/// rearranging series of operations based on mathematical properties, converting between division and reciprocal multiplication, and
1330-
/// disregarding the sign of zero. This means that the results of elementary operations may have
1331-
/// undefined precision, but will not invoke input-dependent undefined behavior.
1329+
/// rearranging series of operations based on mathematical properties, converting between division
1330+
/// and reciprocal multiplication, and disregarding the sign of zero. This means that the results of
1331+
/// elementary operations may have undefined precision, but will not invoke input-dependent
1332+
/// undefined behavior.
13321333
///
13331334
/// Because of the unpredictable nature of compiler optimizations, the same inputs may produce
13341335
/// different results even within a single program run. **Unsafe code must not rely on any property
@@ -1340,21 +1341,25 @@ mod prim_f16 {}
13401341
/// ```
13411342
/// # #![feature(float_algebraic)]
13421343
/// # #![allow(unused_assignments)]
1343-
/// # let mut x: f32 = 12.0;
1344-
/// # let a: f32 = 34.0;
1345-
/// # let b: f32 = 56.0;
1346-
/// x = x.algebraic_add(a.algebraic_mul(b));
1344+
/// # let mut x: f32 = 0.0;
1345+
/// # let a: f32 = 1.0;
1346+
/// # let b: f32 = 2.0;
1347+
/// # let b: f32 = 3.0;
1348+
/// # let b: f32 = 4.0;
1349+
/// x = a.algebraic_add(b).algebraic_add(c).algebraic_add(d);
13471350
/// ```
13481351
///
13491352
/// May be rewritten as either:
13501353
///
13511354
/// ```
13521355
/// # #![allow(unused_assignments)]
1353-
/// # let mut x: f32 = 12.0;
1354-
/// # let a: f32 = 34.0;
1355-
/// # let b: f32 = 56.0;
1356-
/// x = x + (a * b); // As written
1357-
/// x = (a * b) + x; // Reordered to allow using a single `fma`
1356+
/// # let mut x: f32 = 0.0;
1357+
/// # let a: f32 = 1.0;
1358+
/// # let b: f32 = 2.0;
1359+
/// # let b: f32 = 3.0;
1360+
/// # let b: f32 = 4.0;
1361+
/// x = a + b + c + d; // As written
1362+
/// x = (a + c) + (b + d); // Reordered to shorten critical path and enable vectorization
13581363
/// ```
13591364
13601365
#[stable(feature = "rust1", since = "1.0.0")]

0 commit comments

Comments
 (0)