Commit a6f59ee
committed
[SCEV] Check if AddRec doesn't wrap via BTC before adding predicate.
#131281 exposed a case where
SCEV is not able to infer NSW for an AddRec, but constant folding in
SCEVExpander is able to determine the runtime check is always false
(i.e. no NSW).
This is caught by an assertion in LV, where we expand a runtime check
and the trip count expression, but the runtime check gets folded away.
For AddRecs with a step of 1, if Start + BTC >= Start, the AddRec is
treated as having NUW/NSW and won't add a wrap predicate.
https://alive2.llvm.org/ce/z/VnWwEN
This check can help determine NSW/NUW in a few more cases, but doing so
for all AddRecs has a noticeable compile time impact:
https://llvm-compile-time-tracker.com/compare.php?from=215c0d2b651dc757378209a3edaff1a130338dd8&to=cdd1c1d32c598d77b73a57bcc05c1383786b3ac4&stat=instructions:u
I am not sure if there is a good general place where we could try to
refine wrap-flags in SCEV with logic like in the patch?
Fixes #131281.1 parent 0b47f6b commit a6f59ee
File tree
2 files changed
+77
-0
lines changed- llvm
- lib/Analysis
- test/Transforms/LoopVectorize
2 files changed
+77
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14775 | 14775 | | |
14776 | 14776 | | |
14777 | 14777 | | |
| 14778 | + | |
| 14779 | + | |
| 14780 | + | |
| 14781 | + | |
| 14782 | + | |
| 14783 | + | |
| 14784 | + | |
| 14785 | + | |
| 14786 | + | |
| 14787 | + | |
| 14788 | + | |
| 14789 | + | |
| 14790 | + | |
| 14791 | + | |
| 14792 | + | |
| 14793 | + | |
| 14794 | + | |
| 14795 | + | |
| 14796 | + | |
| 14797 | + | |
| 14798 | + | |
| 14799 | + | |
| 14800 | + | |
14778 | 14801 | | |
14779 | 14802 | | |
14780 | 14803 | | |
| |||
14860 | 14883 | | |
14861 | 14884 | | |
14862 | 14885 | | |
| 14886 | + | |
| 14887 | + | |
14863 | 14888 | | |
14864 | 14889 | | |
14865 | 14890 | | |
| |||
Lines changed: 52 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
247 | 247 | | |
248 | 248 | | |
249 | 249 | | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
250 | 302 | | |
251 | 303 | | |
252 | 304 | | |
| |||
0 commit comments