rust/compiler
Taras Tsugrii 6ae2677d72 [rustc_span][perf] Hoist lookup sorted by words out of the loop.
@lqd commented on https://github.com/rust-lang/rust/pull/114351 asking
if `sort_by_words(lookup)` is computed repeatedly. I was assuming that
rustc should have no difficulties to hoist it automatically outside of
the loop to avoid repeated pure computation, but according to
 https://godbolt.org/z/frs8Kj1rq it seems like I was wrong:
original version seems to have 2 calls per loop iteration
```
.LBB16_3:
        mov     rbx, qword ptr [r13]
        mov     r14, qword ptr [r13 + 8]
        lea     rdi, [rsp + 40]
        mov     rsi, rbx
        mov     rdx, r14
        call    example::sort_by_words
        lea     rdi, [rsp + 64]
        mov     rsi, qword ptr [rsp + 8]
        mov     rdx, qword ptr [rsp + 16]
        call    example::sort_by_words
        mov     rdi, qword ptr [rsp + 40]
        mov     rdx, qword ptr [rsp + 56]
        mov     rsi, qword ptr [rsp + 64]
        cmp     rdx, qword ptr [rsp + 80]
        mov     qword ptr [rsp + 32], rdi
        mov     qword ptr [rsp + 24], rsi
        jne     .LBB16_5
        call    qword ptr [rip + bcmp@GOTPCREL]
        test    eax, eax
        sete    al
        mov     dword ptr [rsp + 4], eax
        mov     rsi, qword ptr [rsp + 72]
        test    rsi, rsi
        jne     .LBB16_8
        jmp     .LBB16_9
```
but the manually hoisted version just 1:
```
.LBB16_3:
        mov     r13, qword ptr [r15]
        mov     r14, qword ptr [r15 + 8]
        lea     rdi, [rsp + 64]
        mov     rsi, r13
        mov     rdx, r14
        call    example::sort_by_words
        mov     rdi, qword ptr [rsp + 64]
        mov     rdx, qword ptr [rsp + 16]
        cmp     qword ptr [rsp + 80], rdx
        mov     qword ptr [rsp + 32], rdi
        jne     .LBB16_5
        mov     rsi, qword ptr [rsp + 8]
        call    qword ptr [rip + bcmp@GOTPCREL]
        test    eax, eax
        sete    bpl
        mov     rsi, qword ptr [rsp + 72]
        test    rsi, rsi
        jne     .LBB16_8
        jmp     .LBB16_9
```
This code is probably not very hot, but there is no reason to leave
such a low hanging fruit.
2023-08-02 20:51:16 -07:00
..
rustc inline format!() args up to and including rustc_middle 2023-07-30 13:18:33 +02:00
rustc_abi inline format!() args up to and including rustc_middle 2023-07-30 13:18:33 +02:00
rustc_arena Extend unused_must_use to cover block exprs 2023-06-15 17:59:13 +08:00
rustc_ast Rollup merge of #114321 - SparrowLii:parallel_test, r=oli-obk 2023-08-02 13:46:55 +02:00
rustc_ast_lowering Lower generic const items to HIR 2023-07-28 22:21:40 +02:00
rustc_ast_passes inline format!() args up to and including rustc_middle 2023-07-30 13:18:33 +02:00
rustc_ast_pretty Parse generic const items 2023-07-28 22:21:33 +02:00
rustc_attr [rustc_attr][nit] Replace filter + is_some with map_or. 2023-08-01 12:39:32 -07:00
rustc_baked_icu_data
rustc_borrowck Remove constness from TraitPredicate 2023-08-02 15:38:00 +00:00
rustc_builtin_macros inline format!() args up to and including rustc_middle 2023-07-30 13:18:33 +02:00
rustc_codegen_cranelift Merge commit '1eded3619d0e55d57521a259bf27a03906fdfad0' into sync_cg_clif-2023-07-22 2023-07-22 13:32:34 +00:00
rustc_codegen_gcc Auto merge of #105545 - erikdesjardins:ptrclean, r=bjorn3 2023-08-01 19:44:17 +00:00
rustc_codegen_llvm Rollup merge of #114079 - compiler-errors:closure-upvars, r=oli-obk 2023-08-02 13:46:54 +02:00
rustc_codegen_ssa Auto merge of #105545 - erikdesjardins:ptrclean, r=bjorn3 2023-08-01 19:44:17 +00:00
rustc_const_eval Remove constness from TraitPredicate 2023-08-02 15:38:00 +00:00
rustc_data_structures Rollup merge of #114306 - ttsugriy:push_str, r=wesleywiser 2023-08-01 17:39:12 +02:00
rustc_driver Update rustix 2023-07-03 07:20:51 +00:00
rustc_driver_impl Use a builder instead of boolean/option arguments 2023-07-25 13:51:15 +00:00
rustc_error_codes error/E0691: include alignment in error message 2023-07-21 11:04:16 +02:00
rustc_error_messages inline format!() args up to and including rustc_middle 2023-07-30 13:18:33 +02:00
rustc_errors Rollup merge of #114068 - matthiaskrgr:fmt_args_rustc_1, r=WaffleLapkin 2023-07-30 14:25:09 +02:00
rustc_expand Auto merge of #114273 - nnethercote:move-doc-comment-desugaring, r=petrochenkov 2023-08-01 21:27:48 +00:00
rustc_feature Mark lazy_type_alias as incomplete 2023-07-29 19:47:15 +00:00
rustc_fluent_macro Fix diagnostics with errors 2023-05-26 10:44:18 +00:00
rustc_fs_util
rustc_graphviz
rustc_hir Lower generic const items to HIR 2023-07-28 22:21:40 +02:00
rustc_hir_analysis Remove constness from TraitPredicate 2023-08-02 15:38:00 +00:00
rustc_hir_pretty Lower generic const items to HIR 2023-07-28 22:21:40 +02:00
rustc_hir_typeck Remove constness from TraitPredicate 2023-08-02 15:38:00 +00:00
rustc_incremental inline format!() args up to and including rustc_codegen_llvm 2023-07-30 14:22:50 +02:00
rustc_index Re-format let-else per rustfmt update 2023-07-12 21:49:27 -04:00
rustc_infer Remove constness from TraitPredicate 2023-08-02 15:38:00 +00:00
rustc_interface replace atty crate with std's isTerminal 2023-07-26 18:09:50 +03:00
rustc_lexer Update lexer emoji diagnostics to Unicode 15.0 2023-07-29 08:47:21 +08:00
rustc_lint Auto merge of #112431 - Urgau:cast_ref_to_mut_improvments, r=Nilstrieb 2023-08-02 11:25:13 +00:00
rustc_lint_defs fix(resolve): update the ambiguity glob binding as warning recursively 2023-07-29 00:19:50 +08:00
rustc_llvm Auto merge of #113339 - lqd:respect-filters, r=tmiasko 2023-08-01 23:15:20 +00:00
rustc_log inline format!() args up to and including rustc_middle 2023-07-30 13:18:33 +02:00
rustc_macros inline format!() args up to and including rustc_middle 2023-07-30 13:18:33 +02:00
rustc_metadata Rollup merge of #113741 - compiler-errors:rpitit-projects-to-missing-opaque, r=spastorino 2023-07-30 17:50:48 -07:00
rustc_middle Remove constness from TraitPredicate 2023-08-02 15:38:00 +00:00
rustc_mir_build Lower generic const items to HIR 2023-07-28 22:21:40 +02:00
rustc_mir_dataflow Use upvar_tys in more places, make it a list 2023-08-01 23:19:31 +00:00
rustc_mir_transform Use upvar_tys in more places, make it a list 2023-08-01 23:19:31 +00:00
rustc_monomorphize Rollup merge of #113872 - nnethercote:tweak-cgu-sorting, r=pnkfelix 2023-07-27 06:04:12 +02:00
rustc_parse Auto merge of #114273 - nnethercote:move-doc-comment-desugaring, r=petrochenkov 2023-08-01 21:27:48 +00:00
rustc_parse_format Fix unit tests 2023-07-19 16:37:09 +00:00
rustc_passes Lower generic const items to HIR 2023-07-28 22:21:40 +02:00
rustc_plugin_impl
rustc_privacy Remove constness from TraitPredicate 2023-08-02 15:38:00 +00:00
rustc_query_impl fix couple of clippy findings: 2023-07-23 10:50:14 +02:00
rustc_query_system inline format!() args up to and including rustc_middle 2023-07-30 13:18:33 +02:00
rustc_resolve Rollup merge of #113920 - bvanjoi:fix-81413, r=petrochenkov 2023-07-31 22:49:50 +02:00
rustc_serialize Upgrade to indexmap 2.0.0 2023-07-03 13:51:54 -07:00
rustc_session Fix a comment. 2023-07-31 16:21:02 +10:00
rustc_smir clean up, use opaque types 2023-08-01 17:48:20 +03:00
rustc_span [rustc_span][perf] Hoist lookup sorted by words out of the loop. 2023-08-02 20:51:16 -07:00
rustc_symbol_mangling Auto merge of #113708 - rcvalle:rust-cfi-fix-100778, r=compiler-errors 2023-07-27 02:48:38 +00:00
rustc_target Auto merge of #112922 - g0djan:godjan/wasi-threads, r=wesleywiser 2023-08-02 01:01:48 +00:00
rustc_trait_selection Remove constness from TraitPredicate 2023-08-02 15:38:00 +00:00
rustc_traits refactor(rustc_middle): Substs -> GenericArg 2023-07-14 13:27:35 +01:00
rustc_transmute Don't attempt to compute layout of type referencing error 2023-07-27 18:24:08 +00:00
rustc_ty_utils Rollup merge of #114079 - compiler-errors:closure-upvars, r=oli-obk 2023-08-02 13:46:54 +02:00
rustc_type_ir inline format!() args up to and including rustc_middle 2023-07-30 13:18:33 +02:00