simple_gvn: recognize commutative operators (#6135)
* simple_gvn: recognize commutative operators Normalize instructions with commutative opcodes by sorting the arguments. This means instructions like `iadd v0, v1` and `iadd v1, v0` will be considered identical by GVN and deduplicated. * Remove `UsubSat` and `SsubSat` from `is_commutative` They are not actually commutative * Remove `TODO`s * Move InstructionData normalization into helper fn * Add normalization of commutative instructions in the epgrah implementation * Handle reflexive icmp/fcmps in GVN * Change formatting of `normalize_in_place` * suggestions from code review
This commit is contained in:
@@ -134,6 +134,11 @@ where
|
||||
/// - Update the value-to-opt-value map, and update the eclass
|
||||
/// union-find, if we rewrote the value to different form(s).
|
||||
pub(crate) fn insert_pure_enode(&mut self, inst: NewOrExistingInst) -> Value {
|
||||
match inst {
|
||||
NewOrExistingInst::New(mut data, _) => data.normalize_in_place(),
|
||||
NewOrExistingInst::Existing(inst) => self.func.dfg.insts[inst].normalize_in_place(),
|
||||
}
|
||||
|
||||
// Create the external context for looking up and updating the
|
||||
// GVN map. This is necessary so that instructions themselves
|
||||
// do not have to carry all the references or data for a full
|
||||
|
||||
Reference in New Issue
Block a user