Skip to content

Conversation

@zyw-bot
Copy link
Collaborator

@zyw-bot zyw-bot commented Dec 24, 2025

Link: llvm/llvm-project#173353
Requested by: @Camsyn

@github-actions github-actions bot mentioned this pull request Dec 24, 2025
@zyw-bot
Copy link
Collaborator Author

zyw-bot commented Dec 24, 2025

Diff mode

runner: ariselab-64c-docker
baseline: llvm/llvm-project@d2af817
patch: llvm/llvm-project#173353
sha256: 28de8e93db9c003433bca8598becd4a205a53e1a59fb5122558cca6923cfd088
commit: bf036a7

5451 files changed, 17840834 insertions(+), 18262337 deletions(-)

Improvements:
  simplifycfg.NumSinkCommonInstrs 828610 -> 918613 +10.86%
  simplifycfg.NumSinkCommonCode 378229 -> 415185 +9.77%
  local.NumPHICSEs 184178 -> 190652 +3.52%
  simplifycfg.NumLookupTables 19600 -> 19802 +1.03%
  simplifycfg.NumLookupTablesHoles 2395 -> 2419 +1.00%
  loop-instsimplify.NumSimplified 182012 -> 183366 +0.74%
  constmerge.NumIdenticalMerged 15654 -> 15716 +0.40%
  simplifycfg.NumInvokeSetsFormed 53033 -> 53215 +0.34%
  sroa.NumStoresPredicated 3634 -> 3646 +0.33%
  licm.NumPromotionCandidates 586442 -> 587985 +0.26%
Regressions:
  instcount.NumAtomicRMWInst 884121 -> 876902 -0.82%
  instcount.NumAtomicCmpXchgInst 65818 -> 65530 -0.44%
  instcount.NumCallInst 39125934 -> 39014464 -0.28%
  sccp.NumInstRemoved 1938350 -> 1933152 -0.27%
  memdep.NumCacheNonLocal 19748 -> 19715 -0.17%
  instcount.NumSwitchInst 624511 -> 623486 -0.16%
  memdep.NumUncacheNonLocal 25300 -> 25268 -0.13%
  elim-avail-extern.NumRemovals 245581 -> 245288 -0.12%
  instcount.NumFDivInst 94975 -> 94867 -0.11%
  sccp.NumDeadBlocks 672342 -> 671699 -0.10%

+10 c3c/llvm_codegen.ll
+7 openusd/sdfdump.ll
+6 nix/attrs.ll
+6 nori/layout.ll
+4 openmpi/bfrop_base_unpack.ll
+3 cvc5/dot_printer.ll
+3 hermes/TypedArray.ll
+3 libquic/cbs.ll
+3 openjdk/jvmtiEventController.ll
+2 abc/giaSim.ll
+2 jq/sjis.ll
+2 llvm/Randstruct.ll
+2 llvm/SCCPSolver.ll
+2 minetest/CXMeshFileLoader.ll
+1 clamav/libfreshclam.ll
+1 hdf5/H5SL.ll
+1 node/libnode.spawn_sync.ll
+1 openjdk/compile.ll
+1 openssl/ocsp_cl.ll
+1 pingora-rs/589an6u2o7vfprggstpspnh0k.ll
+1 quiche-rs/2gvjct5jtde9m3f5c2wx76gb9.ll
+1 wasmtime-rs/3r0osxvwe4cd326n.ll
+1 yosys/memory_dff.ll
+1 z3/sat_smt_solver.ll
-1 assimp/D3MFOpcPackage.ll
-1 bdwgc/gc.ll
-1 faiss/BlockInvertedLists.ll
-1 git/refspec.ll
-1 node/libnode.data.ll
-1 openssl/rsa_lib.ll
-1 ruff-rs/dq0qakgq321c81xaqsh8asz0x.ll
-1 slurm/node_mgr.ll
-1 typst-rs/4p46tkw2iv8zjgza.ll
-1 zxing/ODCode128Writer.ll
-2 darktable/lib.ll
-2 duckdb/generated_extension_loader.ll
-2 ffmpeg/bitpacked_dec.ll
-2 ffmpeg/smush.ll
-2 flac/main.ll
-2 g2o/slam2d_linear.ll
-2 protobuf/text_format.ll
-2 rocksdb/backup_engine.ll
-2 taskflow/attach_data.ll
-2 zed-rs/3x9hk0kmwft7qehj3poulcr6l.ll
-3 abc/abcDfs.ll
-3 abseil-cpp/gtest-all.ll
-3 foundations-rs/dh385e1vps3pv71hnt480a6fj.ll
-3 hdf5/h5dump.ll
-3 pbrt-v4/file.ll
-3 ruby/hash.ll
-3 tree-sitter-rs/3uq0p4iqk1x8h2ls.ll
-4 abc/dauMerge.ll
-4 abseil-cpp/status_internal.ll
-4 curl/transfer.ll
-4 fmt/std-test.ll
-4 jemalloc/background_thread.ll
-4 linux/vgaarb.ll
-4 meshlab/apss.ll
-4 mold/arena_slot.ll
-4 nlohmann_json/unit-convenience.ll
-4 ockam-rs/5f9y9q08lu2lh52o.ll
-4 oiio/filter.ll
-4 openblas/dgees.ll
-4 openblas/dgges.ll
-4 raft-rs/eq2ti3k37vps29qsb4c08jmn4.ll
-4 tokenizers-rs/4hn9gefsll13qr1r.ll
-4 velox/SsdFile.ll
-4 z3/smt2_extra_cmds.ll
-4 zed-rs/3jh0wfvrn86dxsxfinwk4avl0.ll
-5 casadi/casadi_find.ll
-5 cpython/_localemodule.ll
-5 cpython/interpconfig.ll
-5 evmone/eof.ll
-5 grpc/socket_utils_common_posix.ll
-5 llvm/ExprInspectionChecker.ll
-5 lua/lauxlib.ll
-5 openmpi/odls_base_default_fns.ll
-5 php/ZendAccelerator.ll
-5 redis/t_zset.ll
-5 ruby/object.ll
-5 ruff-rs/8oyj8gp53iknqkniibhs0hv0n.ll
-5 ruff-rs/93k9xaqg3yy8z6m9wimzpc3mz.ll
-5 yara-x-rs/0n2x7v66evj4ga77peh4kez74.ll
-6 hdf5/H5MF.ll
-6 hermes/AST2JS.ll
-6 pola-rs/chnd9kb30up32o4gsiin00qff.ll
-6 protobuf/generated_message_reflection.ll
-6 quinn-rs/7yqfzisqbnqsiwjrqtgcfuc30.ll
-6 sundials/arkode.ll
-6 vcpkg/commands.build.ll
-7 annoy/annoymodule.ll
-7 coreutils-rs/qcad8r5ga44hvbl.ll
-7 curl/vtls.ll
-7 hwloc/topology-x86.ll
-7 logos-rs/3qbt701u50qepewd.ll
-7 mini-lsm-rs/4c6shhrwpfde8fun.ll
-7 mini-lsm-rs/haynj55bb7tm6r1.ll
-7 sdl/SDL_render_gles2.ll
-7 slurm/info_job.ll
-7 yosys/sim.ll
-8 actix-rs/4i8sqy4dbcgvpe7w.ll
-8 arrow/datetime.ll
-8 coreutils-rs/2g9ijtjos2xwh9zs.ll
-8 fish-rs/djai6kkt8m7zi9lpt05bwt9kh.ll
-8 jsonnet/static_analysis.ll
-8 logos-rs/f8j7k4fzt8jpxp1.ll
-8 php/interval.ll
-8 pola-rs/bm4zsp2597tjacc57944o0fwo.ll
-8 pola-rs/bsq42sll7rl89ozkp2zdugys9.ll
-8 rayon-rs/2xi93mrj8f00xnic.ll
-8 yaml-cpp/exp.ll
-8 yaml-cpp/scantag.ll
-9 arrow/bpacking.ll
-9 delta-rs/3qkwqfk85qralejq.ll
-9 grpc/json_reader.ll
-9 openjdk/zHeap.ll
-9 wireshark/packet-mtp2.ll
-9 wolfssl/coding.ll
-10 entt/meta_container.ll
-10 openexr/ImfHeader.ll
-10 uv-rs/305tf6qmt7vsfgc7gxtt1pqv6.ll
-11 clamav/gpt.ll
-11 libquic/v3_purp.ll
-11 proxygen/SecondaryAuthManager.ll
-11 vcpkg/portfileprovider.ll
-12 crow/example_catchall.ll
-12 node/libnode.udp_wrap.ll
-12 rocksdb/write_prepared_txn_db.ll
-13 rayon-rs/2lfjygkmshe72z1q.ll
-13 re2/dfa.ll
-13 tokio-rs/4zaq7yghb5wawieu.ll
-14 libjpeg-turbo/jcmarker.ll
-16 sentencepiece/extension_set.ll
-21 lvgl/lv_indev.ll

@github-actions
Copy link
Contributor

This patch applies a series of LLVM IR optimizations across many benchmarks, primarily focusing on control-flow simplification, reduction of redundant code paths, and improved PHI node management. Below is a summary of the five major changes:

  1. Sink Common Cleanup Code into Unified Exit Blocks:
    Multiple functions now consolidate cleanup logic (e.g., llvm.lifetime.end, __cxa_free_exception, deallocations) into shared .sink.split blocks instead of duplicating them across multiple exit paths (e.g., _exit, _thread, _local). This reduces code size and improves maintainability—seen in abcDfs.ll, gtest-all.ll, datetime.ll, crow.ll, and others.

  2. Eliminate Redundant Branches and Merge Conditional Logic:
    Several conditional branches that previously diverged to identical targets (e.g., %42, %69, %101) are collapsed or redirected to common sink blocks (e.g., %.sink.split, %.sink.split56). This eliminates unnecessary control flow and enables further optimization—evident in abcDfs.ll, dauMerge.ll, gpt.ll, and curl/transfer.ll.

  3. Refactor PHI Node Construction for Simpler Dominance:
    PHI nodes are updated to reflect the new, simplified CFG: operands are sourced only from actual predecessors of the sink block (not dead or unreachable ones), and redundant phi inputs (e.g., duplicate values from same predecessor) are removed. This improves IR canonicalization and downstream analysis—visible in abcDfs.ll, gpt.ll, clamav/libfreshclam.ll, and coreutils-rs/2g9ijtjos2xwh9zs.ll.

  4. Consolidate Exception Handling and Lifetime Management:
    Landingpad and lifetime-end calls are moved into dedicated sink blocks before final resume/return, ensuring all exception paths converge cleanly. In particular, llvm.lifetime.end.p0 calls are hoisted out of duplicated branches and placed once before branching to the final resume block—observed in abseil-cpp/gtest-all.ll, arrow/datetime.ll, darktable/lib.ll, and fmt/std-test.ll.

  5. Optimize Guard-Variable Initialization and Static Initialization Patterns:
    In entt/meta_container.ll and crow/example_catchall.ll, guard-acquire logic (__cxa_guard_acquire) is refactored to avoid repeated checks and early-exit patterns. The use of br i1 %cond, label %A, label %B is replaced with direct fallthrough or unified sink handling, reducing instruction count and improving branch prediction.

No formatting, renaming, or reordering changes were considered significant; the focus remains strictly on semantic control-flow and data-flow improvements.

model: qwen-plus-latest
CompletionUsage(completion_tokens=594, prompt_tokens=103472, total_tokens=104066, completion_tokens_details=None, prompt_tokens_details=None)

Comment on lines +6863 to +6870
llvm_emit_memcpy.exit: ; preds = %10, %.sink.split.i
%.0.sink.i = phi i32 [ %26, %.sink.split.i ], [ %22, %10 ]
%27 = zext i32 %17 to i64
%28 = add i32 %.0.sink.i, -3
%29 = icmp ult i32 %28, 5
%30 = zext i1 %29 to i32
%31 = tail call ptr @LLVMConstInt(ptr noundef %21, i64 noundef %27, i32 noundef %30) #10
%32 = tail call ptr @LLVMBuildMemCpy(ptr noundef %19, ptr noundef %12, i32 noundef %14, ptr noundef %2, i32 noundef %.0, ptr noundef %31) #10
Copy link

@Camsyn Camsyn Dec 24, 2025

Choose a reason for hiding this comment

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

Shorter IR -> Promote inline -> Larger IR

Comment on lines +22242 to +22250
%.sink = phi ptr [ %8, %112 ], [ %5, %82 ]
%.pn43.pn.pn = phi ptr [ %7, %112 ], [ %4, %82 ]
%.0.sink = phi i1 [ %.0, %112 ], [ %.033, %82 ]
%.sink.ph106 = phi ptr [ %6, %112 ], [ %3, %82 ]
%.pn43.pn.pn.ph107 = phi { ptr, i32 } [ %113, %112 ], [ %83, %82 ]
%.sink104.ph = phi ptr [ %106, %112 ], [ %76, %82 ]
call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED1Ev(ptr noundef nonnull align 8 dereferenceable(32) %.sink109) #38
call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED1Ev(ptr noundef nonnull align 8 dereferenceable(32) %.sink108) #38
br i1 %.0.sink, label %.sink.split, label %117
Copy link

Choose a reason for hiding this comment

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

Sink TWO common code but add many phis --> #IR increases.

Comment on lines +15272 to +15279
%.pn14.pn = phi ptr [ %4, %33 ], [ %2, %21 ]
%.sink29 = phi ptr [ %5, %33 ], [ %3, %21 ]
%.0.sink = phi i1 [ %.0, %33 ], [ %.05, %21 ]
%.pn14.pn.ph26 = phi { ptr, i32 } [ %34, %33 ], [ %22, %21 ]
%.sink.ph27 = phi ptr [ %28, %33 ], [ %16, %21 ]
call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED2Ev(ptr noundef nonnull align 8 dereferenceable(32) %.sink30) #27
call void @_ZNSaIcED1Ev(ptr noundef nonnull align 1 dereferenceable(1) %.sink29) #27
br i1 %.0.sink, label %.sink.split, label %36
Copy link

Choose a reason for hiding this comment

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

Sink 2 common IRs with adding many extra phis --> #IR increases

Copy link

Choose a reason for hiding this comment

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

The same. #{added phis} > #{sunk-common-IR}

Copy link

Choose a reason for hiding this comment

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

The same as above.

Comment on lines -3783 to 3788
%64 = icmp ult i32 %63, 83
call void @llvm.lifetime.end.p0(ptr nonnull %5)
br i1 %64, label %66, label %68
br label %68

_ZN4cvc58internal5proof10DotPrinter13isTheoryLemmaEPKNS0_9ProofNodeE.exit: ; preds = %56
%.fr = freeze i32 %61
%65 = icmp eq i32 %.fr, 2
call void @llvm.lifetime.end.p0(ptr nonnull %5)
br i1 %65, label %66, label %68
br label %68

Copy link

Choose a reason for hiding this comment

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

Should we sink @llvm.lifetime.end.p0 here?

@Camsyn
Copy link

Camsyn commented Dec 24, 2025

/close

@github-actions github-actions bot closed this Dec 24, 2025
@dtcxzyw dtcxzyw deleted the test-run20481946904 branch December 24, 2025 15:11
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