Skip to content

pre-commit: PR183082#3500

Open
zyw-bot wants to merge 3 commits intomainfrom
test-run22358502940
Open

pre-commit: PR183082#3500
zyw-bot wants to merge 3 commits intomainfrom
test-run22358502940

Conversation

@zyw-bot
Copy link
Collaborator

@zyw-bot zyw-bot commented Feb 24, 2026

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

zyw-bot commented Feb 24, 2026

Diff mode

runner: ariselab-64c-docker
baseline: llvm/llvm-project@2e40d2b
patch: llvm/llvm-project#183082
sha256: 47245178c16d1833d47ceac6065946c14c6fed8281842455c6363765f1fe3443
commit: 46e9730

891 files changed, 270695 insertions(+), 270382 deletions(-)

Improvements:
  licm.NumBOAssociationsHoisted 3463 -> 7217 +108.40%
  licm.NumHoisted 5265744 -> 5269024 +0.06%
  correlated-value-propagation.NumSubNSW 77839 -> 77848 +0.01%
  instcombine.NegatorNumValuesVisited 21488110 -> 21490204 +0.01%
  instcombine.NegatorTotalNegationsAttempted 20572494 -> 20574477 +0.01%
  sccp.NumInstRemoved 1926014 -> 1926180 +0.01%
  correlated-value-propagation.NumCmps 270347 -> 270359 +0.00%
  correlated-value-propagation.NumSubNW 114432 -> 114437 +0.00%
  instcombine.NumDeadInst 40975323 -> 40977084 +0.00%
  scalar-evolution.NumExitCountsNotComputed 11927133 -> 11927596 +0.00%
Regressions:
  licm.NumAddSubHoisted 1907 -> 1903 -0.21%
  reassociate.NumChanged 4922532 -> 4921506 -0.02%
  correlated-value-propagation.NumMinMax 10113 -> 10111 -0.02%
  licm.NumGEPsHoisted 23765 -> 23761 -0.02%
  correlated-value-propagation.NumSubNUW 37055 -> 37051 -0.01%
  indvars.NumElimExt 298039 -> 298030 -0.00%
  instcombine.NumSunkInst 3383726 -> 3383636 -0.00%
  instcount.NumSubInst 1915428 -> 1915399 -0.00%
  instsimplify.NumReassoc 813644 -> 813637 -0.00%
  sccp.NumInstReplaced 131997 -> 131996 -0.00%

+9 velox/FirstLastValue.ll
+8 nlohmann_json/unit-json_pointer.ll
+8 nlohmann_json/unit-regression2.ll
+8 sentencepiece/bpe_model_trainer.ll
+8 sentencepiece/builder.ll
+8 z3/model.ll
+8 z3/theory_seq.ll
+7 cmake/cmSystemTools.ll
+6 linux/dmi_scan.ll
+6 stockfish/thread.ll
+4 abseil-cpp/fnmatch.ll
+4 abseil-cpp/str_split.ll
+4 abseil-cpp/stripping_test.ll
+4 cmake/cmQtAutoGenerator.ll
+4 mold/glob.ll
+4 nix/remote-store.ll
+4 node/libnode.node_contextify.ll
+4 pocketpy/io.ll
+4 velox/DateTimeFormatter.ll
+4 velox/StringFunctions.ll
+4 yalantinglibs/EnumFieldGenerator.ll
+3 clamav/bytecode_api.ll
+3 faiss/PolysemousTraining.ll
+3 ffmpeg/hlsenc.ll
+3 hyperscan/tamarama.ll
+3 libquic/ssl_test.ll
+3 libquic/string16.ll
+3 linux/extents.ll
+3 llama.cpp/ggml-opt.ll
+3 llvm/BitcastBuffer.ll
+3 openspiel/tiny_bridge.ll
+3 php/shared_alloc_mmap.ll
+3 php/zend_opcode.ll
+3 postgres/parse_relation.ll
+3 wireshark/packet-gsm_a_bssmap.ll
+1 ffmpeg/bmvvideo.ll
+0 abc/cecSynth.ll
+0 abseil-cpp/spinlock_test_common.ll
+0 arrow/UriQuery.ll
+0 arrow/datetime.ll
+0 arrow/uri.ll
+0 clamav/pe.ll
+0 coreutils-rs/4dx3xgc2q0yp2q7n.ll
+0 curl/tool_cb_dbg.ll
+0 darktable/identify_tools.ll
+0 eastl/EATextUtil.ll
+0 fmt/format-impl-test.ll
+0 git/ref-cache.ll
+0 gromacs/mpiinfo.ll
+0 grpc/http_filters_plugin.ll
+0 hdf5/H5HFdbg.ll
+0 hyperscan/rose_build_convert.ll
+0 influxdb-rs/1s5ibqekmzia6ibu.ll
+0 just-rs/4mdvpwvrpdu4jonv.ll
+0 libcxx/nodebug_on_aliases.ll
+0 libcxx/string.ll
+0 lief/AArch64PAuth.ll
+0 linux/ohci-hcd.ll
+0 meilisearch-rs/2bqmf34tdvo23w8l.ll
+0 meshlab/arap.ll
+0 meshoptimizer/vertexfilter.ll
+0 minetest/dungeongen.ll
+0 open3d/AdvancedIndexing.ll
+0 open3d/FileGLTF.ll
+0 openexr/parse_header.ll
+0 openjdk/hb-ot-shaper-khmer.ll
+0 openssl/bn_lib.ll
+0 openssl/cipher_aes_cbc_hmac_sha1_hw.ll
+0 openusd/aom_scale.ll
+0 openusd/openexr-c.ll
+0 postgres/inv_api.ll
+0 protobuf/importer.ll
+0 protobuf/php_generator.ll
+0 redis/t_hash.ll
+0 ruff-rs/8rgebevtg1rphkf0xv4zhooko.ll
+0 rustfmt-rs/3xcdaapyewyrfogi.ll
+0 slurm/gres_sock_list.ll
+0 tev/Image.ll
+0 typst-rs/5z4no3nnr5v1s13.ll
+0 vcpkg/format.ll
+0 velox/VectorFuzzer.ll
+0 wireshark/packet-ipsec.ll
+0 wireshark/packet-xmcp.ll
+0 wolfssl/sp_int.ll
+0 z3/upolynomial.ll
+0 zed-rs/5qf95fx0pqn6duuq4hkly3hl0.ll
-1 opencv/tldEnsembleClassifier.ll
-2 rust-analyzer-rs/36cskjvhktchzlnh.ll
-2 wireshark/androiddump.ll

@github-actions
Copy link
Contributor

This patch applies a set of loop-invariant code motion (LICM) and arithmetic strength-reduction optimizations across many LLVM IR files. The core transformation is the extraction of invariant subtractions—specifically expressions of the form x - c or c - x where c is constant and x is loop-invariant—and replacing them with precomputed invariant.op = ... values used later in loop bodies.

The major changes are:

  1. Loop-Invariant Subtraction Hoisting: In numerous loops, subtraction operations involving loop-invariant operands (e.g., %397 - %.val203, %397 - %6, %258 - %223) are hoisted out of loops and computed once into new %invariant.op variables. This eliminates redundant arithmetic on every iteration.

  2. Strength Reduction of Indexing Arithmetic: Many sub + add sequences (e.g., sub i32 %a, %b; add i32 %..., 1) are replaced by a single add using the precomputed invariant (e.g., add i32 %a, %invariant.op). This reduces instruction count and improves ILP.

  3. Control-Flow Graph (CFG) Restructuring for LICM: Several functions introduce new preheader blocks (e.g., .lr.ph.split.preheader, .preheader5.preheader, .lr.ph149.preheader) to enable safe hoisting of invariants before loop entry, ensuring correctness under all control paths.

  4. Phi Node Updates & Block Renaming: PHI nodes in loop headers and exits are updated to reflect new predecessor blocks (e.g., changing %59%54 or %60%55), and branch targets are adjusted accordingly (e.g., br i1 ..., label %36 instead of %39). These are mechanical but critical for maintaining SSA form after CFG changes.

  5. Consistent Pattern in String/Buffer Search Loops: A recurring pattern appears across fnmatch.ll, str_split.ll, stripping_test.ll, cmQtAutoGenerator.ll, nlohmann_json.ll, etc.: the memchr call’s length argument was previously computed as (%len - %offset) + 1; now it's (%len + %invariant.op) where %invariant.op = 1 - %offset. This simplifies the address arithmetic and exposes more optimization opportunities.

These changes collectively improve performance by reducing loop-carried dependencies, decreasing dynamic instruction count, and enabling further downstream optimizations like vectorization or better register allocation.

model: qwen-plus-latest
CompletionUsage(completion_tokens=557, prompt_tokens=112845, total_tokens=113402, completion_tokens_details=None, prompt_tokens_details=None)

%.02132.i.i = phi i64 [ %.sroa.023.078, %.lr.ph.i.i ], [ %43, %40 ]
%.02132.i.i = phi ptr [ %.sroa.1029.077, %.lr.ph.i.i ], [ %41, %40 ]
%36 = add i64 %.033.i.i, %invariant.op
%37 = icmp eq i64 %36, 0
Copy link

Choose a reason for hiding this comment

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

Looks like we have a bunch of regressions like this where the icmp is no longer optimized away...

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.

3 participants