Skip to content

Conversation

@dtcxzyw
Copy link
Owner

@dtcxzyw dtcxzyw commented May 8, 2025

Link: llvm/llvm-project#139109
Requested by: @nikic

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

dtcxzyw commented May 8, 2025

Diff mode

runner: ariselab-64c-v2
baseline: llvm/llvm-project@3bc3b1c
patch: llvm/llvm-project#139109
sha256: b716ed3f1c4c8018f74b3d78421269ad15673194d718570068fd8b4d0ec25f17
commit: 2f1c219

10 files changed, 2388 insertions(+), 2389 deletions(-)

Improvements:
  instcombine.NumSunkInst 2878868 -> 2878891 +0.00%
  gvn.NumGVNSimpl 3959581 -> 3959589 +0.00%
  instcombine.NumDeadInst 35302713 -> 35302764 +0.00%
  early-cse.NumSimplify 25059464 -> 25059478 +0.00%
  instcombine.NumTwoIterations 16907846 -> 16907854 +0.00%
  instcombine.NumCombined 105523566 -> 105523610 +0.00%
Regressions:
  reassociate.NumChanged 4252348 -> 4252326 -0.00%
  instcombine.NumOneIteration 40195279 -> 40195271 -0.00%
  memdep.NumUncacheNonLocalPtr 214293971 -> 214293929 -0.00%
  memdep.NumCacheNonLocalPtr 222985753 -> 222985737 -0.00%

20 20 bench/lief/optimized/AArch64Feature.ll
13 13 bench/lief/optimized/DyldBindingInfo.ll
40 40 bench/lief/optimized/ExportInfo.ll
15 15 bench/lief/optimized/Note.ll
16 16 bench/lief/optimized/X86Feature.ll
24 25 bench/llvm/optimized/DAGCombiner.ll

@github-actions
Copy link
Contributor

github-actions bot commented May 8, 2025

The provided patch modifies several LLVM IR files, primarily related to code generated for frozen map lookups used in enum-to-string conversions. Below is a summary of the top 5 major changes:


1. Simplified Branch Condition Logic

In multiple functions (e.g., _ZNK6frozen3map...find...), complex branch conditions involving selects and ORs have been replaced with simpler and operations:

  • Old: Used select followed by or disjoint to compute an index, then compared with a constant.
  • New: Replaced with a direct and of two comparison results, simplifying logic and potentially improving predictability.

Example:

; Old
%.not.i.i = icmp eq i64 %.add12.i.i, 56

; New
%.not.i.i = and i1 %.not.i.i.i.i.i.i.i.i, %.not.i.i.i.i.i.i.i.i

This pattern appears consistently across all modified files.


2. Improved Memory Access Pattern

GEP (GetElementPtr) and load instructions have been reordered or restructured to better express memory access patterns, likely aiding alias analysis and vectorization.

Example:
Instead of loading from a computed pointer, a base address is selected first based on a condition, then indexed and loaded:

%4 = getelementptr nuw i8, ptr @__const..., i64 %.idx...
%.ptr = getelementptr nuw i8, ptr %4, i64 %.add...
%5 = load i32, ptr %.ptr...

Improves clarity and may help backend optimizations.


3. Phi Node Adjustments

Several PHI nodes in merge blocks have been updated to reflect new control flow changes introduced by the altered branching logic.

Impact: Ensures correctness after CFG (Control Flow Graph) modifications and improves value tracking.


4. Reduction in Intermediate Values

By replacing multi-step arithmetic (or, add, etc.) with logical combinations, intermediate values such as .add12.i.i are eliminated.

Effect: Reduces register pressure and simplifies instruction scheduling.


5. Minor DAG Combiner Improvements

In DAGCombiner.ll, some integer logic around sign extension and selection has been restructured:

  • Uses xor and select instead of mul and icmp slt for certain sign checks.
  • Updates sink PHIs to refer to correct predecessors, indicating minor control-flow restructuring.

These changes appear aimed at reducing complexity and improving optimization opportunities in SelectionDAG building.


High-Level Overview:

The patch seems focused on simplifying and optimizing lookup logic in frozen maps used for enum stringification. It reduces arithmetic complexity in favor of boolean logic, which can improve both runtime performance and compiler analysis efficiency. The changes are consistent across multiple files, suggesting a common source-level refactor or improvement in the code generation strategy for these map lookups.

model: qwen-plus-latest
CompletionUsage(completion_tokens=635, prompt_tokens=17055, total_tokens=17690, completion_tokens_details=None, prompt_tokens_details=None)

@dtcxzyw dtcxzyw closed this Aug 2, 2025
@dtcxzyw dtcxzyw deleted the test-run14913245172 branch August 2, 2025 06:41
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