Skip to content

Conversation

@dtcxzyw
Copy link
Owner

@dtcxzyw dtcxzyw commented Mar 2, 2025

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

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

dtcxzyw commented Mar 2, 2025

Diff mode

runner: ariselab-64c-v2
baseline: llvm/llvm-project@81a8b5c
patch: llvm/llvm-project#129363
sha256: 07b9ebc91a854632a3ef6510b558653904cedd587838507ceb912ac2d95662c6
commit: 5c9d893

6 files changed, 9781 insertions(+), 9805 deletions(-)

Improvements:
  instcombine.NumDeadInst 35268595 -> 35268672 +0.00%
  instcombine.NumOneIteration 40440199 -> 40440208 +0.00%
Regressions:
  correlated-value-propagation.NumAShrsConverted 4422 -> 4419 -0.07%
  correlated-value-propagation.NumNNeg 84081 -> 84075 -0.01%
  correlated-value-propagation.NumShlNSW 101965 -> 101962 -0.00%
  early-cse.NumSimplify 25224236 -> 25223660 -0.00%
  correlated-value-propagation.NumShlNW 231608 -> 231605 -0.00%
  correlated-value-propagation.NumNSW 475711 -> 475708 -0.00%
  reassociate.NumChanged 4193488 -> 4193469 -0.00%
  correlated-value-propagation.NumNW 887951 -> 887948 -0.00%
  instcombine.NumSunkInst 2830770 -> 2830764 -0.00%
  licm.NumHoisted 4454380 -> 4454374 -0.00%

15 39 bench/abseil-cpp/optimized/wide_multiply_test.ll

@github-actions
Copy link
Contributor

github-actions bot commented Mar 2, 2025

The provided LLVM IR diff demonstrates several optimizations and simplifications in the generated code, focusing on reducing redundancy and improving clarity. Below is a summary of the major changes:

  1. Removal of Unnecessary Sign Extensions and Arithmetic Shifts:
    In multiple sections of the code, unnecessary sext (sign extension) and ashr (arithmetic shift right) operations have been eliminated. For example:

    • %6 = sext i32 %5 to i64 and %.lobit.i = ashr i32 %5, 31 are removed.
    • Instead, the value is directly used in subsequent computations or converted using simpler instructions like sext i32 %5 to i128.
  2. Simplified Comparison Logic:
    The comparison logic has been streamlined by removing intermediate steps. For instance:

    • Previously, multiple zext, shl, and or operations were performed to construct 128-bit values for comparison.
    • Now, the code directly uses sext i32 %5 to i128 to create the 128-bit value, reducing the number of instructions.
  3. Branch Simplification:
    Branching logic has been simplified by consolidating conditions and reducing redundant phi nodes. For example:

    • The label %16 and its associated phi node %17 have been replaced with %12 and %13, respectively, reducing complexity.
    • This change improves readability and potentially reduces execution overhead.
  4. Elimination of Redundant Temporary Variables:
    Several temporary variables that were used to store intermediate results have been removed. For instance:

    • Variables like %.sroa.2.0.insert.ext.i, %.sroa.2.0.insert.shift.i, and %.sroa.0.0.insert.ext.i are no longer needed due to the simplified computation flow.
  5. Improved Type Handling:
    The patch consistently uses sext to extend 32-bit integers to 128 bits, replacing the previous combination of sext to 64 bits followed by additional operations. This approach ensures more direct and efficient type conversions.

High-Level Overview:

The overall goal of these changes is to reduce instruction count, eliminate redundant operations, and simplify the control flow. By doing so, the patch enhances both the performance and maintainability of the generated code. The transformations focus on leveraging more efficient type extensions and eliminating unnecessary intermediate computations, which can lead to better register utilization and reduced execution time. These improvements are particularly beneficial for wide integer operations, such as those involving 128-bit values, where minimizing instruction complexity is crucial for performance optimization.

model: qwen-plus-latest
CompletionUsage(completion_tokens=572, prompt_tokens=2920, total_tokens=3492, completion_tokens_details=None, prompt_tokens_details=None)

@dtcxzyw dtcxzyw closed this Mar 2, 2025
@dtcxzyw dtcxzyw deleted the test-run13613706131 branch March 12, 2025 09:45
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.

1 participant