Skip to content

pre-commit: PR127398 #2123

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed

pre-commit: PR127398 #2123

wants to merge 3 commits into from

Conversation

dtcxzyw
Copy link
Owner

@dtcxzyw dtcxzyw commented Feb 16, 2025

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

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

dtcxzyw commented Feb 16, 2025

runner: ariselab-64c-v2
baseline: llvm/llvm-project@b55f751
patch: llvm/llvm-project#127398
sha256: 8aec58388c20ef1d4dced07ef88440e35a111f4cab9757d6718806897e9e5d44
commit: 8783b03

412 files changed, 195004 insertions(+), 195095 deletions(-)

Improvements:
  instsimplify.NumExpand 139761 -> 140050 +0.21%
  instcombine.NegatorNumInstructionsNegatedSuccess 46884 -> 46919 +0.07%
  instcombine.NegatorNumInstructionsCreatedTotal 50641 -> 50676 +0.07%
  instcombine.NegatorNumTreesNegated 37171 -> 37189 +0.05%
  correlated-value-propagation.NumNNeg 75409 -> 75421 +0.02%
  instcombine.NegatorMaxInstructionsCreated 13370 -> 13372 +0.01%
  indvars.NumElimIV 220641 -> 220659 +0.01%
  indvars.NumLFTR 246506 -> 246524 +0.01%
  adce.NumRemoved 90683 -> 90689 +0.01%
  correlated-value-propagation.NumSelects 214934 -> 214944 +0.00%
Regressions:
  instcombine.NegatorNumNegationsFoundInCache 3988 -> 3979 -0.23%
  loop-rotate.NumInstrsHoisted 939 -> 938 -0.11%
  instcombine.NumReassoc 255244 -> 254980 -0.10%
  instcombine.NumFactor 40285 -> 40257 -0.07%
  instcombine.NumSunkInst 2729038 -> 2728756 -0.01%
  instcombine.NumDeadInst 33137689 -> 33134510 -0.01%
  instsimplify.NumReassoc 353377 -> 353354 -0.01%
  instcombine.NumCombined 99695210 -> 99690410 -0.00%
  early-cse.NumCSE 4051723 -> 4051625 -0.00%
  simplifycfg.NumSpeculations 336407 -> 336402 -0.00%

1 2 bench/abseil-cpp/optimized/exception_safety_testing.ll
4 5 bench/assimp/optimized/zip.ll
7 8 bench/c3c/optimized/sema_expr.ll
2 3 bench/cmake/optimized/cmCPackIFWPackage.ll
2 4 bench/cpython/optimized/typeobject.ll
3 1 bench/darktable/optimized/blend_gui.ll
7 6 bench/fmt/optimized/compile-test.ll
2 3 bench/g2o/optimized/optimizable_graph.ll
8 10 bench/glslang/optimized/SpvBuilder.ll
1 2 bench/gromacs/optimized/xtc2.ll
7 9 bench/harfbuzz/optimized/harfbuzz.ll
16 17 bench/hdf5/optimized/H5SM.ll
7 10 bench/hermes/optimized/APFloat.ll
5 15 bench/hermes/optimized/Statistic.ll
6 7 bench/icu/optimized/number_utils.ll
4 7 bench/imgui/optimized/imgui_widgets.ll
11 13 bench/libevent/optimized/ws.ll
114 115 bench/linux/optimized/filter.ll
15 16 bench/llvm/optimized/APINotesTypes.ll
40 42 bench/llvm/optimized/ARMWinEH.ll
17 19 bench/llvm/optimized/ASTStructuralEquivalence.ll
5 7 bench/llvm/optimized/DebugLinesSubsection.ll
7 8 bench/llvm/optimized/DeclTemplate.ll
6 7 bench/llvm/optimized/ExprMutationAnalyzer.ll
3 4 bench/llvm/optimized/MicrosoftCXXABI.ll
1 3 bench/llvm/optimized/NeonEmitter.ll
3 6 bench/llvm/optimized/RISCVAsmParser.ll
2 3 bench/llvm/optimized/SemaTemplateDeduction.ll
15 16 bench/lvgl/optimized/lv_switch.ll
1 3 bench/meshlab/optimized/filter_mesh_booleans.ll
5 6 bench/meshlab/optimized/filter_sketchfab.ll
14 12 bench/mold/optimized/passes.cc.ALPHA.ll
16 13 bench/mold/optimized/passes.cc.ARM32.ll
9 9 bench/oiio/optimized/argparse.ll
16 17 bench/oiio/optimized/targaoutput.ll
24 28 bench/opencv/optimized/softfloat.ll
6 6 bench/openjdk/optimized/assembler_x86.ll
2 4 bench/openjdk/optimized/cmspack.ll
2 4 bench/openmpi/optimized/libmpi_c_profile_la-status_set_elements.ll
1 4 bench/openmpi/optimized/libmpi_c_profile_la-status_set_elements_x.ll
1 1 bench/openspiel/optimized/quoridor.ll
10 13 bench/openssl/optimized/libcrypto-lib-bss_mem.ll
2 3 bench/openssl/optimized/libssl-lib-quic_reactor.ll
17 19 bench/openssl/optimized/libssl-lib-quic_stream_map.ll
2 6 bench/openusd/optimized/catmarkPatchBuilder.ll
46 51 bench/openusd/optimized/faceVertex.ll
14 14 bench/openusd/optimized/regularPatchBuilder.ll
12 12 bench/openusd/optimized/stencilTableFactory.ll
64 72 bench/php/optimized/zend_API.ll
11 12 bench/postgres/optimized/genfile.ll
98 97 bench/postgres/optimized/numeric.ll
12 14 bench/postgres/optimized/spgkdtreeproc.ll
2 4 bench/qemu/optimized/hw_nvme_ctrl.ll
5 5 bench/spike/optimized/csrs.ll
3 4 bench/spike/optimized/s_subMagsF32.ll
3 3 bench/velox/optimized/ComplexVector.ll
2 6 bench/verilator/optimized/V3EmitCConstPool.ll
5 15 bench/verilator/optimized/V3EmitCModel.ll
11 11 bench/wasmedge/optimized/codegen.ll
3 7 bench/wasmtime-rs/optimized/16qf4j2oevjc61uc.ll
8 11 bench/wasmtime-rs/optimized/4bsmuvpz9r22ks1w.ll
27 29 bench/wireshark/optimized/androiddump.ll
12 16 bench/wireshark/optimized/blf.ll
62 68 bench/wireshark/optimized/packet-agentx.ll
22 25 bench/wireshark/optimized/packet-edonkey.ll
5 6 bench/wireshark/optimized/packet-ipmi.ll
4 5 bench/wireshark/optimized/packet-mongo.ll
59 60 bench/wireshark/optimized/packet-rlc-lte.ll
53 55 bench/wireshark/optimized/packet-twamp.ll
13 14 bench/wireshark/optimized/peekclassic.ll
18 20 bench/yosys/optimized/SimpSolver.ll
6 8 bench/z3/optimized/dep_intervals.ll
2 3 bench/z3/optimized/lar_solver.ll
6 7 bench/z3/optimized/smt_context.ll

Copy link
Contributor

Summary of Major Changes in the LLVM IR Patch

1. Replacement of Bitwise Operations with Select Instructions

  • In multiple files (e.g., exception_safety_testing.ll, zip.ll, ASTStructuralEquivalence.ll), bitwise operations like shl, lshr, and and are replaced with select instructions. This transformation simplifies the logic by directly choosing values based on conditions, reducing intermediate steps and improving clarity.
  • Example:
    %0 = select i1 %tobool.not, i64 0, i64 16

2. Optimization of Function Calls and Pointer Usage

  • Several function calls now use pointers derived from select or icmp results instead of relying on complex pointer arithmetic or truncation (e.g., libmpi_c_profile_la-status_set_elements.ll, hermes/APINotesTypes.ll).
  • Example:
    call void %157(ptr noundef %160, ptr noundef %.0166)

3. Removal of Redundant Shift and Truncate Operations

  • Redundant lshr and trunc operations are removed in favor of simpler icmp and select constructs. This reduces unnecessary bit manipulation and improves performance (e.g., ARMWinEH.ll, statistic.ll).
  • Example:
    %11 = select i1 %.not46, i16 0, i16 16384

4. Reordering and Simplification of PHI Nodes

  • PHI nodes are reorganized to streamline control flow and reduce dependencies on intermediate values (e.g., wireshark/packet-twamp.ll, velox/ComplexVector.ll).
  • Example:
    %.085 = phi i32 [ %150, %149 ], [ -1, %95 ], [ -1, %135 ], [ -1, %6 ], [ -1, %97 ], [ -1, %144 ]

5. Introduction of New Intrinsics and Declarations

  • New intrinsics like @llvm.abs.i32 are introduced to handle absolute value computations for 32-bit integers, complementing existing 64-bit versions (e.g., postgres/numeric.ll).
  • Example:
    declare i32 @llvm.abs.i32(i32, i1 immarg) #12

High-Level Overview

The patch focuses on simplifying and optimizing LLVM IR by replacing complex bitwise operations with conditional selects (select) and comparisons (icmp). This approach enhances readability and potentially improves execution efficiency by eliminating unnecessary shifts, truncations, and XOR operations. Additionally, function calls and PHI node handling are refined to ensure cleaner data flow and reduced redundancy. The introduction of new intrinsics supports more precise and efficient operations for specific data types, such as 32-bit integers. These changes collectively aim to improve both the maintainability and performance of the generated code across various benchmarks.

model: qwen-plus-latest
CompletionUsage(completion_tokens=688, prompt_tokens=96509, total_tokens=97197, completion_tokens_details=None, prompt_tokens_details=None)

%storemerge = xor i32 %11, -2147483648
%storemerge = and i32 %11, 2147483647
%masksel = select i1 %.not9, i32 -2147483648, i32 0
%storemerge = or disjoint i32 %masksel, %13
Copy link
Owner Author

Choose a reason for hiding this comment

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

Regression.

@dtcxzyw dtcxzyw closed this Feb 17, 2025
@dtcxzyw dtcxzyw deleted the test-run13356766502 branch February 24, 2025 06:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant