about summary refs log tree commit diff
path: root/src/test/codegen/src-hash-algorithm/src-hash-algorithm-md5.rs
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2022-11-18 17:48:16 -0500
committerGitHub <noreply@github.com>2022-11-18 17:48:16 -0500
commit6b09d60f82180a9138b0299df1dbc23d78b59920 (patch)
tree1678519e62fe742ddd42e4590e16d0f9750b71b0 /src/test/codegen/src-hash-algorithm/src-hash-algorithm-md5.rs
parent8aca6ccedd0916da959638e6d2aac610d11e79c5 (diff)
parenta3c3f722b7e71d5c9985ba318c700b697fd2c106 (diff)
downloadrust-6b09d60f82180a9138b0299df1dbc23d78b59920.tar.gz
rust-6b09d60f82180a9138b0299df1dbc23d78b59920.zip
Rollup merge of #103378 - nagisa:fix-infinite-offset, r=scottmcm
Fix mod_inv termination for the last iteration

On usize=u64 platforms, the 4th iteration would overflow the `mod_gate` back to 0. Similarly for usize=u32 platforms, the 3rd iteration would overflow much the same way.

I tested various approaches to resolving this, including approaches with `saturating_mul` and `widening_mul` to a double usize. Turns out LLVM likes `mul_with_overflow` the best. In fact now, that LLVM can see the iteration count is limited, it will happily unroll the loop into a nice linear sequence.

You will also notice that the code around the loop got simplified somewhat. Now that LLVM is handling the loop nicely, there isn’t any more reasons to manually unroll the first iteration out of the loop (though looking at the code today I’m not sure all that complexity was necessary in the first place).

Fixes #103361
Diffstat (limited to 'src/test/codegen/src-hash-algorithm/src-hash-algorithm-md5.rs')
0 files changed, 0 insertions, 0 deletions