Commit 438a2fa
committed
Auto merge of rust-lang#124114 - scottmcm:better-checked, r=workingjubilee
Make `checked` ops emit *unchecked* LLVM operations where feasible
For things with easily pre-checked overflow conditions -- shifts and unsigned subtraction -- write the checked methods in such a way that we stop emitting wrapping versions of them.
For example, today <https://rust.godbolt.org/z/qM9YK8Txb> neither
```rust
a.checked_sub(b).unwrap()
```
nor
```rust
a.checked_sub(b).unwrap_unchecked()
```
actually optimizes to `sub nuw`. After this PR they do.
cc rust-lang#1032992 files changed
+47
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1163 | 1163 | | |
1164 | 1164 | | |
1165 | 1165 | | |
| 1166 | + | |
| 1167 | + | |
1166 | 1168 | | |
1167 | 1169 | | |
1168 | 1170 | | |
1169 | 1171 | | |
1170 | | - | |
1171 | | - | |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
1172 | 1179 | | |
1173 | 1180 | | |
1174 | 1181 | | |
| |||
1254 | 1261 | | |
1255 | 1262 | | |
1256 | 1263 | | |
| 1264 | + | |
| 1265 | + | |
1257 | 1266 | | |
1258 | 1267 | | |
1259 | 1268 | | |
1260 | 1269 | | |
1261 | | - | |
1262 | | - | |
| 1270 | + | |
| 1271 | + | |
| 1272 | + | |
| 1273 | + | |
| 1274 | + | |
| 1275 | + | |
| 1276 | + | |
1263 | 1277 | | |
1264 | 1278 | | |
1265 | 1279 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
579 | 579 | | |
580 | 580 | | |
581 | 581 | | |
582 | | - | |
583 | | - | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
584 | 593 | | |
585 | 594 | | |
586 | 595 | | |
| |||
1222 | 1231 | | |
1223 | 1232 | | |
1224 | 1233 | | |
| 1234 | + | |
| 1235 | + | |
1225 | 1236 | | |
1226 | 1237 | | |
1227 | 1238 | | |
1228 | 1239 | | |
1229 | | - | |
1230 | | - | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
| 1243 | + | |
| 1244 | + | |
| 1245 | + | |
| 1246 | + | |
1231 | 1247 | | |
1232 | 1248 | | |
1233 | 1249 | | |
| |||
1313 | 1329 | | |
1314 | 1330 | | |
1315 | 1331 | | |
| 1332 | + | |
| 1333 | + | |
1316 | 1334 | | |
1317 | 1335 | | |
1318 | 1336 | | |
1319 | 1337 | | |
1320 | | - | |
1321 | | - | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
| 1342 | + | |
| 1343 | + | |
| 1344 | + | |
1322 | 1345 | | |
1323 | 1346 | | |
1324 | 1347 | | |
| |||
0 commit comments