From db50bd96e50cc7debb1734e1f6d5318f5e0b3095 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sat, 13 May 2023 22:05:24 +0000 Subject: [PATCH] Add a paragraph about the assume bitwise equal. --- compiler/rustc_mir_transform/src/gvn.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/compiler/rustc_mir_transform/src/gvn.rs b/compiler/rustc_mir_transform/src/gvn.rs index 0695f9af752..2b96763c297 100644 --- a/compiler/rustc_mir_transform/src/gvn.rs +++ b/compiler/rustc_mir_transform/src/gvn.rs @@ -18,6 +18,31 @@ //! //! By opportunity, this pass simplifies some `Rvalue`s based on the accumulated knowledge. //! +//! # Operational semantic +//! +//! Operationally, this pass attempts to prove bitwise equality between locals. Given this MIR: +//! ```ignore (MIR) +//! _a = some value // has VnIndex i +//! // some MIR +//! _b = some other value // also has VnIndex i +//! ``` +//! +//! We consider it to be replacable by: +//! ```ignore (MIR) +//! _a = some value // has VnIndex i +//! // some MIR +//! _c = some other value // also has VnIndex i +//! assume(_a bitwise equal to _c) // follows from having the same VnIndex +//! _b = _a // follows from the `assume` +//! ``` +//! +//! Which is simplifiable to: +//! ```ignore (MIR) +//! _a = some value // has VnIndex i +//! // some MIR +//! _b = _a +//! ``` +//! //! # Handling of references //! //! We handle references by assigning a different "provenance" index to each Ref/AddressOf rvalue.