Skip to content

Conversation

zyw-bot
Copy link
Collaborator

@zyw-bot zyw-bot commented Aug 11, 2025

Link: llvm/llvm-project#152851
Requested by: @dtcxzyw

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

zyw-bot commented Aug 11, 2025

Diff mode

runner: ariselab-64c-docker
baseline: llvm/llvm-project@12cec43
patch: llvm/llvm-project#152851
sha256: f3834b4921ca8efb835adfb10b401005455a9e4b3753731c8051553d05e7ccfa
commit: 39d7365

8 files changed, 3667 insertions(+), 3684 deletions(-)

Improvements:
  simplifycfg.NumSinkCommonCode 370722 -> 370723 +0.00%
  simplifycfg.NumFoldBranchToCommonDest 764436 -> 764438 +0.00%
  correlated-value-propagation.NumPhis 1292214 -> 1292216 +0.00%
  simplifycfg.NumSinkCommonInstrs 803157 -> 803158 +0.00%
  jump-threading.NumThreads 2810823 -> 2810825 +0.00%
  instcombine.NumDeadInst 42243732 -> 42243752 +0.00%
  instcombine.NumCombined 124887135 -> 124887145 +0.00%
Regressions:
  dse.NumCFGTries 57270 -> 57266 -0.01%
  dse.NumCFGChecks 638194 -> 638166 -0.00%
  instcombine.NumDeadStore 26814 -> 26813 -0.00%
  simplifycfg.NumSpeculations 399999 -> 399998 -0.00%
  reassociate.NumChanged 5084112 -> 5084108 -0.00%
  instcombine.NegatorTotalNegationsAttempted 21359586 -> 21359575 -0.00%
  instcombine.NegatorNumValuesVisited 22312672 -> 22312661 -0.00%
  memdep.NumUncacheNonLocalPtr 260090660 -> 260090653 -0.00%
  memdep.NumCacheNonLocalPtr 274908255 -> 274908250 -0.00%

10 11 bench/hdf5/optimized/H5HGcache.ll
2 3 bench/hermes/optimized/BytecodeDataProvider.ll
15 21 bench/libquic/optimized/pickle.ll
7 9 bench/linux/optimized/printk_ringbuffer.ll
33 34 bench/llvm/optimized/VNCoercion.ll

Copy link
Contributor

The patch introduces several optimizations and simplifications across multiple LLVM IR files, primarily focused on improving alignment checks and reducing redundant computations. Here are the major changes:

  1. Simplified alignment checks using bitwise AND instead of add-and-mask: In multiple functions (H5HG__cache_heap_deserialize, get_data, BytecodeDataProvider, VNCoercion, and Pickle), alignment checks of the form

    %tmp = add i64 %val, 7
    %aligned = and i64 %tmp, -8
    %is_aligned = icmp eq i64 %val, %aligned

    are replaced with the more efficient:

    %remainder = and i64 %val, 7
    %is_aligned = icmp eq i64 %remainder, 0

    This transformation is mathematically equivalent for checking 8-byte alignment but avoids the addition and uses a positive mask (7 instead of -8), which is clearer and potentially more optimizable.

  2. Improved control flow in base::Pickle constructor: The original code used speculative select and phi nodes to handle a bounds check and alignment condition separately. The patch merges these into a single conditional check using and of two conditions:

    • The size does not exceed available buffer (icmp ule)
    • The size is aligned (and %size, 3 == 0)
      This reduces branching complexity and eliminates unnecessary basic blocks.
  3. Corrected PHI node predecessor labels: In several functions (get_data, VNCoercion), PHI nodes are updated to reference the correct predecessor blocks after control flow changes. For example, %64 in get_data now correctly lists %49, %54, and %57 instead of %50, %56, %59, reflecting updated branch targets due to reordered conditions.

  4. Reduction in redundant basic blocks: The pickle.ll change eliminates intermediate blocks like .thread6 and .thread by combining alignment and bounds checks, reducing the number of branches and improving code locality.

  5. Operand and label renumbering due to structural changes: Instruction renumbering (e.g., %43%42) and updated PHI incoming values reflect the removal of instructions and basic blocks, resulting in tighter, more maintainable IR.

Overall, the changes reflect a pattern of simplifying alignment logic, reducing control flow overhead, and improving correctness in PHI node construction — all contributing to more efficient and readable LLVM IR.

model: qwen-plus-latest
CompletionUsage(completion_tokens=540, prompt_tokens=7470, total_tokens=8010, completion_tokens_details=None, prompt_tokens_details=None)

@dtcxzyw dtcxzyw closed this Aug 11, 2025
@dtcxzyw dtcxzyw deleted the test-run16869287397 branch August 19, 2025 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants