Commit 98e17c6
committed
[SCEV] Rewrite A - B = UMin(1, A - B) lazily for A != B loop guards. (llvm#163787)
Follow-up to 2d02726
(llvm#160500)
Creating the SCEV subtraction eagerly is very expensive. To soften the
blow, just collect a map with inequalities and check if we can apply the
subtract rewrite when rewriting SCEVAddExpr.
Restores most of the regression:
http://llvm-compile-time-tracker.com/compare.php?from=0792478e4e133be96650444f3264e89d002fc058&to=7fca35db60fe6f423ea6051b45226046c067c252&stat=instructions:u
stage1-O3: -0.10%
stage1-ReleaseThinLTO: -0.09%
stage1-ReleaseLTO-g: -0.10%
stage1-O0-g: +0.02%
stage1-aarch64-O3: -0.09%
stage1-aarch64-O0-g: +0.00%
stage2-O3: -0.17%
stage2-O0-g: -0.05%
stage2-clang: -0.07%
There is still some negative impact compared to before 2d02726, but
there's probably not much we could do reduce this even more.
Compile-time improvement with 2d02726 reverted on top of the
current PR:
http://llvm-compile-time-tracker.com/compare.php?from=7fca35db60fe6f423ea6051b45226046c067c252&to=98dd152bdfc76b30d00190d3850d89406ca3c21f&stat=instructions:u
stage1-O3: 60628M (-0.03%)
stage1-ReleaseThinLTO: 76388M (-0.04%)
stage1-ReleaseLTO-g: 89228M (-0.02%)
stage1-O0-g: 18523M (-0.03%)
stage1-aarch64-O3: 67623M (-0.03%)
stage1-aarch64-O0-g: 22595M (+0.01%)
stage2-O3: 52336M (+0.01%)
stage2-O0-g: 16174M (+0.00%)
stage2-clang: 34890032M (-0.03%)
PR: llvm#163787
(cherry picked from commit a5d3522)1 parent 96dbb37 commit 98e17c6
File tree
3 files changed
+189
-11
lines changed- llvm
- include/llvm/Analysis
- lib/Analysis
- test/Transforms/IndVarSimplify
3 files changed
+189
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1343 | 1343 | | |
1344 | 1344 | | |
1345 | 1345 | | |
| 1346 | + | |
1346 | 1347 | | |
1347 | 1348 | | |
1348 | 1349 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15699 | 15699 | | |
15700 | 15700 | | |
15701 | 15701 | | |
| 15702 | + | |
| 15703 | + | |
| 15704 | + | |
| 15705 | + | |
15702 | 15706 | | |
15703 | 15707 | | |
15704 | 15708 | | |
15705 | 15709 | | |
15706 | 15710 | | |
15707 | 15711 | | |
15708 | | - | |
15709 | | - | |
15710 | | - | |
15711 | | - | |
15712 | | - | |
15713 | | - | |
15714 | | - | |
| 15712 | + | |
| 15713 | + | |
| 15714 | + | |
| 15715 | + | |
| 15716 | + | |
| 15717 | + | |
| 15718 | + | |
| 15719 | + | |
| 15720 | + | |
| 15721 | + | |
15715 | 15722 | | |
15716 | 15723 | | |
15717 | 15724 | | |
| |||
15845 | 15852 | | |
15846 | 15853 | | |
15847 | 15854 | | |
| 15855 | + | |
15848 | 15856 | | |
15849 | 15857 | | |
15850 | 15858 | | |
15851 | 15859 | | |
15852 | 15860 | | |
15853 | 15861 | | |
15854 | | - | |
| 15862 | + | |
| 15863 | + | |
15855 | 15864 | | |
15856 | 15865 | | |
15857 | 15866 | | |
| |||
15906 | 15915 | | |
15907 | 15916 | | |
15908 | 15917 | | |
| 15918 | + | |
| 15919 | + | |
| 15920 | + | |
| 15921 | + | |
| 15922 | + | |
| 15923 | + | |
| 15924 | + | |
| 15925 | + | |
| 15926 | + | |
| 15927 | + | |
| 15928 | + | |
| 15929 | + | |
| 15930 | + | |
| 15931 | + | |
| 15932 | + | |
| 15933 | + | |
| 15934 | + | |
15909 | 15935 | | |
15910 | 15936 | | |
15911 | 15937 | | |
15912 | 15938 | | |
15913 | 15939 | | |
15914 | 15940 | | |
15915 | | - | |
15916 | | - | |
| 15941 | + | |
| 15942 | + | |
| 15943 | + | |
| 15944 | + | |
| 15945 | + | |
| 15946 | + | |
| 15947 | + | |
15917 | 15948 | | |
15918 | 15949 | | |
15919 | 15950 | | |
| |||
15948 | 15979 | | |
15949 | 15980 | | |
15950 | 15981 | | |
15951 | | - | |
| 15982 | + | |
15952 | 15983 | | |
15953 | 15984 | | |
15954 | 15985 | | |
| |||
Lines changed: 146 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
0 commit comments