Skip to content

Conversation

@zyw-bot
Copy link
Collaborator

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

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

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

zyw-bot commented Aug 31, 2025

Diff mode

runner: ariselab-64c-docker
baseline: llvm/llvm-project@865f956
patch: llvm/llvm-project#156246
sha256: 5a26366b51b59bbf9e2421ed6b363e0cdb74000f10104c5284bec2501410bb46
commit: da8f27d

4 files changed, 151 insertions(+), 145 deletions(-)

Improvements:
  globalsmodref-aa.NumNoMemFunctions 793024 -> 793030 +0.00%
  globalsmodref-aa.NumReadMemFunctions 1217281 -> 1217287 +0.00%
  instcombine.NegatorTotalNegationsAttempted 21427329 -> 21427332 +0.00%
  instcombine.NegatorNumValuesVisited 22389776 -> 22389779 +0.00%
  instcombine.NumDeadInst 42555031 -> 42555034 +0.00%
  instcombine.NumCombined 125411587 -> 125411590 +0.00%
Regressions:

15 13 bench/abc/optimized/giaAiger.ll
17 15 bench/abc/optimized/ioWriteAiger.ll
17 15 bench/abc/optimized/ioaWriteAig.ll

@github-actions
Copy link
Contributor

The patch introduces a consistent transformation across multiple ABC benchmark files (giaAiger.ll, ioWriteAiger.ll, ioaWriteAig.ll), primarily focused on optimizing signed integer difference computation and improving code clarity using LLVM intrinsics. The key changes are:

  1. Use of @llvm.abs.i32 intrinsic:
    Replaces a sequence of sub, select, and conditional logic used to compute the absolute value of a signed integer difference (%26 = %25 - %.03053) with a direct call to @llvm.abs.i32(%26, false). This simplifies the IR and allows for better optimization by the backend.

  2. Simplification of sign-bit handling:
    The original pattern computes the absolute value manually using sub 0, %val, then selects based on the sign (icmp slt, select). This is replaced with a single @llvm.abs.i32 call, which is semantically equivalent but more concise and amenable to target-specific lowering.

  3. Reduction in instruction count and complexity:
    The replacement eliminates at least two instructions (sub, select) and one PHI node dependency in the loop, reducing register pressure and improving potential for vectorization or unrolling.

  4. Consistent operand update in PHI nodes:
    PHI nodes in the loop header and exit blocks are updated to reflect the new value %31 (result of or disjoint i32 %29, %30) instead of the old %32, ensuring correct dominance and liveness after the transformation.

  5. Addition of @llvm.abs.i32 declaration:
    Introduces the declaration of the @llvm.abs.i32 intrinsic with appropriate attributes (nocallback, nounwind, speculatable, memory(none)), enabling its use and allowing interprocedural optimizations.

These changes improve code quality by leveraging LLVM’s built-in abstractions for common operations, leading to cleaner IR, better optimization opportunities, and potentially faster execution. The transformation is applied uniformly across multiple functions, suggesting an automated or peephole optimization pass was used.

model: qwen-plus-latest
CompletionUsage(completion_tokens=457, prompt_tokens=5558, total_tokens=6015, completion_tokens_details=None, prompt_tokens_details=None)

@dtcxzyw dtcxzyw closed this Aug 31, 2025
@dtcxzyw dtcxzyw deleted the test-run17358331309 branch September 1, 2025 15:02
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