Single-File Scanning Mode (x86 Intel Intrinsics Analysis)
You can add the --enable-intel-intrinsics parameter next to the ./tiancheng file command to enable x86 Intel intrinsics analysis, which analyzes x86 vectorized instructions in source files to rewrite x86 vectorized code.
The flame graph scanning mode and function scanning mode also support x86 Intel intrinsics analysis. In the following example, x86 Intel intrinsics analysis is enabled when scanning a single source file.
Prerequisites
Assume that the Tiancheng Code Optimizer is installed in /home/tiancheng-x.x.x-Linux-Kunpeng.
Single-File Scanning with x86 Intel Intrinsics Analysis
./tiancheng file --enable-intel-intrinsics -i /home/demo/input.cpp -o /home/demo
- After the preceding command is executed, x86 Intel intrinsics analysis is enabled. The source file input.cpp in the /home/demo directory is scanned, x86 vectorized instructions in the source file are analyzed, and an HTML vectorization check report file and a JSON report file are generated in the /home/demo directory.
- The function vectorization check report is generated in the HTML vectorization check report file only when the x86 Intel intrinsics analysis feature is enabled. If this feature is disabled, the report file contains only the loop vectorization check report and task information.
Command output:
Compile database file does not exist or is unreachable. Analyzing file: /home/demo/input.cpp // Starting analysis of the input.cpp source file. >>> X86 detected. Configuring Virtual Environment... compile_commands.json not found under: /home/demo Recursively collecting include paths as fallback. [Scan] Target : /home/demo/input.cpp [Scan] Mode : direct scan (source file) [Scan] Entry : /home/demo/input.cpp Start to scan code. Vectorization check task is being executed. Please wait... Scanning start time: 2026/08/11 15:32:26 For the details information, please check: Successfully generated vectorization report: /home/demo/Vectorization_Source_20260814_190207_001_6209.html // Indicates the path to the HTML vectorization check report file. Successfully generated vectorization optimization result: /home/demo/Vectorization_Optimization_Result_20260814_190207_001_6209.json // Indicates the path to the JSON report file.
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.
- 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 Result
- View an HTML vectorization check report file. The report includes the loop vectorization check result, function vectorization check result, and task information.
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 2.

Table 1 Parameters in the 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 49 and 50), 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 process of analyzing a potentially vectorizable loop. Based on the check result, you can view the reason why the code at the corresponding location in the source file (lines 116 to 124) is potentially vectorizable.
- The following figure shows the process of analyzing a non-vectorizable loop. Based on the check result, you can view the reason why the code at the corresponding location in the source file (lines 189 to 195) 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.
Click Function Vectorization Report to view the function vectorization check result. The following figure shows the details. For details about the report parameters, see Table 3.

Table 3 Parameters in the report Parameter
Description
Function Vectorization Statistics
Total Functions
Total number of functions scanned in the source file.
Vectorizable
Number of vectorizable functions in the source file.
Potentially vectorizable
Number of functions that contain rewriteable instructions but are not supported by the Tiancheng Code Optimizer for rewriting.
Non-vectorizable
Number of non-vectorizable functions in the source file.
Lines Analyzed
Code lines of the function in the source file.
Function Check Result
Function types that can be detected by the Tiancheng Code Optimizer, including vectorizable, potentially vectorizable, and non-vectorizable.
Function Name
Function name for which vectorization is checked by the Tiancheng Code Optimizer.
Source File Path
Path to the source file containing the function.
You can filter different function types in Result Category. By default, all function types are selected. You can click any row to expand the specific function analysis process.
Click Lines Analyzed to expand a function analysis process, which can be vectorizable, potentially vectorizable, or non-vectorizable. Table 4 describes the function analysis process parameters.
- The following figure shows the process of analyzing a vectorizable function. As shown in the example, copy the vectorized optimized code snippet, replace the corresponding code in the source file (lines 303 to 325), and save the modified file to complete the rewrite.
- The following figure shows the process of analyzing a potentially vectorizable function. Based on the check result, you can view the reason why the code at the corresponding location in the source file (lines 342 to 366) is potentially vectorizable.
- The following figure shows the process of analyzing a non-vectorizable function. Based on the check result, you can view the reason why the code at the corresponding location in the source file (lines 270 to 302) is not vectorizable.
Table 4 Parameters of the function analysis process Function Analysis Process
Parameter
Description
Vectorizable
Complete Function Snippet
Code snippet of the function in the source file.
Vectorized Optimized Snippet
Code snippet of the function after being vectorized by the Tiancheng Code Optimizer.
Potentially vectorizable
Complete Function Snippet
Code snippet of the function in the source file.
Non-vectorizable
Why Non-vectorizable
The rewrite module of the Tiancheng Code Optimizer is not yet adapted and does not currently support vectorization rewriting.
Complete Function Snippet
Code snippet of the function in the source file.
Vectorized Optimized Snippet
Code snippet of the function after being vectorized by the Tiancheng Code Optimizer.
Common parameters
Function Analysis (Line by Line)
Function analysis process performed by the Tiancheng Code Optimizer.
Lines of Code
Lines of code for the function 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 a function, which can be Vectorizable, Potentially vectorizable, Non-vectorizable, Only x86-type variables included, or Irrelevant statement.
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.
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 5.

In the Task Information tab page, you can quickly view the report name, report generation time, and source code path.
Table 5 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 49 and 50), 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_190207_001_6209.json
The JSON file content is as follows:
{ "advisor_items": [ { "opt_file": { "begin_line": 303, "description": "", "end_line": 325, "fileName": "/home/demo/input.cpp", "headerFile": { "name": "#include <arm_sve.h>", "operation": "" }, "headerLocBegin": -1, "headerLocEnd": -1, "sample_code": "void vector_supported(const float * src1, const float * src2, float * dst, size_t n, float scale){\n svfloat32_t v_vscale = svdup_n_f32(scale);\n size_t i = 0;\n svbool_t pg = svwhilelt_b32_u64((uint64_t)(i), (uint64_t)(n));\n while (svptest_any(svptrue_b32(), pg)) {\n svfloat32_t v_a = svld1_f32(pg, reinterpret_cast<const float *>((src1 + i)));\n svfloat32_t v_b = svld1_f32(pg, reinterpret_cast<const float *>((src2 + i)));\n svfloat32_t v_result = svmla_f32_x(pg, v_b, v_a, v_vscale);\n svst1_f32(pg, reinterpret_cast<float *>((dst + i)), v_result);\n i += svcntw();\n pg = svwhilelt_b32_u64((uint64_t)(i), (uint64_t)(n));\n }\n for (; i < n; ++i) {\n dst[i] = src1[i] * scale + src2[i];\n }\n}" } }, { "opt_file": { "begin_line": 342, "description": "", "end_line": 366, "fileName": "/home/demo/input.cpp", "headerFile": { "name": "#include <arm_sve.h>", "operation": "" }, "headerLocBegin": -1, "headerLocEnd": -1, "sample_code": "void vector_unsupported(const float * src1, const float * src2, float * dst, size_t n, float bias){\n svfloat32_t v_vbias = svdup_n_f32(bias);\n size_t i = 0;\n svbool_t pg = svwhilelt_b32_u64((uint64_t)(i), (uint64_t)(n));\n while (svptest_any(svptrue_b32(), pg)) {\n svfloat32_t v_a = svld1_f32(pg, reinterpret_cast<const float *>((src1 + i)));\n svfloat32_t v_b = svld1_f32(pg, reinterpret_cast<const float *>((src2 + i)));\n svfloat32_t v_div = svdiv_f32_x(pg, v_a, v_b);\n svfloat32_t v_result = svadd_f32_x(pg, v_div, v_vbias);\n svst1_f32(pg, reinterpret_cast<float *>((dst + i)), v_result);\n i += svcntw();\n pg = svwhilelt_b32_u64((uint64_t)(i), (uint64_t)(n));\n }\n for (; i < n; ++i) {\n dst[i] = src1[i] / src2[i] + bias;\n }\n}" } }, { "opt_file": { "begin_line": 382, "description": "", "end_line": 410, "fileName": "/home/demo/input.cpp", "headerFile": { "name": "#include <arm_sve.h>", "operation": "" }, "headerLocBegin": -1, "headerLocEnd": -1, "sample_code": "void vector_outside_supported_list(const float * src1, const float * src2, const int * indices, const int * permute_indices, float * dst){\n svint32_t v_index_vec = svld1_s32(svptrue_pat_b32(SV_VL8), reinterpret_cast<const int32_t *>((indices)));\n svint32_t v_perm = svld1_s32(svptrue_pat_b32(SV_VL8), reinterpret_cast<const int32_t *>((permute_indices)));\n}" } } ], "code": 0, "recognizedPattern": 3 }Table 6 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 303.
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 325.
fileName
Path to the analyzed source file.
In the example, the path is /home/demo/input.cpp.
headerFile
Header file processing information used in the vectorization process.
In the example, "name": "#include <arm_sve.h>" indicates the target header file to be added or replaced in the source code, which is used to enable the SVE instruction set. "operation": "" 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:
void vector_supported(const float * src1, const float * src2, float * dst, size_t n, float scale){\n svfloat32_t v_vscale = svdup_n_f32(scale);\n size_t i = 0;\n svbool_t pg = svwhilelt_b32_u64((uint64_t)(i), (uint64_t)(n));\n while (svptest_any(svptrue_b32(), pg)) {\n svfloat32_t v_a = svld1_f32(pg, reinterpret_cast<const float *>((src1 + i)));\n svfloat32_t v_b = svld1_f32(pg, reinterpret_cast<const float *>((src2 + i)));\n svfloat32_t v_result = svmla_f32_x(pg, v_b, v_a, v_vscale);\n svst1_f32(pg, reinterpret_cast<float *>((dst + i)), v_result);\n i += svcntw();\n pg = svwhilelt_b32_u64((uint64_t)(i), (uint64_t)(n));\n }\n for (; i < n; ++i) {\n dst[i] = src1[i] * scale + src2[i];\n }\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.





