Single-File Scanning Mode
You can add the -i parameter to the ./tiancheng file command to scan and analyze all the source code in a single source file.
Prerequisites
Assume that the Tiancheng Code Optimizer is installed in /home/tiancheng-x.x.x-Linux-Kunpeng.
Single-File Scanning
./tiancheng file -i /home/demo/pairwise_L2sqr.cpp -o /home/demo
- Scan the pairwise_L2sqr.cpp file in the /home/demo directory. The HTML vectorization check report and JSON report files are generated in the /home/demo directory.
- This section uses a single source file as an example. If you scan a source file in a project, add the -r parameter to specify the project root directory to which the source file belongs. This prevents missing header files.
Command output:
Compile database file does not exist or is unreachable. Analyzing file: /home/demo/pairwise_L2sqr.cpp // Starting analysis of the pairwise_L2sqr.cpp source file. [Scan] Target : /home/demo/pairwise_L2sqr.cpp [Scan] Mode : direct scan (source file) [Scan] Entry : /home/demo/pairwise_L2sqr.cpp Start to scan code. [FilterAnchors] Limiting from 22 to 10 anchors [CallDepth] Function 'main': original anchors=22, filtered=10 → disabling interprocedural analysis Vectorization check task is being executed. Please wait... Scanning start time: 2026/08/14 09:20:42 For the details information, please check: Successfully generated vectorization report: /home/demo/Vectorization_Source_20260814_092042_343_8341.html // Indicates the path to the HTML vectorization check report file. Successfully generated vectorization optimization result: /home/demo/Vectorization_Optimization_Result_20260814_092042_343_8341.json // Indicates the path to the JSON report file.
The scanning task is complete, and the analysis result is saved to the specified output directory.
The output directory contains two types of analysis reports. You can view the reports as needed.
- JSON report file: contains only vectorizable code snippets that have been successfully optimized. It is suited for scenarios where optimization results need to be quickly extracted. If the system displays a message indicating that the header file is not found, rectify the fault following instructions in Header File Not Found During Source File Scan with the Tiancheng Code Optimizer.
- HTML report file: provides a comprehensive view and displays three types of code: vectorizable, potentially vectorizable, and non-vectorizable. It is suitable for in-depth analysis of scenarios with optimization potential.
Viewing a Vectorization Check Report
- View an HTML vectorization check report file.
The report includes the loop vectorization check result, function vectorization check result, and task information.
The function vectorization check report is generated only when the x86 Intel intrinsics analysis feature is enabled. If this feature is disabled, the function vectorization check report contains no data.
Click Loop Vectorization Report to view the loop vectorization check result. The following figure shows the details. For details about the report parameters, see Table 1.

Table 1 Parameters in the loop vectorization check report Parameter
Description
Loop Vectorization Statistics
Total Loops
Total number of loops scanned in the source file.
Vectorizable
Number of vectorizable loops in the source file.
Potentially vectorizable
Number of loops that can be vectorized only after special processing (such as function inlining) is performed.
Non-vectorizable
Number of non-vectorizable loops in the source file.
Analyzed Loop Lines
Source line numbers of the code identified as a loop optimization candidate.
Result Category
Loop types that can be detected by the Tiancheng Code Optimizer, including vectorizable, potentially vectorizable, and non-vectorizable.
Loop Variable
Variable used in the loop iteration.
Source File Path
Path to the source file containing the loop.
You can filter different loop types in Result Category. By default, all loop types are selected. You can click any row to expand the specific loop analysis process.
Click Analyzed Loop Lines to expand a loop analysis process, which can be vectorizable, potentially vectorizable, or non-vectorizable. Table 2 describes the parameters of the loop analysis process.
- The following figure shows the process of analyzing a vectorizable loop. As shown in the example, copy the vectorized optimized code snippet, replace the corresponding code in the source file (lines 29 and 30), and save the modified file to complete the rewrite.
For modules that support rewriting, the Tiancheng Code Optimizer directly provides optimized code snippets. For modules that cannot be matched for rewriting, the tool outputs vectorization check information during line-by-line analysis of the loop body. You can optimize the code based on the vectorization check result.
- The following figure shows the potentially vectorizable loop analysis process. Based on the check result, you can view the reason why the code at the corresponding location in the source file (lines 96 to 104) is potentially vectorizable.
- The following figure shows the non-vectorizable loop analysis process. Based on the check result, you can view the reason why the code at the corresponding location in the source file (lines 85 to 88) is not vectorizable.
Table 2 Parameters of the loop analysis process Type
Parameter
Description
Vectorizable
Complete Loop Snippet
Code snippet of the loop in the source file.
Vectorized Optimized Snippet
Code snippet of the loop after being vectorized by the Tiancheng Code Optimizer.
Potentially vectorizable
Complete Loop Snippet
Code snippet of the loop in the source file.
Non-vectorizable
Why Non-vectorizable
Reason why the Tiancheng Code Optimizer determines that the loop is not vectorizable.
Complete Loop Snippet
Code snippet of the loop in the source file.
Common parameters
Loop Body Analysis (Line-by-Line)
Loop analysis process performed by the Tiancheng Code Optimizer.
Lines of Code
Lines of code for the loop body.
Coverage
Indicates whether it is covered by a vectorization mode of the Tiancheng Code Optimizer.
Line Vectorization Status
Vectorization status of a single line of code in the loop body, which can be vectorizable, potentially vectorizable, or non-vectorizable.
Check Information
Result of code line analysis performed by the Tiancheng Code Optimizer.
NOTE:If the code line vectorization status is vectorizable, no check information is displayed. If the status is potentially vectorizable or non-vectorizable, the cause or suggestion is displayed.
When the x86 Intel intrinsics analysis feature is disabled, the function vectorization check report contains no data. For details, see the following figure:

Click Task Information to view the information about the current check report. See the following figure. For details about the task information parameters, see Table 3.

In the Task Information tab page, you can quickly view the report name, report generation time, and source code path.
Table 3 Task information parameters Parameter
Description
Task Name
Name of the check task automatically created by the Tiancheng Code Optimizer.
Report Generated
Time when the Tiancheng Code Optimizer generates the report.
Source File Path
Path to the source file containing the scanned source code.
Flame Graph Path
Path to the scanned flame graph SVG file.
Specific Function Name
Name of the scanned function.
File Project
Root directory of the project containing the source file to be analyzed.
Clang File Path
Directory of the Clang built-in header file (for example, stddef.h).
GCC Toolchain
GCC installation directory, which is used as the toolchain path for code analysis.
Enable SVE
Indicates whether to convert the instruction set to the SVE instruction set.
The HTML report focuses on diagnostic analysis. You need to manually adjust the code structure based on the provided suggestions and verify the optimization effect again.
- The following figure shows the process of analyzing a vectorizable loop. As shown in the example, copy the vectorized optimized code snippet, replace the corresponding code in the source file (lines 29 and 30), and save the modified file to complete the rewrite.
- View a JSON report file.
Open the generated JSON report file and analyze and confirm the modification points.
vim /home/demo/Vectorization_Optimization_Result_20260814_092042_343_8341.json
The JSON file content is as follows:
{ "advisor_items": [ { "opt_file": { "begin_line": 29, "description": "", "end_line": 30, "fileName": "/home/demo/pairwise_L2sqr.cpp", "headerFile": { "name": "#include <arm_neon.h>", "operation": "add" }, "headerLocBegin": -1, "headerLocEnd": -1, "sample_code": " size_t j = 0;\n for (; j + 4 < nb; j += 4) {\n vst1q_f32(dis + j, vaddq_f32(vdupq_n_f32(qNorm), vld1q_f32(bNorms + j)));\n }\n for (; j < nb; j++) dis[j] = qNorm + bNorms[j];" } }, { "opt_file": { "begin_line": 36, "description": "", "end_line": 38, "fileName": "/home/demo/pairwise_L2sqr.cpp", "headerFile": { "name": "#include <arm_neon.h>", "operation": "add" }, "headerLocBegin": -1, "headerLocEnd": -1, "sample_code": " size_t j = 0;\n for (; j + 4 < nb; j += 4) {\n vst1q_f32(dis + j, vaddq_f32(vdupq_n_f32(qNorm), vld1q_f32(bNorms + j)));\n }\n for (; j < nb; j++) {\n dis[j] = qNorm + bNorms[j];\n }" } }, { "opt_file": { "begin_line": 59, "description": "", "end_line": 61, "fileName": "/home/demo/pairwise_L2sqr.cpp", "headerFile": { "name": "#include <arm_neon.h>", "operation": "add" }, "headerLocBegin": -1, "headerLocEnd": -1, "sample_code": " size_t j = 0;\n for (; j + 4 < nb; j += 4) {\n vst1q_f32(dis + j, vaddq_f32(vld1q_f32(dis + j), vdupq_n_f32(qNorm)));\n }\n for (; j < nb; j++) {\n dis[j] += qNorm;\n }" } } ], "code": 0, "recognizedPattern": 3 }Table 4 Field description Field
Description
advisor_items
Array of code optimization suggestions. Each item in the array is a code tuning optimization.
opt_file
Detailed information about a single optimization suggestion.
begin_line
Start line number of the code to be optimized.
In the example, the start line number is 29.
description
Detailed description of the optimization suggestion.
end_line
End line number of the code to be optimized.
In the example, the end line number is 30.
fileName
Path to the analyzed source file.
In the example, the path is /home/demo/pairwise_L2sqr.cpp.
headerFile
Header file processing information used in the vectorization process.
In the example, "name": "#include <arm_neon.h>" indicates the target header file to be added or replaced in the source code, which is used to enable the NEON instruction set. "operation": "add" indicates the operation type for processing the specified header file.
The options of operation are:
- add: adds a target header file during scalar code vectorization.
- replace: replaces the existing x86 header file with the corresponding Arm header file during x86-to-Arm vectorization porting.
headerLocBegin
Start line number where the header file will be inserted.
- If the value is -1, the header file is already included in the code and does not need to be manually added.
- If the value is a positive integer, it indicates the start line number where the header file will be inserted.
In the example, the value is -1, which indicates that the header file is already included in the code and does not need to be manually added.
headerLocEnd
End line number where the header file will be inserted.
- If the value is -1, the header file is already included in the code and does not need to be manually added.
- If the value is a positive integer, it indicates the end line number where the header file will be inserted.
In the example, the value is -1, which indicates that the header file is already included in the code and does not need to be manually added.
sample_code
Recommended code vectorization sample, which can be directly used to replace the current code.
The following is an example of optimized code:
size_t j = 0;\n for (; j + 4 < nb; j += 4) {\n vst1q_f32(dis + j, vaddq_f32(vdupq_n_f32(qNorm), vld1q_f32(bNorms + j)));\n }\n for (; j < nb; j++) {\n dis[j] = qNorm + bNorms[j];\n}code
Tool execution status code.
- The value 0 indicates execution success.
- A non-zero value indicates an interruption.
In the example, 0 indicates that the tool is executed successfully.
recognizedPattern
Number of code snippets to be optimized.
In the example, the number is 3.
Rewrite the code based on the JSON report.
- View advisor_items, which contains all identified optimization suggestions.
- For each optimization suggestion, check the begin_line and end_line fields to determine the code range to be replaced.
- Copy the vectorized code from sample_code and replace the code in the source file between begin_line and end_line.
- Check the headerLocBegin and headerLocEnd fields.
- If the value is -1, the header file already exists and does not need to be added.
- If the value is a positive integer, add the header file declaration in headerFile to the specified location.
- Save the modified file to complete the automatic rewrite.


