Skip to content

Conversation

@dtcxzyw
Copy link
Owner

@dtcxzyw dtcxzyw commented Jun 11, 2025

Link: llvm/llvm-project#143677
Requested by: @nikic

@github-actions github-actions bot mentioned this pull request Jun 11, 2025
@dtcxzyw
Copy link
Owner Author

dtcxzyw commented Jun 11, 2025

Diff mode

runner: ariselab-64c-docker
baseline: llvm/llvm-project@c59cc2b
patch: llvm/llvm-project#143677
sha256: 705689373cfa18286a7695b3c84429f621946f5837768ecdb27f042f62853e9d
commit: 3cdb7c2

1077 files changed, 680566 insertions(+), 681038 deletions(-)

Improvements:
  correlated-value-propagation.NumAddNUW 241093 -> 242259 +0.48%
  correlated-value-propagation.NumAddNW 521904 -> 524235 +0.45%
  correlated-value-propagation.NumAddNSW 280811 -> 281976 +0.41%
  simplifycfg.NumFoldValueComparisonIntoPredecessors 521514 -> 522706 +0.23%
  correlated-value-propagation.NumNW 1076039 -> 1078426 +0.22%
  correlated-value-propagation.NumNUW 619395 -> 620618 +0.20%
  correlated-value-propagation.NumNSW 654391 -> 655558 +0.18%
  correlated-value-propagation.NumSubNUW 39285 -> 39340 +0.14%
  simplifycfg.NumLookupTablesHoles 2562 -> 2565 +0.12%
  correlated-value-propagation.NumCmps 300837 -> 301046 +0.07%
Regressions:
  instsimplify.NumReassoc 839423 -> 838472 -0.11%
  early-cse.NumSimplify 30230816 -> 30217453 -0.04%
  jump-threading.NumThreads 2951167 -> 2949883 -0.04%
  constmerge.NumIdenticalMerged 15663 -> 15659 -0.03%
  jump-threading.NumFolds 2761666 -> 2760995 -0.02%
  correlated-value-propagation.NumPhis 1345940 -> 1345631 -0.02%
  correlated-value-propagation.NumOverflows 4785 -> 4784 -0.02%
  dse.NumRedundantStores 37600 -> 37596 -0.01%
  simplifycfg.NumHoistCommonInstrs 2487836 -> 2487633 -0.01%
  jump-threading.NumDupes 143284 -> 143279 -0.00%

4 4 bench/actix-rs/optimized/14bh10sj718x2c7a.ll
13 10 bench/actix-rs/optimized/4pmtvrahn6eloepe.ll
4 4 bench/assimp/optimized/zip.ll
6 7 bench/brotli/optimized/compress_fragment.ll
11 12 bench/brotli/optimized/compress_fragment_two_pass.ll
9 9 bench/clap-rs/optimized/5651dp9k16h53y8x.ll
3 3 bench/cpython/optimized/_datetimemodule.ll
3 3 bench/curl/optimized/hsts.ll
6 6 bench/darktable/optimized/CiffIFD.ll
5 5 bench/darktable/optimized/TiffIFD.ll
19 16 bench/duckdb/optimized/format.ll
4 4 bench/entt/optimized/signal_less.ll
7 7 bench/gromacs/optimized/scanner_internal.ll
6 6 bench/harfbuzz/optimized/harfbuzz.ll
23 23 bench/hermes/optimized/MemoryBuffer.ll
2 2 bench/image-rs/optimized/1njpscpjlgoe3i07.ll
16 12 bench/image-rs/optimized/244uszkx0e8t5ie1.ll
10 10 bench/ipopt/optimized/IpTNLPReducer.ll
6 7 bench/linux/optimized/e1000_hw.ll
7 8 bench/linux/optimized/initramfs.ll
69 70 bench/linux/optimized/intel_pps.ll
23 27 bench/linux/optimized/x_tables.ll
3 4 bench/llvm/optimized/AArch64ISelLowering.ll
16 17 bench/llvm/optimized/AArch64InstructionSelector.ll
25 26 bench/llvm/optimized/ELFObjectFile.ll
4 4 bench/luau/optimized/Normalize.ll
1 1 bench/memcached/optimized/proto_text.ll
6 5 bench/minetest/optimized/base64.ll
3 3 bench/nix/optimized/hash.ll
2 2 bench/opencv/optimized/cv2_convert.ll
12 14 bench/pingora-rs/optimized/49twrvocwp9bq7vff0y6fdha0.ll
30 32 bench/pola-rs/optimized/3wianlchgo9it4fzo8sacadsu.ll
12 14 bench/pola-rs/optimized/coi50hzefc1heiv20go5gh3ph.ll
14 16 bench/pola-rs/optimized/druded1wlaptuxbrsbyp1cgur.ll
15 22 bench/ruff-rs/optimized/0dzegug7jvirkbl9h47rmcoii.ll
9 11 bench/ruff-rs/optimized/9ezhgv3vaoku7b96fwwr4f701.ll
5 6 bench/ruff-rs/optimized/ai55pudcm2su63z2q0evp6vp4.ll
6 7 bench/ruff-rs/optimized/eflamytq0vbr5latbim0v068w.ll
8 11 bench/rust-analyzer-rs/optimized/2c0n7dumpf7kecgy.ll
22 26 bench/rust-analyzer-rs/optimized/4piyv0md79k42idp.ll
14 14 bench/syn/optimized/2i67i8azb4r5b3mw.ll
36 36 bench/tls-rs/optimized/2xhpv4vf07do7r8g.ll
38 38 bench/tls-rs/optimized/7y9936vu35zt2sp.ll
8 8 bench/tokio-rs/optimized/2i86qkpybymk1snv.ll
5 4 bench/typst-rs/optimized/15cic2jih5jwap60.ll
35 47 bench/typst-rs/optimized/1fd2xpfefmgrcb9d.ll
5 6 bench/uv-rs/optimized/0qkl8r8szphiev5qfee0uvoca.ll
1 1 bench/wasmtime-rs/optimized/1spnjfu340nob5zr.ll
29 26 bench/wasmtime-rs/optimized/t1qxt6oh6s98so1.ll
5 6 bench/wireshark/optimized/packet-wassp.ll
11 12 bench/zed-rs/optimized/0ndq4firz8eetu3jvgre1the4.ll
7 9 bench/zed-rs/optimized/0npw9rg0wengltga49c0tfins.ll
14 15 bench/zed-rs/optimized/1x0js6flb76ylaa82e6lu27uy.ll
11 12 bench/zed-rs/optimized/3tqegt9m5oad3ocos87azd3mb.ll
5 6 bench/zed-rs/optimized/5ta1fnasvc90k95zqql8ufc92.ll
10 11 bench/zed-rs/optimized/di6vqkr45z5qfxmwsnoq97jcv.ll
1 1 bench/zxing/optimized/ECI.ll

@github-actions
Copy link
Contributor

Here is a brief summary of the most significant changes in the provided LLVM IR diff:

  1. Switch Instruction Reorganization and Optimization:

    • Several functions replace xor-based switch condition generation with more direct comparisons, improving clarity and potentially enabling better optimization by the backend.
    • For example, in _ZN4core5slice6memchr12memchr_naive17hc161699a4e4d4b77E.exit.i, instead of XOR'ing with poison values to generate switch conditions, the code now uses simpler comparison logic (switch i64 %37, label %38).
    • This change appears across multiple files (e.g., typst-rs, ruff-rs, pola-rs) and likely reflects a broader pattern of optimizing switch lowering.
  2. PHI Node Reordering:

    • In several functions, the order of incoming values in PHI nodes has been changed without altering functionality. For instance, in .thread blocks of actix-rs and pola-rs, the predecessors are reordered but the actual logic remains the same.
    • These reorders often improve alignment with predecessor block layout, which may help with register allocation or readability for downstream optimizations.
  3. Improved Lifetime Management and Stack Cleanup:

    • Some diffs add explicit llvm.lifetime.end calls earlier or remove redundant ones. For example, in tls-rs/optimized/2xhpv4vf07do7r8g.ll, lifetime markers are adjusted around unwind paths to better reflect object lifetimes.
    • These changes help the optimizer understand when variables are dead, possibly enabling better memory reuse and avoiding unnecessary spills.
  4. Use of Poison Values and Better Alignment in Constant Tables:

    • In functions like BrotliCompressFragmentFast, constant switch tables now use poison entries explicitly to represent unreachable or undefined cases.
    • This improves safety and helps catch potential miscompiles during analysis by making undefined control flow explicit.
  5. Unreachable Code Pruning and Simplification:

    • Some functions have unreachable blocks removed or simplified, such as in base64.ll where %conv and %cmp15 are used to reduce branching after switch logic.
    • Other instances include pruning landingpad-based cleanup paths that were unreachable or redundant, especially in Rust panic handling routines (e.g., rust_analyzer, uv-rs).

High-Level Overview

The patch primarily consists of cleanup and optimization of switch statements, including removal of XOR idioms that previously transformed values for switch labels. There's also a focus on better lifetime management, PHI node reordering, and explicit use of poison to model undefined behavior safely. Many changes affect error handling and unwinding paths, particularly in Rust crates, by removing unreachable blocks and simplifying resume points. The overall goal seems to be improving codegen quality, reducing redundancy, and making undefined control flow safer and clearer to the optimizer.

model: qwen-plus-latest
CompletionUsage(completion_tokens=640, prompt_tokens=109985, total_tokens=110625, completion_tokens_details=None, prompt_tokens_details=None)

tail call void @_ZN6brotli3enc17compress_fragment30BrotliCompressFragmentFastImpl17h24e109efb8be68e4E.llvm.2002727345234535996(ptr noalias noundef nonnull align 1 %0, ptr noalias noundef nonnull readonly align 1 %1, i64 noundef %2, i64 noundef %3, i32 noundef %4, ptr noalias noundef nonnull align 4 %5, i64 noundef %6, i64 noundef %23, ptr noalias noundef nonnull align 1 %8, i64 noundef %9, ptr noalias noundef nonnull align 2 %10, i64 noundef %11, ptr noalias noundef nonnull align 8 dereferenceable(8) %12, ptr noalias noundef nonnull align 1 %13, i64 noundef %14, ptr noalias noundef nonnull align 8 dereferenceable(8) %15, ptr noalias noundef nonnull align 1 %16, i64 noundef %17)
.sink.split2: ; preds = %21
%switch.gep = getelementptr inbounds nuw [7 x i64], ptr @switch.table._ZN6brotli3enc17compress_fragment26BrotliCompressFragmentFast17hcd5548c609f0d180E, i64 0, i64 %switch.tableidx
%switch.load = load i64, ptr %switch.gep, align 8
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regression

i64 -9223372036854775803, label %"_ZN4core4iter8adapters3map8map_fold28_$u7b$$u7b$closure$u7d$$u7d$17he8509607f81d0c7aE.exit.i"
i64 -9223372036854775798, label %"_ZN4core4iter8adapters3map8map_fold28_$u7b$$u7b$closure$u7d$$u7d$17he8509607f81d0c7aE.exit.i"
i64 -9223372036854775797, label %"_ZN4core4iter8adapters3map8map_fold28_$u7b$$u7b$closure$u7d$$u7d$17he8509607f81d0c7aE.exit.i"
i64 -9223372036854775792, label %"_ZN4core4iter8adapters3map8map_fold28_$u7b$$u7b$closure$u7d$$u7d$17he8509607f81d0c7aE.exit.i"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Creating unfortunately large immediates here.

@dtcxzyw dtcxzyw closed this Aug 2, 2025
@dtcxzyw dtcxzyw deleted the test-run15582836093 branch August 2, 2025 06:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants