windows: Elide division-by-zero checks in Instant::now()#157328
windows: Elide division-by-zero checks in Instant::now()#157328mathisbot wants to merge 1 commit into
Conversation
|
|
|
r? @ChrisDenton rustbot has assigned @ChrisDenton. Use Why was this reviewer chosen?The reviewer was selected based on:
|
this removes the panic path when dividing by the frequency. this also makes calls to Instant::now() faster.
fd3a114 to
c2b9f39
Compare
|
Thanks! @bors r+ rollup |
This comment has been minimized.
This comment has been minimized.
windows: Elide division-by-zero checks in Instant::now() This PR teaches LLVM that the frequency of the performance counter is non null so it is able to remove division by zero checks. This removes the panic path in `mul_div_u64` and should make calls to `Instant::now()` (very slightly) faster. As seen in the assembly (see godbolt below), telling LLVM that the frequency is non zero suffices to get the optimization, but I don't know if it could be a great idea to also update the signature of `mul_div_u64`? MSDN page for [QueryPerformanceFrequency](https://learn.microsoft.com/en-us/windows/win32/api/profileapi/nf-profileapi-queryperformancefrequency): > On systems that run Windows XP or later, the function will always succeed when given valid parameters and will thus never return zero. Godbolt: https://rust.godbolt.org/z/xr6x8MrPE
…ChrisDenton windows: Elide division-by-zero checks in Instant::now() This PR teaches LLVM that the frequency of the performance counter is non null so it is able to remove division by zero checks. This removes the panic path in `mul_div_u64` and should make calls to `Instant::now()` (very slightly) faster. As seen in the assembly (see godbolt below), telling LLVM that the frequency is non zero suffices to get the optimization, but I don't know if it could be a great idea to also update the signature of `mul_div_u64`? MSDN page for [QueryPerformanceFrequency](https://learn.microsoft.com/en-us/windows/win32/api/profileapi/nf-profileapi-queryperformancefrequency): > On systems that run Windows XP or later, the function will always succeed when given valid parameters and will thus never return zero. Godbolt: https://rust.godbolt.org/z/xr6x8MrPE
|
@bors yield for encompassing rollup |
|
Auto build was cancelled. Cancelled workflows: The next pull request likely to be tested is #157340. |
This comment has been minimized.
This comment has been minimized.
windows: Elide division-by-zero checks in Instant::now() This PR teaches LLVM that the frequency of the performance counter is non null so it is able to remove division by zero checks. This removes the panic path in `mul_div_u64` and should make calls to `Instant::now()` (very slightly) faster. As seen in the assembly (see godbolt below), telling LLVM that the frequency is non zero suffices to get the optimization, but I don't know if it could be a great idea to also update the signature of `mul_div_u64`? MSDN page for [QueryPerformanceFrequency](https://learn.microsoft.com/en-us/windows/win32/api/profileapi/nf-profileapi-queryperformancefrequency): > On systems that run Windows XP or later, the function will always succeed when given valid parameters and will thus never return zero. Godbolt: https://rust.godbolt.org/z/xr6x8MrPE
|
same thing @bors yield |
|
Auto build was cancelled. Cancelled workflows: The next pull request likely to be tested is #157340. |
This comment has been minimized.
This comment has been minimized.
windows: Elide division-by-zero checks in Instant::now() This PR teaches LLVM that the frequency of the performance counter is non null so it is able to remove division by zero checks. This removes the panic path in `mul_div_u64` and should make calls to `Instant::now()` (very slightly) faster. As seen in the assembly (see godbolt below), telling LLVM that the frequency is non zero suffices to get the optimization, but I don't know if it could be a great idea to also update the signature of `mul_div_u64`? MSDN page for [QueryPerformanceFrequency](https://learn.microsoft.com/en-us/windows/win32/api/profileapi/nf-profileapi-queryperformancefrequency): > On systems that run Windows XP or later, the function will always succeed when given valid parameters and will thus never return zero. Godbolt: https://rust.godbolt.org/z/xr6x8MrPE
|
💔 Test for c09f2f7 failed: CI. Failed job:
|
|
not related to this PR. The tree is currently closed for that reason @bors retry |
|
A job failed! Check out the build log: (web) (plain enhanced) (plain) Click to see the possible cause of the failure (guessed by this bot) |
…ChrisDenton windows: Elide division-by-zero checks in Instant::now() This PR teaches LLVM that the frequency of the performance counter is non null so it is able to remove division by zero checks. This removes the panic path in `mul_div_u64` and should make calls to `Instant::now()` (very slightly) faster. As seen in the assembly (see godbolt below), telling LLVM that the frequency is non zero suffices to get the optimization, but I don't know if it could be a great idea to also update the signature of `mul_div_u64`? MSDN page for [QueryPerformanceFrequency](https://learn.microsoft.com/en-us/windows/win32/api/profileapi/nf-profileapi-queryperformancefrequency): > On systems that run Windows XP or later, the function will always succeed when given valid parameters and will thus never return zero. Godbolt: https://rust.godbolt.org/z/xr6x8MrPE
Rollup of 7 pull requests Successful merges: - #155763 (Promotes 5 Thumb-mode bare-metal Arm targets to Tier 2) - #156928 (Remove -Zemscripten-wasm-eh) - #157236 (Reorganize `tests/ui/issues` [3/N]) - #157294 (Split coroutine layout computation to its own file) - #157328 (windows: Elide division-by-zero checks in Instant::now()) - #157331 (Rewrite target checking for `#[link]`) - #157336 (Enable `clippy::mem_replace_with_default`)
…ChrisDenton windows: Elide division-by-zero checks in Instant::now() This PR teaches LLVM that the frequency of the performance counter is non null so it is able to remove division by zero checks. This removes the panic path in `mul_div_u64` and should make calls to `Instant::now()` (very slightly) faster. As seen in the assembly (see godbolt below), telling LLVM that the frequency is non zero suffices to get the optimization, but I don't know if it could be a great idea to also update the signature of `mul_div_u64`? MSDN page for [QueryPerformanceFrequency](https://learn.microsoft.com/en-us/windows/win32/api/profileapi/nf-profileapi-queryperformancefrequency): > On systems that run Windows XP or later, the function will always succeed when given valid parameters and will thus never return zero. Godbolt: https://rust.godbolt.org/z/xr6x8MrPE
…ChrisDenton windows: Elide division-by-zero checks in Instant::now() This PR teaches LLVM that the frequency of the performance counter is non null so it is able to remove division by zero checks. This removes the panic path in `mul_div_u64` and should make calls to `Instant::now()` (very slightly) faster. As seen in the assembly (see godbolt below), telling LLVM that the frequency is non zero suffices to get the optimization, but I don't know if it could be a great idea to also update the signature of `mul_div_u64`? MSDN page for [QueryPerformanceFrequency](https://learn.microsoft.com/en-us/windows/win32/api/profileapi/nf-profileapi-queryperformancefrequency): > On systems that run Windows XP or later, the function will always succeed when given valid parameters and will thus never return zero. Godbolt: https://rust.godbolt.org/z/xr6x8MrPE
…ChrisDenton windows: Elide division-by-zero checks in Instant::now() This PR teaches LLVM that the frequency of the performance counter is non null so it is able to remove division by zero checks. This removes the panic path in `mul_div_u64` and should make calls to `Instant::now()` (very slightly) faster. As seen in the assembly (see godbolt below), telling LLVM that the frequency is non zero suffices to get the optimization, but I don't know if it could be a great idea to also update the signature of `mul_div_u64`? MSDN page for [QueryPerformanceFrequency](https://learn.microsoft.com/en-us/windows/win32/api/profileapi/nf-profileapi-queryperformancefrequency): > On systems that run Windows XP or later, the function will always succeed when given valid parameters and will thus never return zero. Godbolt: https://rust.godbolt.org/z/xr6x8MrPE
This PR teaches LLVM that the frequency of the performance counter is non null so it is able to remove division by zero checks.
This removes the panic path in
mul_div_u64and should make calls toInstant::now()(very slightly) faster.As seen in the assembly (see godbolt below), telling LLVM that the frequency is non zero suffices to get the optimization, but I don't know if it could be a great idea to also update the signature of
mul_div_u64?MSDN page for QueryPerformanceFrequency:
Godbolt: https://rust.godbolt.org/z/xr6x8MrPE