Repository navigation
Commit a54d5f7
committed
[JSC] B3 foldPathConstants should treat a boolean branch condition as 1 on the taken edge
https://bugs.webkit.org/show_bug.cgi?id=327633
rdar://190084203
Reviewed by Keith Miller.
When you have a code like this,
x === 32 || x === 9 || ..
the graph likes this is generated.
BB#0: (root)
Int32 @0 = ArgumentReg(x0) // x
Int32 @1 = Const32(36)
Int32 @2 = Equal(@0, @1)
Void @3 = Branch(@2), Successors: Then:#1, Else:#2
BB#1: (firstTaken) preds: #0
Void @4 = Upsilon(@2, ^10) // passes the compare itself into the Phi
Void @5 = Jump, Successors: #4
BB#2: (secondCompare) preds: #0
Int32 @6 = Const32(95)
Int32 @7 = Equal(@0, @6)
Void @8 = Branch(@7), Successors: Then:#3, Else:#6
BB#3: (secondTaken) preds: #2
Void @9 = Upsilon(@7, ^10)
Void @11 = Jump, Successors: #4
BB#4: (join) preds: #1, #3
Int32 @10 = Phi // the merged "||" result
...
Void @15 = Branch(@10), Successors: Then:#5, Else:#6
BB#5: (matched)
...
BB#6: (unmatched) preds: #2, #4
Void @17 = Return($5)
In foldPathConstants, we can install 1 for taken path if the Branch's
input returns bool (e.g. `===`). Then in the above case, @4 and @9 are
replaced with Constant 1, then @10 will be folded into 1 since both are
the same constant input, and @15 will become jump since input is always 1.
Tests: Source/JavaScriptCore/b3/testb3_1.cpp
Source/JavaScriptCore/b3/testb3_5.cpp
* Source/JavaScriptCore/b3/B3FoldPathConstants.cpp:
* Source/JavaScriptCore/b3/testb3.h:
* Source/JavaScriptCore/b3/testb3_1.cpp:
(run):
* Source/JavaScriptCore/b3/testb3_5.cpp:
(testBranchOnPhiOfTakenComparesFoldPathConstant):
Canonical link: https://commits.webkit.org/323859@main1 parent a2e1c23 commit a54d5f7
4 files changed
Lines changed: 67 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
98 | | - | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
99 | 101 | | |
100 | 102 | | |
101 | 103 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1222 | 1222 | | |
1223 | 1223 | | |
1224 | 1224 | | |
| 1225 | + | |
1225 | 1226 | | |
1226 | 1227 | | |
1227 | 1228 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
941 | 941 | | |
942 | 942 | | |
943 | 943 | | |
| 944 | + | |
944 | 945 | | |
945 | 946 | | |
946 | 947 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2945 | 2945 | | |
2946 | 2946 | | |
2947 | 2947 | | |
| 2948 | + | |
| 2949 | + | |
| 2950 | + | |
| 2951 | + | |
| 2952 | + | |
| 2953 | + | |
| 2954 | + | |
| 2955 | + | |
| 2956 | + | |
| 2957 | + | |
| 2958 | + | |
| 2959 | + | |
| 2960 | + | |
| 2961 | + | |
| 2962 | + | |
| 2963 | + | |
| 2964 | + | |
| 2965 | + | |
| 2966 | + | |
| 2967 | + | |
| 2968 | + | |
| 2969 | + | |
| 2970 | + | |
| 2971 | + | |
| 2972 | + | |
| 2973 | + | |
| 2974 | + | |
| 2975 | + | |
| 2976 | + | |
| 2977 | + | |
| 2978 | + | |
| 2979 | + | |
| 2980 | + | |
| 2981 | + | |
| 2982 | + | |
| 2983 | + | |
| 2984 | + | |
| 2985 | + | |
| 2986 | + | |
| 2987 | + | |
| 2988 | + | |
| 2989 | + | |
| 2990 | + | |
| 2991 | + | |
| 2992 | + | |
| 2993 | + | |
| 2994 | + | |
| 2995 | + | |
| 2996 | + | |
| 2997 | + | |
| 2998 | + | |
| 2999 | + | |
| 3000 | + | |
| 3001 | + | |
| 3002 | + | |
| 3003 | + | |
| 3004 | + | |
| 3005 | + | |
| 3006 | + | |
| 3007 | + | |
| 3008 | + | |
| 3009 | + | |
2948 | 3010 | | |
2949 | 3011 | | |
2950 | 3012 | | |
| |||
0 commit comments