File tree Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change 19
19
//
20
20
21
21
#include < ir/block-utils.h>
22
+ #include < ir/branch-hints.h>
22
23
#include < ir/drop.h>
23
24
#include < ir/effects.h>
24
25
#include < ir/iteration.h>
@@ -297,6 +298,7 @@ struct Vacuum : public WalkerPass<ExpressionStackWalker<Vacuum>> {
297
298
curr->ifFalse = nullptr ;
298
299
curr->condition =
299
300
Builder (*getModule ()).makeUnary (EqZInt32, curr->condition );
301
+ BranchHints::flip (curr, getFunction ());
300
302
} else if (curr->ifTrue ->is <Drop>() && curr->ifFalse ->is <Drop>()) {
301
303
// instead of dropping both sides, drop the if, if they are the same
302
304
// type
Original file line number Diff line number Diff line change
1
+ ;; NOTE: Assertions have been generated by update_lit_checks.py and should not be edited.
2
+ ;; RUN: wasm-opt %s --vacuum -all -S -o - | filecheck %s
3
+
4
+ (module
5
+ ;; CHECK: (func $if (type $0) (param $x i32)
6
+ ;; CHECK-NEXT: (@metadata.code.branch_hint "\01")
7
+ ;; CHECK-NEXT: (if
8
+ ;; CHECK-NEXT: (i32.eqz
9
+ ;; CHECK-NEXT: (i32.eqz
10
+ ;; CHECK-NEXT: (local.get $x)
11
+ ;; CHECK-NEXT: )
12
+ ;; CHECK-NEXT: )
13
+ ;; CHECK-NEXT: (then
14
+ ;; CHECK-NEXT: (call $if
15
+ ;; CHECK-NEXT: (local.get $x)
16
+ ;; CHECK-NEXT: )
17
+ ;; CHECK-NEXT: )
18
+ ;; CHECK-NEXT: )
19
+ ;; CHECK-NEXT: )
20
+ (func $if (param $x i32 )
21
+ ;; When we flip the if, the hint should flip too.
22
+ (@metadata.code.branch_hint " \00 " )
23
+ (if
24
+ (i32.eqz
25
+ (local.get $x )
26
+ )
27
+ (then
28
+ (nop )
29
+ )
30
+ (else
31
+ (call $if
32
+ (local.get $x )
33
+ )
34
+ )
35
+ )
36
+ )
37
+ )
38
+
You can’t perform that action at this time.
0 commit comments