95b8f52f9f
Updates the simplification of moving constat operands of comparisons to the right to correctly use the strictly swapped operand rather than the negated operand. Also change the `flipOperands` function to a `swapped` getter to avoid confusion and be clearer that it returns a new value, rather than changing the current one. This better aligns with the Effective Dart guidelines for when to use a getter and how to name them. TEST=pkg/cfg/testcases/simplification.dart Change-Id: Id2c19b7cfcbc1586413251b2b9d6d54abcf590c0 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/509840 Reviewed-by: Alexander Markov <alexmarkov@google.com> Reviewed-by: Slava Egorov <vegorov@google.com> Commit-Queue: Slava Egorov <vegorov@google.com>
223 lines
4.6 KiB
Plaintext
223 lines
4.6 KiB
Plaintext
--- A.
|
|
B0 = EntryBlock()
|
|
v4 = Constant(null)
|
|
v1 = Parameter(this)
|
|
DirectCall Object.(v1)
|
|
Return(v4)
|
|
|
|
--- A.foo
|
|
B0 = EntryBlock()
|
|
Parameter(this)
|
|
v2 = Parameter(a)
|
|
v3 = Parameter(b)
|
|
v4 = Parameter(c)
|
|
v7 = BinaryIntOp +(v2, v3)
|
|
v9 = BinaryIntOp +(v7, v4)
|
|
Return(v9)
|
|
|
|
--- bar
|
|
B0 = EntryBlock()
|
|
v4 = Constant(null)
|
|
Parameter(a)
|
|
Parameter(b)
|
|
Parameter(c)
|
|
Return(v4)
|
|
|
|
--- unreachable1
|
|
B0 = EntryBlock()
|
|
Constant(10)
|
|
v4 = Constant("Bye")
|
|
Constant(null)
|
|
Parameter(obj)
|
|
Throw(v4)
|
|
|
|
--- unreachable2
|
|
B0 = EntryBlock()
|
|
v2 = Constant("12")
|
|
Constant(10)
|
|
v6 = Constant("Bye")
|
|
Constant(null)
|
|
Parameter(obj)
|
|
DirectCall int.parse(v2)
|
|
Throw(v6)
|
|
|
|
--- unreachableBreak1
|
|
B0 = EntryBlock() dominates:(B4)
|
|
v2 = Constant(0)
|
|
v13 = Constant(2)
|
|
v20 = Constant("Bye")
|
|
v22 = Constant(null)
|
|
v24 = Constant(1)
|
|
v1 = Parameter(n)
|
|
Goto(B4)
|
|
B4 = JoinBlock(B0, B16) idom:B0 dominates:(B10, B9) loop-header (depth:1 body:(B4, B9, B16) back-edges:(B16))
|
|
v29 = Phi(v2, v25)
|
|
v8 = Comparison int <(v29, v1)
|
|
Branch(v8, true: B9, false: B10)
|
|
B9 = TargetBlock() idom:B4 dominates:(B16, B15) in-loop:B4
|
|
v14 = Comparison int >(v29, v13)
|
|
Branch(v14, true: B15, false: B16)
|
|
B15 = TargetBlock() idom:B9
|
|
Throw(v20)
|
|
B16 = TargetBlock() idom:B9 in-loop:B4
|
|
v25 = BinaryIntOp +(v29, v24)
|
|
Goto(B4)
|
|
B10 = TargetBlock() idom:B4
|
|
Return(v22)
|
|
|
|
--- unreachableBreak2
|
|
B0 = EntryBlock() dominates:(B10, B9)
|
|
v2 = Constant(0)
|
|
Constant(2)
|
|
Constant("Bye")
|
|
v22 = Constant(null)
|
|
Constant(false)
|
|
v1 = Parameter(n)
|
|
v8 = Comparison int >(v1, v2)
|
|
Branch(v8, true: B9, false: B10)
|
|
B9 = TargetBlock() idom:B0
|
|
Return(v22)
|
|
B10 = TargetBlock() idom:B0
|
|
Return(v22)
|
|
|
|
--- unreachableFinally
|
|
B0 = EntryBlock() dominates:(B2, B1)
|
|
v11 = Constant(1)
|
|
v13 = Constant("Bye")
|
|
Constant(null)
|
|
v20 = Constant(3)
|
|
v22 = Constant("Bye-bye")
|
|
TryEntry(try-body: B1, catch-block: B2)
|
|
B1 = TargetBlock() exception-handler:B2 idom:B0
|
|
DirectCall print(v11)
|
|
Throw(v13)
|
|
B2 = CatchBlock() idom:B0
|
|
Parameter(#exception)
|
|
Parameter(#stackTrace)
|
|
DirectCall print(v20)
|
|
Throw(v22)
|
|
|
|
--- unreachableTryEnd
|
|
B0 = EntryBlock() dominates:(B2, B1)
|
|
v4 = Constant(1)
|
|
v6 = Constant("Bye-bye")
|
|
v8 = Constant(null)
|
|
v13 = Constant(3)
|
|
TryEntry(try-body: B1, catch-block: B2)
|
|
B1 = TargetBlock() exception-handler:B2 idom:B0
|
|
DirectCall print(v4)
|
|
Throw(v6)
|
|
B2 = CatchBlock() idom:B0
|
|
Parameter(#exception)
|
|
Parameter(#stackTrace)
|
|
DirectCall print(v13)
|
|
Return(v8)
|
|
|
|
--- unreachableCatchEnd
|
|
B0 = EntryBlock() dominates:(B2, B1)
|
|
v4 = Constant(1)
|
|
v12 = Constant(2)
|
|
v14 = Constant("Bye-bye")
|
|
v16 = Constant(null)
|
|
TryEntry(try-body: B1, catch-block: B2)
|
|
B1 = TargetBlock() exception-handler:B2 idom:B0
|
|
DirectCall print(v4)
|
|
Return(v16)
|
|
B2 = CatchBlock() idom:B0
|
|
Parameter(#exception)
|
|
Parameter(#stackTrace)
|
|
DirectCall print(v12)
|
|
Throw(v14)
|
|
|
|
--- unreachableBothTryEndAndCatchEnd
|
|
B0 = EntryBlock() dominates:(B2, B1)
|
|
v4 = Constant(1)
|
|
v6 = Constant("Bye")
|
|
Constant(null)
|
|
v13 = Constant(3)
|
|
v15 = Constant("Bye-bye")
|
|
TryEntry(try-body: B1, catch-block: B2)
|
|
B1 = TargetBlock() exception-handler:B2 idom:B0
|
|
DirectCall print(v4)
|
|
Throw(v6)
|
|
B2 = CatchBlock() idom:B0
|
|
Parameter(#exception)
|
|
Parameter(#stackTrace)
|
|
DirectCall print(v13)
|
|
Throw(v15)
|
|
|
|
--- unreachableStringInterpolation
|
|
B0 = EntryBlock()
|
|
Constant("x = ")
|
|
Constant(", boom = ")
|
|
v6 = Constant("Bye")
|
|
Constant(null)
|
|
Parameter(x)
|
|
Parameter(y)
|
|
Throw(v6)
|
|
|
|
--- unreachableListLiteral
|
|
B0 = EntryBlock()
|
|
Constant(<int>)
|
|
Constant(1)
|
|
Constant(2)
|
|
Constant(3)
|
|
Constant(4)
|
|
Constant(5)
|
|
Constant(6)
|
|
Constant(7)
|
|
Constant(8)
|
|
Constant(9)
|
|
v11 = Constant("Bye")
|
|
Constant(null)
|
|
Throw(v11)
|
|
|
|
--- unreachableMapLiteral
|
|
B0 = EntryBlock()
|
|
Constant(<int, String>)
|
|
Constant(10)
|
|
Constant("aa")
|
|
Constant(20)
|
|
Constant("bb")
|
|
Constant(30)
|
|
v7 = Constant("Bye")
|
|
Constant(null)
|
|
Throw(v7)
|
|
|
|
--- unreachableLogicExpr
|
|
B0 = EntryBlock() dominates:(B6, B10, B5)
|
|
v8 = Constant(true)
|
|
v16 = Constant("Bye")
|
|
Constant(null)
|
|
v19 = Constant(false)
|
|
v1 = Parameter(c1)
|
|
v2 = Parameter(c2)
|
|
Parameter(c3)
|
|
Branch(v1, true: B5, false: B6)
|
|
B5 = TargetBlock() idom:B0 dominates:(B14, B13)
|
|
Branch(v2, true: B13, false: B14)
|
|
B13 = TargetBlock() idom:B5
|
|
Goto(B10)
|
|
B14 = TargetBlock() idom:B5
|
|
Throw(v16)
|
|
B6 = TargetBlock() idom:B0
|
|
Goto(B10)
|
|
B10 = JoinBlock(B6, B13) idom:B0
|
|
v24 = Phi(v8, v19)
|
|
Return(v24)
|
|
|
|
--- main
|
|
B0 = EntryBlock()
|
|
v1 = Constant(null)
|
|
Return(v1)
|
|
|
|
--- field-init unreachableFieldInitializer
|
|
B0 = EntryBlock()
|
|
Constant(<num>)
|
|
Constant(10)
|
|
Constant(1)
|
|
v4 = Constant("Bye")
|
|
Constant(null)
|
|
Throw(v4)
|
|
|