Skip to content

Commit 58fec81

Browse files
committed
Add a paragraph about the assume bitwise equal.
1 parent 2c31e4c commit 58fec81

File tree

1 file changed

+25
-0
lines changed
  • compiler/rustc_mir_transform/src

1 file changed

+25
-0
lines changed

compiler/rustc_mir_transform/src/gvn.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,31 @@
1818
//!
1919
//! By opportunity, this pass simplifies some `Rvalue`s based on the accumulated knowledge.
2020
//!
21+
//! # Operational semantic
22+
//!
23+
//! Operationally, this pass attempts to prove bitwise equality between locals. Given this MIR:
24+
//! ```ignore (MIR)
25+
//! _a = some value // has VnIndex i
26+
//! // some MIR
27+
//! _b = some other value // also has VnIndex i
28+
//! ```
29+
//!
30+
//! We consider it to be replacable by:
31+
//! ```ignore (MIR)
32+
//! _a = some value // has VnIndex i
33+
//! // some MIR
34+
//! _c = some other value // also has VnIndex i
35+
//! assume(_a bitwise equal to _c) // follows from having the same VnIndex
36+
//! _b = _a // follows from the `assume`
37+
//! ```
38+
//!
39+
//! Which is simplifiable to:
40+
//! ```ignore (MIR)
41+
//! _a = some value // has VnIndex i
42+
//! // some MIR
43+
//! _b = _a
44+
//! ```
45+
//!
2146
//! # Handling of references
2247
//!
2348
//! We handle references by assigning a different "provenance" index to each Ref/AddressOf rvalue.

0 commit comments

Comments
 (0)