Browse Source
* 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 reviewpull/6131/merge
Karl Meakin
2 years ago
committed by
GitHub
12 changed files with 153 additions and 33 deletions
@ -0,0 +1,55 @@ |
|||
test simple-gvn |
|||
|
|||
function %commutative_binary(i32, i32) -> i32, i32 { |
|||
block0(v0: i32, v1: i32): |
|||
v2 = iadd v0, v1 |
|||
v3 = iadd v1, v0 |
|||
return v2, v3 |
|||
; check: v2 = iadd v0, v1 |
|||
; check: return v2, v2 |
|||
} |
|||
|
|||
function %commutative_ternary(f32, f32, f32) -> f32, f32 { |
|||
block0(v0: f32, v1: f32, v2: f32): |
|||
v3 = fma v0, v1, v2 |
|||
v4 = fma v1, v0, v2 |
|||
return v3, v4 |
|||
; check: v3 = fma v0, v1, v2 |
|||
; check: return v3, v3 |
|||
} |
|||
|
|||
function %commutative_icmp(i32, i32) -> i8, i8 { |
|||
block0(v0: i32, v1: i32): |
|||
v2 = icmp ult v0, v1 |
|||
v3 = icmp ugt v1, v0 |
|||
return v2, v3 |
|||
; check: v2 = icmp ult v0, v1 |
|||
; check: return v2, v2 |
|||
} |
|||
|
|||
function %commutative_icmp_reflexive(i32, i32) -> i8, i8 { |
|||
block0(v0: i32, v1: i32): |
|||
v2 = icmp ule v0, v0 |
|||
v3 = icmp uge v0, v0 |
|||
return v2, v3 |
|||
; check: v2 = icmp ule v0, v0 |
|||
; check: return v2, v2 |
|||
} |
|||
|
|||
function %commutative_fcmp(f32, f32) -> i8, i8 { |
|||
block0(v0: f32, v1: f32): |
|||
v2 = fcmp lt v0, v1 |
|||
v3 = fcmp gt v1, v0 |
|||
return v2, v3 |
|||
; check: v2 = fcmp lt v0, v1 |
|||
; check: return v2, v2 |
|||
} |
|||
|
|||
function %commutative_fcmp_reflexive(f32, f32) -> i8, i8 { |
|||
block0(v0: f32, v1: f32): |
|||
v2 = fcmp ule v0, v0 |
|||
v3 = fcmp uge v0, v0 |
|||
return v2, v3 |
|||
; check: v2 = fcmp ule v0, v0 |
|||
; check: return v2, v2 |
|||
} |
Loading…
Reference in new issue