Datasets:

Modalities:
Text
Formats:
json
Size:
< 1K
Tags:
code
DOI:
Libraries:
Datasets
pandas
License:
dtcxzyw commited on
Commit
8d5ae49
·
1 Parent(s): bbc83f3
This view is limited to 50 files because it contains too many changes.   See raw diff
.gitignore ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ __pycache__
2
+ work
3
+ .vscode
4
+ .cache
5
+
6
+ # Python Environments
7
+ .env
8
+ .venv
9
+ env/
10
+ venv/
11
+ ENV/
12
+ env.bak/
13
+ venv.bak/
CITATION.cff ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ cff-version: 1.2.0
2
+ message: "If you use this dataset, please cite it as below."
3
+ title: "LLVM APR Benchmark: A Large-Scale Automated Program Repair Benchmark of Real-World LLVM Middle-End Bugs"
4
+ type: dataset
5
+ authors:
6
+ - given-names: Yingwei
7
+ family-names: Zheng
8
9
+ affiliation: Southern University of Science and Technology
10
+ url: "https://github.com/dtcxzyw/llvm-apr-benchmark"
11
+ license: Apache-2.0
Dockerfile ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM ubuntu:22.04
2
+ WORKDIR /root
3
+
4
+ # Install dependencies
5
+ RUN apt-get update && apt-get install -y \
6
+ build-essential \
7
+ ninja-build \
8
+ cmake \
9
+ sudo \
10
+ ccache \
11
+ python3-pip \
12
+ libkrb5-3 \
13
+ zlib1g-dev \
14
+ liblttng-ust1t64 \
15
+ libssl-dev \
16
+ libicu-dev \
17
+ cargo \
18
+ gawk \
19
+ bison \
20
+ wget \
21
+ flex \
22
+ curl \
23
+ jq \
24
+ git
25
+ RUN wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -
26
+ RUN apt-get update && apt-get install -y \
27
+ llvm-20-dev \
28
+ clang-20 \
29
+ && rm -rf /var/lib/apt/lists/*
30
+
31
+ # Clone and build alive2
32
+ RUN git clone https://github.com/AliveToolkit/alive2.git && \
33
+ cd alive2 && mkdir -p build && cd build && \
34
+ cmake .. -GNinja -DCMAKE_BUILD_TYPE=Release -DBUILD_TV=1 && \
35
+ cmake --build . -j
36
+
37
+ # Install python dependencies
38
+
39
+ # Clone the repository and llvm
40
+ RUN git clone https://github.com/dtcxzyw/llvm-apr-benchmark.git && \
41
+ cd llvm-apr-benchmark && \
42
+ pip3 install -r requirements.txt && \
43
+ mkdir -p work && cd work && \
44
+ git clone https://github.com/llvm/llvm-project.git && \
45
+
46
+ # Set environment variables
47
+ ENV LAB_LLVM_DIR=/root/llvm-apr-benchmark/work/llvm-project
48
+ ENV LAB_LLVM_BUILD_DIR=/root/llvm-apr-benchmark/work/llvm-build
49
+ ENV LAB_LLVM_ALIVE_TV=/root/alive2/build/alive-tv
50
+ ENV LAB_DATASET_DIR=/root/llvm-apr-benchmark/dataset
51
+ ENV LAB_FIX_DIR=/root/llvm-apr-benchmark/examples/fixes
LICENSE ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
README.md CHANGED
@@ -1,3 +1,335 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # LLVM APR Benchmark: A Large-Scale Automated Program Repair Benchmark of Real-World LLVM Middle-End Bugs
2
+
3
+ ## Motivation
4
+
5
+ The compiler is a critical infrastructure in the software development. The LLVM compiler infrastructure is widely used in both academia and industry. However, due to its inherent complexity, the LLVM compiler still contains many bugs that can be triggered in edge cases. As one of the LLVM maintainers, my job is to provide the minimal reproducible test cases for issues from fuzzers/ downstream users, and fix these bugs (or assign them to the right person). However, the process is time-consuming and boring. Thanks to the recent advances in compiler testing, we can automatically generate interesting test cases that trigger bugs and automatically reduce the tests to minimal ones. If we can also perform bug localization and repair automatically, it will significantly reduce the workload of us maintainers! Recently, LLM-based automated program repair (APR) techniques have been proposed. We have seen some successful cases in APR benchmarks like Defects4J and SWE-bench. But I believe that fixing LLVM bugs is more challenging than existing benchmarks due to its large C/C++ codebase, complex logic, long history, and the need for domain-specific knowledge. Therefore, I build this benchmark to see if we can automatically repair real-world LLVM bugs with the help of large language models and APR techniques. I hope this benchmark can help both SE researchers and LLVM community to understand how APR techniques work on a large-scale, real-world C/C++ project.
6
+
7
+ ## Dataset Description
8
+
9
+ In this benchmark, we only focus on three kinds of bugs in the LLVM middle-end:
10
+ + Crash: the compiler terminates exceptionally or hits an assertion failure (LLVM is built with `-DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_ABI_BREAKING_CHECKS=WITH_ASSERTS`).
11
+ + Miscompilation: the compiler generates incorrect program from a well-defined source code.
12
+ + Hang: the compiler runs into an infinite loop or fails to reach a fixpoint.
13
+
14
+ All bugs can be triggered with an `opt` command and a small piece of LLVM textual IR.
15
+
16
+ This dataset collects some fixed LLVM middle-end bugs from GitHub issues since 2024-01-01. Each issue contains issue description, test cases, a reference patch, and some hints. All issues are checked against the following criteria:
17
+
18
+ + At least one of the given test cases can be used to reproduce the bug at a specific commit (`base_commit`). For most of the miscompilation bugs, the `src` and `tgt` functions will be checked with alive2, an automatic refinement verification tool for LLVM. If miscompilation happens, `alive-tv` will provide a counterexample. The remaining miscompilation bugs will be checked by `lli`.
19
+ + `opt` passes all the given tests after fixing the bug with the given reference patch (`patch`).
20
+ + `opt` passes all regression tests at a specific commit (`hints.fix_commit`).
21
+
22
+ Take [Issue121459](https://github.com/llvm/llvm-project/issues/121459) as an example:
23
+ ```jsonc
24
+ {
25
+ // Identifier of the bug. It can be an issue number, a pull request number,
26
+ // or a commit hash.
27
+ "bug_id": "121459",
28
+ // Points to issue/PR/commit url
29
+ "issue_url": "https://github.com/llvm/llvm-project/issues/121459",
30
+ // Bug type: crash/miscompilation/hang
31
+ "bug_type": "miscompilation",
32
+ // Fixes should be applied at the base commit
33
+ "base_commit": "68d265666e708bad1c63b419b6275aaba1a7dcd2",
34
+ // Knowledge cutoff date. It is not allowed to use the web knowledge base
35
+ // after this date or use a large language model trained with newer
36
+ // information. Please check the "Rules" section for exemptions.
37
+ "knowledge_cutoff": "2025-01-02T09:03:32Z",
38
+ // Regression test directories
39
+ "lit_test_dir": [
40
+ "llvm/test/Transforms/InstCombine"
41
+ ],
42
+ // Bug localization hints at different granularity levels.
43
+ // Note that this information is provided in a best-effort way.
44
+ // They are not guaranteed to be available or accurate.
45
+ "hints": {
46
+ "fix_commit": "a4d92400a6db9566d84cb4b900149e36e117f452",
47
+ "components": [
48
+ "InstCombine"
49
+ ],
50
+ "bug_location_lineno": {
51
+ "llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": [
52
+ [
53
+ 2782,
54
+ 2787
55
+ ],
56
+ [
57
+ 2838,
58
+ 2843
59
+ ],
60
+ [
61
+ 2847,
62
+ 2852
63
+ ]
64
+ ]
65
+ },
66
+ "bug_location_funcname": {
67
+ "llvm/lib/Transforms/InstCombine/InstructionCombining.cpp": [
68
+ "foldGEPOfPhi"
69
+ ]
70
+ }
71
+ },
72
+ // A reference patch extracted from hints.fix_commit
73
+ "patch": "<omitted>",
74
+ // Minimal reproducible tests
75
+ "tests": [
76
+ {
77
+ "file": "llvm/test/Transforms/InstCombine/opaque-ptr.ll",
78
+ "commands": [
79
+ "opt -S -passes='instcombine<no-verify-fixpoint>' < %s"
80
+ ],
81
+ "tests": [
82
+ {
83
+ "test_name": "gep_of_phi_of_gep_different_type",
84
+ "test_body": "<omitted>"
85
+ },
86
+ {
87
+ "test_name": "gep_of_phi_of_gep_flags2",
88
+ "test_body": "<omitted>"
89
+ },
90
+ {
91
+ "test_name": "gep_of_phi_of_gep_flags1",
92
+ "test_body": "<omitted>"
93
+ }
94
+ ]
95
+ }
96
+ ],
97
+ // Issue description
98
+ "issue": {
99
+ "title": "[InstCombine] GEPNoWrapFlags is propagated incorrectly",
100
+ "body": "<omitted>",
101
+ "author": "dtcxzyw",
102
+ "labels": [
103
+ "miscompilation",
104
+ "llvm:instcombine"
105
+ ],
106
+ "comments": []
107
+ },
108
+ "verified": true
109
+ }
110
+ ```
111
+
112
+ As of January 20, 2025, this benchmark contains 226 issues. You can run `python3 scripts/dataset_summary.py` locally to obtain the latest statistics.
113
+ ```
114
+ Total issues: 226
115
+ Verified issues: 226 (100.00%)
116
+
117
+ Bug type summary:
118
+ miscompilation: 84
119
+ crash: 135
120
+ hang: 7
121
+
122
+ Bug component summary (Total = 43):
123
+ LoopVectorize: 60
124
+ SLPVectorizer: 50
125
+ InstCombine: 47
126
+ ScalarEvolution: 10
127
+ VectorCombine: 7
128
+ ValueTracking: 5
129
+ IR: 5
130
+ ConstraintElimination: 4
131
+ InstructionSimplify: 4
132
+ Local: 3
133
+ MemCpyOptimizer: 3
134
+ ...
135
+
136
+ Label summary:
137
+ miscompilation: 86
138
+ crash: 82
139
+ vectorizers: 67
140
+ llvm:instcombine: 50
141
+ llvm:SLPVectorizer: 50
142
+ crash-on-valid: 44
143
+ llvm:transforms: 31
144
+ llvm:analysis: 14
145
+ llvm:SCEV: 11
146
+ release:backport: 9
147
+ confirmed: 9
148
+ llvm:crash: 8
149
+ regression: 6
150
+ llvm:hang: 6
151
+ floating-point: 4
152
+ ...
153
+
154
+ Changed files count summary:
155
+ Average: 1.15
156
+ Max: 4
157
+ Min: 1
158
+ Median: 1
159
+
160
+ Inserted lines summary:
161
+ Average: 11.04
162
+ Max: 164
163
+ Min: 0
164
+ Median: 6
165
+
166
+ Deleted lines summary:
167
+ Average: 5.64
168
+ Max: 169
169
+ Min: 0
170
+ Median: 2
171
+
172
+ Test count summary:
173
+ Average: 3.73
174
+ Max: 107
175
+ Min: 1
176
+ Median: 1
177
+
178
+ Patch summary:
179
+ Single file fix: 201 (88.94%)
180
+ Single func fix: 173 (76.55%)
181
+ Single hunk fix: 129 (57.08%)
182
+ ```
183
+
184
+ You can see from the statistics that more than half of the bugs can be fixed with a single hunk. So I believe most of bugs can be fixed with the aid of LLM-based APR techniques :)
185
+
186
+ ## Getting Started
187
+
188
+ ### Prerequisites
189
+
190
+ + A C++17 compatible compiler
191
+ + ninja
192
+ + ccache
193
+ + Pre-built LLVM core libraries
194
+ + [alive-tv](https://github.com/AliveToolkit/alive2)
195
+
196
+ You can follow the [Dockerfile](./Dockerfile) to setup the environment.
197
+
198
+ ### Installation
199
+
200
+ ```bash
201
+ git clone https://github.com/dtcxzyw/llvm-apr-benchmark.git
202
+ cd llvm-apr-benchmark
203
+ pip3 install -r requirements.txt
204
+ mkdir -p work && cd work
205
+ git clone https://github.com/llvm/llvm-project.git
206
+ ```
207
+
208
+ Please set the following environment variables:
209
+ ```bash
210
+ export LAB_LLVM_DIR=<path-to-llvm-src>
211
+ export LAB_LLVM_BUILD_DIR=<path-to-llvm-build-dir>
212
+ export LAB_LLVM_ALIVE_TV=<path-to-alive-tv>
213
+ export LAB_DATASET_DIR=<path-to-llvm-apr-benchmark>/dataset
214
+ export LAB_FIX_DIR=<path-to-llvm-apr-benchmark>/examples/fixes
215
+ ```
216
+
217
+ ### Usage
218
+
219
+ This benchmark provides two helper modules to allow researchers to easily interact with LLVM and this benchmark.
220
+
221
+ To use these two helpers:
222
+ ```python
223
+ sys.path.append(os.path.join(os.path.dirname(os.environ["LAB_DATASET_DIR"]), "scripts"))
224
+ import llvm_helper
225
+ from lab_env import Environment as Env
226
+ ```
227
+
228
+ [llvm_helper](./scripts/llvm_helper.py)
229
+ ```python
230
+ # Environment variables
231
+ llvm_helper.llvm_dir # os.environ["LAB_LLVM_DIR"]
232
+ llvm_helper.llvm_build_dir # os.environ["LAB_LLVM_BUILD_DIR"]
233
+ llvm_helper.llvm_alive_tv # os.environ["LAB_LLVM_ALIVE_TV"]
234
+ llvm_helper.dataset_dir # os.environ["LAB_DATASET_DIR"]
235
+
236
+ # Execute git commands on the llvm source tree
237
+ source_code = llvm_helper.git_execute(['show', f'{commit}:{file_path}'])
238
+
239
+ # Get information of first failed test from the result of Environment.check_fast/check_full
240
+ res, log = env.check_fast()
241
+ if isinstance(log, list):
242
+ test = llvm_helper.get_first_failed_test(log)
243
+ ```
244
+ [lab_env](./scripts/lab_env.py)
245
+ ```python
246
+ env = Env(
247
+ # Load an issue from dataset/{issue_id}.json
248
+ issue_id,
249
+ # The knowledge cutoff date of LLM
250
+ base_model_knowledge_cutoff = "2024-01-01Z",
251
+ # Max concurrent jobs for build/test
252
+ max_build_jobs=None,
253
+ max_test_jobs=None,
254
+ )
255
+
256
+ # If any external knowledge is used, please call this function.
257
+ env.use_knowledge(url = "<url>", date = "<date>")
258
+ # Reset the source tree to the base commit. Please call it before each attempt.
259
+ env.reset()
260
+ # Build llvm
261
+ res, log = env.build()
262
+ # Provide a certificate with the patch and verification result
263
+ certificate = env.dump()
264
+ # Perform build + test
265
+ res, log = env.check_fast()
266
+ # Perform build + test + lit regression test
267
+ res, log = env.check_full()
268
+ # Issue information (always available)
269
+ bug_type = env.get_bug_type()
270
+ base_commit = env.get_base_commit()
271
+ tests = env.get_tests()
272
+ # Hints (optional)
273
+ fix_commit = env.get_hint_fix_commit()
274
+ components = env.get_hint_components()
275
+ files = env.get_hint_files()
276
+ functions = env.get_hint_bug_functions()
277
+ linenos = env.get_hint_line_level_bug_locations()
278
+ # Issue description (optional)
279
+ issue = env.get_hint_issue()
280
+ # Collect instructions and intrinsics from the given LLVM IR.
281
+ # Then it will retrieve descriptions from llvm/docs/LangRef.dst.
282
+ # It is useful for LLMs to understand new flags/attributes/metadata.
283
+ keywords = env.get_ir_keywords(llvm_ir)
284
+ desc = env.get_langref_desc(keywords)
285
+ ```
286
+
287
+ Here is a simple repair loop:
288
+ ```python
289
+ env = Env(...)
290
+ # System prompts and user prompts
291
+ messages = []
292
+ while True:
293
+ # Reset the LLVM source code tree
294
+ env.reset()
295
+ # Get information from env
296
+ ...
297
+ # Chat with LLM
298
+ ...
299
+ # Modify the source code in place
300
+ ...
301
+ res, log = env.check_full()
302
+ if res:
303
+ # The bug is fixed successfully
304
+ cert = json.dumps(env.dump(log = messages), indent=2)
305
+ print(cert)
306
+ break
307
+ # Append the feedback into user prompts for the next iteration
308
+ messages.append(construct_user_prompt_from_feedback(log))
309
+ ```
310
+
311
+ I have drafted a poor [baseline](./examples/baseline.py) which is powered by [DeepSeek-R1](https://www.deepseek.com). This baseline implementation is only for reference purposes since I am neither an expert in LLM nor APR.
312
+
313
+ ### Rules
314
+
315
+ To claim that your APR tool successfully fixes a bug, please obey the following rules:
316
+ + Knowledge allowed to use:
317
+ + Any static content/ dynamic feedback provided by `lab_env.Environment`
318
+ + Any content in the LLVM source tree before the base commit
319
+ + Large language model trained with dataset before the knowledge cutoff date
320
+ + Any other content on the web created before the knowledge cutoff date
321
+ + `opt` with this patch passes both the given tests and the regression testsuite.
322
+
323
+ ## License
324
+
325
+ This project is licensed under the Apache License 2.0. Please see the [LICENSE](./LICENSE) for details.
326
+
327
+ Please cite this work with the following BibTex entry:
328
+ ```bibtex
329
+ @misc{llvm-apr-benchmark,
330
+ title = {LLVM APR Benchmark: A Large-Scale Automated Program Repair Benchmark of Real-World LLVM Middle-End Bugs},
331
+ url = {https://github.com/dtcxzyw/llvm-apr-benchmark},
332
+ author = {Yingwei Zheng},
333
+ year = {2025},
334
+ }
335
+ ```
dataset/100298.json ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "100298",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/100298",
4
+ "bug_type": "miscompilation",
5
+ "base_commit": "75642a00e15b722bdfb90726be31f1c8adaeb0c5",
6
+ "knowledge_cutoff": "2024-07-24T04:19:53Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/InstCombine"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "59eae919c938f890e9b9b4be8a3fa3cb1b11ed89",
12
+ "components": [
13
+ "ValueTracking"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/include/llvm/Analysis/SimplifyQuery.h": [
17
+ [
18
+ 130,
19
+ 135
20
+ ]
21
+ ],
22
+ "llvm/lib/Analysis/ValueTracking.cpp": [
23
+ [
24
+ 1435,
25
+ 1441
26
+ ],
27
+ [
28
+ 1468,
29
+ 1474
30
+ ],
31
+ [
32
+ 1546,
33
+ 1552
34
+ ],
35
+ [
36
+ 2329,
37
+ 2335
38
+ ],
39
+ [
40
+ 2943,
41
+ 2949
42
+ ],
43
+ [
44
+ 3509,
45
+ 3515
46
+ ],
47
+ [
48
+ 4001,
49
+ 4007
50
+ ],
51
+ [
52
+ 5909,
53
+ 5918
54
+ ]
55
+ ]
56
+ },
57
+ "bug_location_funcname": {
58
+ "llvm/include/llvm/Analysis/SimplifyQuery.h": [
59
+ "getWithCondContext"
60
+ ],
61
+ "llvm/lib/Analysis/ValueTracking.cpp": [
62
+ "ComputeNumSignBitsImpl",
63
+ "computeKnownBitsFromOperator",
64
+ "computeKnownFPClass",
65
+ "isKnownNonZeroFromOperator",
66
+ "isKnownToBeAPowerOfTwo",
67
+ "isNonEqualPHIs"
68
+ ]
69
+ }
70
+ },
71
+ "patch": "commit a87fbeb3a77a53ded341277c5b326f7696d47594\nAuthor: Yingwei Zheng <[email protected]>\nDate: Wed Jul 24 20:06:36 2024 +0800\n\n [ValueTracking] Don't use CondContext in dataflow analysis of phi nodes (#100316)\n \n See the following case:\n ```\n define i16 @pr100298() {\n entry:\n br label %for.inc\n \n for.inc:\n %indvar = phi i32 [ -15, %entry ], [ %mask, %for.inc ]\n %add = add nsw i32 %indvar, 9\n %mask = and i32 %add, 65535\n %cmp1 = icmp ugt i32 %mask, 5\n br i1 %cmp1, label %for.inc, label %for.end\n \n for.end:\n %conv = trunc i32 %add to i16\n %cmp2 = icmp ugt i32 %mask, 3\n %shl = shl nuw i16 %conv, 14\n %res = select i1 %cmp2, i16 %conv, i16 %shl\n ret i16 %res\n }\n ```\n \n When computing knownbits of `%shl` with `%cmp2=false`, we cannot use\n this condition in the analysis of `%mask (%for.inc -> %for.inc)`.\n \n Fixes https://github.com/llvm/llvm-project/issues/100298.\n \n (cherry picked from commit 59eae919c938f890e9b9b4be8a3fa3cb1b11ed89)\n\ndiff --git a/llvm/include/llvm/Analysis/SimplifyQuery.h b/llvm/include/llvm/Analysis/SimplifyQuery.h\nindex a560744f0122..e8f43c8c2e91 100644\n--- a/llvm/include/llvm/Analysis/SimplifyQuery.h\n+++ b/llvm/include/llvm/Analysis/SimplifyQuery.h\n@@ -130,6 +130,12 @@ struct SimplifyQuery {\n Copy.CC = &CC;\n return Copy;\n }\n+\n+ SimplifyQuery getWithoutCondContext() const {\n+ SimplifyQuery Copy(*this);\n+ Copy.CC = nullptr;\n+ return Copy;\n+ }\n };\n \n } // end namespace llvm\ndiff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp\nindex 40fe1ffe13f1..4b77c0046cc7 100644\n--- a/llvm/lib/Analysis/ValueTracking.cpp\n+++ b/llvm/lib/Analysis/ValueTracking.cpp\n@@ -1435,7 +1435,7 @@ static void computeKnownBitsFromOperator(const Operator *I,\n // inferred hold at original context instruction. TODO: It may be\n // correct to use the original context. IF warranted, explore and\n // add sufficient tests to cover.\n- SimplifyQuery RecQ = Q;\n+ SimplifyQuery RecQ = Q.getWithoutCondContext();\n RecQ.CxtI = P;\n computeKnownBits(R, DemandedElts, Known2, Depth + 1, RecQ);\n switch (Opcode) {\n@@ -1468,7 +1468,7 @@ static void computeKnownBitsFromOperator(const Operator *I,\n // phi. This is important because that is where the value is actually\n // \"evaluated\" even though it is used later somewhere else. (see also\n // D69571).\n- SimplifyQuery RecQ = Q;\n+ SimplifyQuery RecQ = Q.getWithoutCondContext();\n \n unsigned OpNum = P->getOperand(0) == R ? 0 : 1;\n Instruction *RInst = P->getIncomingBlock(OpNum)->getTerminator();\n@@ -1546,7 +1546,7 @@ static void computeKnownBitsFromOperator(const Operator *I,\n // phi. This is important because that is where the value is actually\n // \"evaluated\" even though it is used later somewhere else. (see also\n // D69571).\n- SimplifyQuery RecQ = Q;\n+ SimplifyQuery RecQ = Q.getWithoutCondContext();\n RecQ.CxtI = P->getIncomingBlock(u)->getTerminator();\n \n Known2 = KnownBits(BitWidth);\n@@ -2329,7 +2329,7 @@ bool isKnownToBeAPowerOfTwo(const Value *V, bool OrZero, unsigned Depth,\n // it is an induction variable where in each step its value is a power of\n // two.\n auto *PN = cast<PHINode>(I);\n- SimplifyQuery RecQ = Q;\n+ SimplifyQuery RecQ = Q.getWithoutCondContext();\n \n // Check if it is an induction variable and always power of two.\n if (isPowerOfTwoRecurrence(PN, OrZero, Depth, RecQ))\n@@ -2943,7 +2943,7 @@ static bool isKnownNonZeroFromOperator(const Operator *I,\n return true;\n \n // Check if all incoming values are non-zero using recursion.\n- SimplifyQuery RecQ = Q;\n+ SimplifyQuery RecQ = Q.getWithoutCondContext();\n unsigned NewDepth = std::max(Depth, MaxAnalysisRecursionDepth - 1);\n return llvm::all_of(PN->operands(), [&](const Use &U) {\n if (U.get() == PN)\n@@ -3509,7 +3509,7 @@ static bool isNonEqualPHIs(const PHINode *PN1, const PHINode *PN2,\n if (UsedFullRecursion)\n return false;\n \n- SimplifyQuery RecQ = Q;\n+ SimplifyQuery RecQ = Q.getWithoutCondContext();\n RecQ.CxtI = IncomBB->getTerminator();\n if (!isKnownNonEqual(IV1, IV2, DemandedElts, Depth + 1, RecQ))\n return false;\n@@ -4001,7 +4001,7 @@ static unsigned ComputeNumSignBitsImpl(const Value *V,\n \n // Take the minimum of all incoming values. This can't infinitely loop\n // because of our depth threshold.\n- SimplifyQuery RecQ = Q;\n+ SimplifyQuery RecQ = Q.getWithoutCondContext();\n Tmp = TyBits;\n for (unsigned i = 0, e = NumIncomingValues; i != e; ++i) {\n if (Tmp == 1) return Tmp;\n@@ -5909,10 +5909,10 @@ void computeKnownFPClass(const Value *V, const APInt &DemandedElts,\n // Recurse, but cap the recursion to two levels, because we don't want\n // to waste time spinning around in loops. We need at least depth 2 to\n // detect known sign bits.\n- computeKnownFPClass(\n- IncValue, DemandedElts, InterestedClasses, KnownSrc,\n- PhiRecursionLimit,\n- Q.getWithInstruction(P->getIncomingBlock(U)->getTerminator()));\n+ computeKnownFPClass(IncValue, DemandedElts, InterestedClasses, KnownSrc,\n+ PhiRecursionLimit,\n+ Q.getWithoutCondContext().getWithInstruction(\n+ P->getIncomingBlock(U)->getTerminator()));\n \n if (First) {\n Known = KnownSrc;\n",
72
+ "tests": [
73
+ {
74
+ "file": "llvm/test/Transforms/InstCombine/pr100298.ll",
75
+ "commands": [
76
+ "opt -S -passes=instcombine < %s"
77
+ ],
78
+ "tests": [
79
+ {
80
+ "test_name": "pr100298",
81
+ "test_body": "define i16 @pr100298() {\nentry:\n br label %for.inc\n\nfor.inc: ; preds = %for.inc, %entry\n %indvar = phi i32 [ -15, %entry ], [ %mask, %for.inc ]\n %add = add nsw i32 %indvar, 9\n %mask = and i32 %add, 65535\n %cmp1 = icmp ugt i32 %mask, 5\n br i1 %cmp1, label %for.inc, label %for.end\n\nfor.end: ; preds = %for.inc\n %conv = trunc i32 %add to i16\n %cmp2 = icmp ugt i32 %mask, 3\n %shl = shl nuw i16 %conv, 14\n %res = select i1 %cmp2, i16 %conv, i16 %shl\n ret i16 %res\n}\n"
82
+ }
83
+ ]
84
+ }
85
+ ],
86
+ "issue": {
87
+ "title": "Miscompilation at O3",
88
+ "body": "```\r\n#include \"csmith.h\"\r\nuint32_t a;\r\nint16_t c;\r\nvoid d() {\r\n for (a = -15; a >= 6; a = safe_add_func_uint16_t_u_u(a, 9))\r\n ;\r\n c = safe_lshift_func_int16_t_s_u(safe_lshift_func_uint16_t_u_s(a,14), 0);\r\n}\r\nint main() {\r\n d();\r\n printf(\"%d\\n\", c);\r\n return 0;\r\n}\r\n```\r\n\r\n```\r\ndtcxzyw@dtcxzyw:~/WorkSpace/Projects/compilers/LLVM/llvm-build$ gcc -O0 test.c -fsanitize=undefined -I/usr/include/csmith -w\r\ndtcxzyw@dtcxzyw:~/WorkSpace/Projects/compilers/LLVM/llvm-build$ ./a.out \r\n-16384\r\ndtcxzyw@dtcxzyw:~/WorkSpace/Projects/compilers/LLVM/llvm-build$ bin/clang -O3 test.c -I/usr/include/csmith -w\r\ndtcxzyw@dtcxzyw:~/WorkSpace/Projects/compilers/LLVM/llvm-build$ ./a.out \r\n0\r\n```\r\n\r\nllvm version: 2d6ff0c533aa1b0fe6d91764846f636c4a4e911c",
89
+ "author": "dtcxzyw",
90
+ "labels": [
91
+ "miscompilation",
92
+ "llvm:analysis"
93
+ ],
94
+ "comments": [
95
+ {
96
+ "author": "dtcxzyw",
97
+ "body": "Reduced testcase: https://alive2.llvm.org/ce/z/9fExrA\r\n```\r\n; bin/opt -passes=instcombine test.ll -S\r\ndefine i16 @src() {\r\nentry:\r\n br label %for.inc\r\n\r\nfor.inc:\r\n %storemerge6 = phi i32 [ -15, %entry ], [ %conv1, %for.inc ]\r\n %add.i = add nsw i32 %storemerge6, 9\r\n %conv1 = and i32 %add.i, 65535\r\n %cmp = icmp ugt i32 %conv1, 5\r\n br i1 %cmp, label %for.inc, label %for.end\r\n\r\nfor.end:\r\n %conv2 = trunc nuw nsw i32 %conv1 to i16\r\n %cmp3.i = icmp ugt i32 %conv1, 3\r\n %0 = shl nuw i16 %conv2, 14\r\n %cond.in.i = select i1 %cmp3.i, i16 %conv2, i16 %0\r\n ret i16 %cond.in.i\r\n}\r\n```"
98
+ }
99
+ ]
100
+ },
101
+ "verified": true
102
+ }
dataset/100464.json ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "100464",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/100464",
4
+ "bug_type": "crash",
5
+ "base_commit": "ba461f8c6278a7b2fd7695454c1f184c38897ecd",
6
+ "knowledge_cutoff": "2024-07-24T20:37:49Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/LoopVectorize"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "b72689a5cbd8645c183476cd87e32948308c5b64",
12
+ "components": [
13
+ "LoopVectorize"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
17
+ [
18
+ 6678,
19
+ 6683
20
+ ],
21
+ [
22
+ 6693,
23
+ 6700
24
+ ],
25
+ [
26
+ 6727,
27
+ 6742
28
+ ]
29
+ ]
30
+ },
31
+ "bug_location_funcname": {
32
+ "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
33
+ "LoopVectorizationCostModel::collectValuesToIgnore"
34
+ ]
35
+ }
36
+ },
37
+ "patch": "commit b72689a5cbd8645c183476cd87e32948308c5b64\nAuthor: Florian Hahn <[email protected]>\nDate: Thu Jul 25 11:16:09 2024 +0100\n\n [LV] Ignore live-out users in cost model if scalar epilogue is required.\n \n Follow-up to ba8126b6fef79.\n \n If a scalar epilogue is required, users outside the loop won't use\n live-outs from the vector loop but from the scalar epilogue. Ignore them if\n that is the case.\n \n This fixes another case where the VPlan-based cost-model more accurately\n computes cost.\n \n Fixes https://github.com/llvm/llvm-project/issues/100464.\n\ndiff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\nindex b709ccc3c35a..224d98d5c4f9 100644\n--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\n+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\n@@ -6678,6 +6678,15 @@ void LoopVectorizationCostModel::collectValuesToIgnore() {\n \n SmallVector<Value *, 4> DeadInterleavePointerOps;\n SmallVector<Value *, 4> DeadOps;\n+\n+ // If a scalar epilogue is required, users outside the loop won't use\n+ // live-outs from the vector loop but from the scalar epilogue. Ignore them if\n+ // that is the case.\n+ bool RequiresScalarEpilogue = requiresScalarEpilogue(true);\n+ auto IsLiveOutDead = [this, RequiresScalarEpilogue](User *U) {\n+ return RequiresScalarEpilogue &&\n+ !TheLoop->contains(cast<Instruction>(U)->getParent());\n+ };\n for (BasicBlock *BB : TheLoop->blocks())\n for (Instruction &I : *BB) {\n // Find all stores to invariant variables. Since they are going to sink\n@@ -6693,8 +6702,9 @@ void LoopVectorizationCostModel::collectValuesToIgnore() {\n // Add instructions that would be trivially dead and are only used by\n // values already ignored to DeadOps to seed worklist.\n if (wouldInstructionBeTriviallyDead(&I, TLI) &&\n- all_of(I.users(), [this](User *U) {\n- return VecValuesToIgnore.contains(U) || ValuesToIgnore.contains(U);\n+ all_of(I.users(), [this, IsLiveOutDead](User *U) {\n+ return VecValuesToIgnore.contains(U) ||\n+ ValuesToIgnore.contains(U) || IsLiveOutDead(U);\n }))\n DeadOps.push_back(&I);\n \n@@ -6727,16 +6737,22 @@ void LoopVectorizationCostModel::collectValuesToIgnore() {\n \n // Mark ops that would be trivially dead and are only used by ignored\n // instructions as free.\n+ BasicBlock *Header = TheLoop->getHeader();\n for (unsigned I = 0; I != DeadOps.size(); ++I) {\n auto *Op = dyn_cast<Instruction>(DeadOps[I]);\n // Skip any op that shouldn't be considered dead.\n if (!Op || !TheLoop->contains(Op) ||\n+ (isa<PHINode>(Op) && Op->getParent() == Header) ||\n !wouldInstructionBeTriviallyDead(Op, TLI) ||\n- any_of(Op->users(), [this](User *U) {\n- return !VecValuesToIgnore.contains(U) && !ValuesToIgnore.contains(U);\n+ any_of(Op->users(), [this, IsLiveOutDead](User *U) {\n+ return !VecValuesToIgnore.contains(U) && ValuesToIgnore.contains(U) &&\n+ !IsLiveOutDead(U);\n }))\n continue;\n \n+ if (!TheLoop->contains(Op->getParent()))\n+ continue;\n+\n // If all of Op's users are in ValuesToIgnore, add it to ValuesToIgnore\n // which applies for both scalar and vector versions. Otherwise it is only\n // dead in vector versions, so only add it to VecValuesToIgnore.\n",
38
+ "tests": [
39
+ {
40
+ "file": "llvm/test/Transforms/LoopVectorize/RISCV/dead-ops-cost.ll",
41
+ "commands": [
42
+ "opt -p loop-vectorize -mtriple riscv64-linux-gnu -mattr=+v,+f -S %s"
43
+ ],
44
+ "tests": [
45
+ {
46
+ "test_name": "dead_live_out_due_to_scalar_epilogue_required",
47
+ "test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\n\ndefine i8 @dead_live_out_due_to_scalar_epilogue_required(ptr %src, ptr %dst) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]\n %idxprom = sext i32 %iv to i64\n %gep.src = getelementptr i8, ptr %src, i64 %idxprom\n %l = load i8, ptr %gep.src, align 1\n %gep.dst = getelementptr i8, ptr %dst, i64 %idxprom\n store i8 0, ptr %gep.dst, align 1\n %iv.next = add i32 %iv, 4\n %cmp = icmp ult i32 %iv, 1001\n br i1 %cmp, label %loop, label %exit\n\nexit: ; preds = %loop\n %r = phi i8 [ %l, %loop ]\n ret i8 %r\n}\n"
48
+ },
49
+ {
50
+ "test_name": "dead_load",
51
+ "test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\n\ndefine void @dead_load(ptr %p, i16 %start) {\nentry:\n %start.ext = sext i16 %start to i64\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ %start.ext, %entry ], [ %iv.next, %loop ]\n %gep = getelementptr i16, ptr %p, i64 %iv\n store i16 0, ptr %gep, align 2\n %l = load i16, ptr %gep, align 2\n %iv.next = add i64 %iv, 3\n %cmp = icmp slt i64 %iv, 111\n br i1 %cmp, label %loop, label %exit\n\nexit: ; preds = %loop\n ret void\n}\n"
52
+ }
53
+ ]
54
+ },
55
+ {
56
+ "file": "llvm/test/Transforms/LoopVectorize/RISCV/riscv-vector-reverse.ll",
57
+ "commands": [
58
+ "opt -passes=loop-vectorize,dce,instcombine -mtriple riscv64-linux-gnu -mattr=+v -debug-only=loop-vectorize -scalable-vectorization=on -riscv-v-vector-bits-min=128 -disable-output < %s 2>&1"
59
+ ],
60
+ "tests": [
61
+ {
62
+ "test_name": "vector_reverse_i64",
63
+ "test_body": "define void @vector_reverse_i64(ptr nocapture noundef writeonly %A, ptr nocapture noundef readonly %B, i32 noundef signext %n) {\nentry:\n %cmp7 = icmp sgt i32 %n, 0\n br i1 %cmp7, label %for.body.preheader, label %for.cond.cleanup\n\nfor.body.preheader: ; preds = %entry\n %0 = zext i32 %n to i64\n br label %for.body\n\nfor.cond.cleanup: ; preds = %for.body, %entry\n ret void\n\nfor.body: ; preds = %for.body, %for.body.preheader\n %indvars.iv = phi i64 [ %0, %for.body.preheader ], [ %indvars.iv.next, %for.body ]\n %i.0.in8 = phi i32 [ %n, %for.body.preheader ], [ %i.0, %for.body ]\n %i.0 = add nsw i32 %i.0.in8, -1\n %idxprom = zext i32 %i.0 to i64\n %arrayidx = getelementptr inbounds i32, ptr %B, i64 %idxprom\n %1 = load i32, ptr %arrayidx, align 4\n %add9 = add i32 %1, 1\n %arrayidx3 = getelementptr inbounds i32, ptr %A, i64 %idxprom\n store i32 %add9, ptr %arrayidx3, align 4\n %cmp = icmp ugt i64 %indvars.iv, 1\n %indvars.iv.next = add nsw i64 %indvars.iv, -1\n br i1 %cmp, label %for.body, label %for.cond.cleanup, !llvm.loop !0\n}\n\n!0 = distinct !{!0, !1, !2, !3, !4}\n!1 = !{!\"llvm.loop.mustprogress\"}\n!2 = !{!\"llvm.loop.vectorize.width\", i32 4}\n!3 = !{!\"llvm.loop.vectorize.scalable.enable\", i1 true}\n!4 = !{!\"llvm.loop.vectorize.enable\", i1 true}\n"
64
+ },
65
+ {
66
+ "test_name": "vector_reverse_f32",
67
+ "test_body": "define void @vector_reverse_f32(ptr nocapture noundef writeonly %A, ptr nocapture noundef readonly %B, i32 noundef signext %n) {\nentry:\n %cmp7 = icmp sgt i32 %n, 0\n br i1 %cmp7, label %for.body.preheader, label %for.cond.cleanup\n\nfor.body.preheader: ; preds = %entry\n %0 = zext i32 %n to i64\n br label %for.body\n\nfor.cond.cleanup: ; preds = %for.body, %entry\n ret void\n\nfor.body: ; preds = %for.body, %for.body.preheader\n %indvars.iv = phi i64 [ %0, %for.body.preheader ], [ %indvars.iv.next, %for.body ]\n %i.0.in8 = phi i32 [ %n, %for.body.preheader ], [ %i.0, %for.body ]\n %i.0 = add nsw i32 %i.0.in8, -1\n %idxprom = zext i32 %i.0 to i64\n %arrayidx = getelementptr inbounds float, ptr %B, i64 %idxprom\n %1 = load float, ptr %arrayidx, align 4\n %conv1 = fadd float %1, 1.000000e+00\n %arrayidx3 = getelementptr inbounds float, ptr %A, i64 %idxprom\n store float %conv1, ptr %arrayidx3, align 4\n %cmp = icmp ugt i64 %indvars.iv, 1\n %indvars.iv.next = add nsw i64 %indvars.iv, -1\n br i1 %cmp, label %for.body, label %for.cond.cleanup, !llvm.loop !0\n}\n\n!0 = distinct !{!0, !1, !2, !3, !4}\n!1 = !{!\"llvm.loop.mustprogress\"}\n!2 = !{!\"llvm.loop.vectorize.width\", i32 4}\n!3 = !{!\"llvm.loop.vectorize.scalable.enable\", i1 true}\n!4 = !{!\"llvm.loop.vectorize.enable\", i1 true}\n"
68
+ }
69
+ ]
70
+ }
71
+ ],
72
+ "issue": {
73
+ "title": "[VPlan] VPlan cost model and legacy cost model disagreed",
74
+ "body": "Related: #99701, #92555. @fhahn Please let me know if you'd prefer these assert triggering testcases to be all in the same issue or prefer a new issue when a new testcase is found.\r\n\r\nTested using llvm f719a339a89b\r\n\r\nTestcase:\r\n```llvm ir\r\ntarget datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\r\ntarget triple = \"riscv64-unknown-linux-gnu\"\r\n\r\ndefine i32 @main(ptr %0) #0 {\r\nentry:\r\n br label %for.body\r\n\r\nfor.cond.cleanup: ; preds = %for.body\r\n %.lcssa = phi i8 [ %1, %for.body ]\r\n ret i32 0\r\n\r\nfor.body: ; preds = %for.body, %entry\r\n %l.011 = phi i32 [ 0, %entry ], [ %add, %for.body ]\r\n %idxprom = sext i32 %l.011 to i64\r\n %arrayidx1 = getelementptr [15 x i8], ptr %0, i64 0, i64 %idxprom\r\n %1 = load i8, ptr %arrayidx1, align 1\r\n %arrayidx3 = getelementptr [0 x i8], ptr null, i64 0, i64 %idxprom\r\n store i8 0, ptr %arrayidx3, align 1\r\n %add = add i32 %l.011, 4\r\n %cmp = icmp ult i32 %l.011, -9\r\n br i1 %cmp, label %for.body, label %for.cond.cleanup\r\n}\r\n\r\nattributes #0 = { \"target-features\"=\"+64bit,+a,+c,+d,+f,+m,+relax,+v,+zicsr,+zifencei,+zmmul,+zve32f,+zve32x,+zve64d,+zve64f,+zve64x,+zvl128b,+zvl32b,+zvl64b,-b,-e,-experimental-smmpm,-experimental-smnpm,-experimental-ssnpm,-experimental-sspm,-experimental-ssqosid,-experimental-supm,-experimental-zacas,-experimental-zalasr,-experimental-zicfilp,-experimental-zicfiss,-h,-shcounterenw,-shgatpa,-shtvala,-shvsatpa,-shvstvala,-shvstvecd,-smaia,-smcdeleg,-smcsrind,-smepmp,-smstateen,-ssaia,-ssccfg,-ssccptr,-sscofpmf,-sscounterenw,-sscsrind,-ssstateen,-ssstrict,-sstc,-sstvala,-sstvecd,-ssu64xl,-svade,-svadu,-svbare,-svinval,-svnapot,-svpbmt,-xcvalu,-xcvbi,-xcvbitmanip,-xcvelw,-xcvmac,-xcvmem,-xcvsimd,-xsfcease,-xsfvcp,-xsfvfnrclipxfqf,-xsfvfwmaccqqq,-xsfvqmaccdod,-xsfvqmaccqoq,-xsifivecdiscarddlone,-xsifivecflushdlone,-xtheadba,-xtheadbb,-xtheadbs,-xtheadcmo,-xtheadcondmov,-xtheadfmemidx,-xtheadmac,-xtheadmemidx,-xtheadmempair,-xtheadsync,-xtheadvdot,-xventanacondops,-xwchc,-za128rs,-za64rs,-zaamo,-zabha,-zalrsc,-zama16b,-zawrs,-zba,-zbb,-zbc,-zbkb,-zbkc,-zbkx,-zbs,-zca,-zcb,-zcd,-zce,-zcf,-zcmop,-zcmp,-zcmt,-zdinx,-zfa,-zfbfmin,-zfh,-zfhmin,-zfinx,-zhinx,-zhinxmin,-zic64b,-zicbom,-zicbop,-zicboz,-ziccamoa,-ziccif,-zicclsm,-ziccrse,-zicntr,-zicond,-zihintntl,-zihintpause,-zihpm,-zimop,-zk,-zkn,-zknd,-zkne,-zknh,-zkr,-zks,-zksed,-zksh,-zkt,-ztso,-zvbb,-zvbc,-zvfbfmin,-zvfbfwma,-zvfh,-zvfhmin,-zvkb,-zvkg,-zvkn,-zvknc,-zvkned,-zvkng,-zvknha,-zvknhb,-zvks,-zvksc,-zvksed,-zvksg,-zvksh,-zvkt,-zvl1024b,-zvl16384b,-zvl2048b,-zvl256b,-zvl32768b,-zvl4096b,-zvl512b,-zvl65536b,-zvl8192b\" }\r\n```\r\n\r\nCommand/backtrace:\r\n```\r\n> /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt -passes loop-vectorize reduced.ll -S\r\nopt: /scratch/tc-testing/tc-compiler-fuzz-trunk/llvm/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:10098: bool llvm::LoopVectorizePass::processLoop(llvm::Loop*): Assertion `VF.Width == Width && \"VPlan cost model and legacy cost model disagreed\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0. Program arguments: /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt -passes loop-vectorize reduced.ll -S\r\n1. Running pass \"function(loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>)\" on module \"reduced.ll\"\r\n2. Running pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"main\"\r\n #0 0x0000647de5790dd0 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2f1ddd0)\r\n #1 0x0000647de578e1ef llvm::sys::RunSignalHandlers() (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2f1b1ef)\r\n #2 0x0000647de578e345 SignalHandler(int) Signals.cpp:0:0\r\n #3 0x00007b2a02842520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #4 0x00007b2a028969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\r\n #5 0x00007b2a028969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10\r\n #6 0x00007b2a028969fc pthread_kill ./nptl/pthread_kill.c:89:10\r\n #7 0x00007b2a02842476 gsignal ./signal/../sysdeps/posix/raise.c:27:6\r\n #8 0x00007b2a028287f3 abort ./stdlib/abort.c:81:7\r\n #9 0x00007b2a0282871b _nl_load_domain ./intl/loadmsgcat.c:1177:9\r\n#10 0x00007b2a02839e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n#11 0x0000647de47acc98 llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1f39c98)\r\n#12 0x0000647de47af851 llvm::LoopVectorizePass::runImpl(llvm::Function&, llvm::ScalarEvolution&, llvm::LoopInfo&, llvm::TargetTransformInfo&, llvm::DominatorTree&, llvm::BlockFrequencyInfo*, llvm::TargetLibraryInfo*, llvm::DemandedBits&, llvm::AssumptionCache&, llvm::LoopAccessInfoManager&, llvm::OptimizationRemarkEmitter&, llvm::ProfileSummaryInfo*) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1f3c851)\r\n#13 0x0000647de47affd0 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1f3cfd0)\r\n#14 0x0000647de3621ff6 llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xdaeff6)\r\n#15 0x0000647de55a8e7e llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2d35e7e)\r\n#16 0x0000647de3625186 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xdb2186)\r\n#17 0x0000647de55a7c0b llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2d34c0b)\r\n#18 0x0000647de36214d6 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xdae4d6)\r\n#19 0x0000647de55a5d5d llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2d32d5d)\r\n#20 0x0000647de2e6b5d6 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x5f85d6)\r\n#21 0x0000647de2e5d211 optMain (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x5ea211)\r\n#22 0x00007b2a02829d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16\r\n#23 0x00007b2a02829e40 call_init ./csu/../csu/libc-start.c:128:20\r\n#24 0x00007b2a02829e40 __libc_start_main ./csu/../csu/libc-start.c:379:5\r\n#25 0x0000647de2e530a5 _start (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x5e00a5)\r\nzsh: IOT instruction (core dumped) /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt\r\n```\r\n\r\nGodbolt: https://godbolt.org/z/z7ee8hWWP",
75
+ "author": "patrick-rivos",
76
+ "labels": [
77
+ "vectorizers",
78
+ "crash"
79
+ ],
80
+ "comments": [
81
+ {
82
+ "author": "fhahn",
83
+ "body": "@patrick-rivos thanks for the report. I think it would be best to keep filing separate issues, as the underlying issues usually are different. Although the fuzzers may generate many instances of the same issue as was the case for https://github.com/llvm/llvm-project/issues/99701. Not sure if there's an easy way to catch that other than waiting for a day or so after filing the first issue."
84
+ }
85
+ ]
86
+ },
87
+ "verified": true
88
+ }
dataset/100591.json ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "100591",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/100591",
4
+ "bug_type": "crash",
5
+ "base_commit": "71801707e33c235656b172fa7dfb8662473a95c2",
6
+ "knowledge_cutoff": "2024-07-25T16:31:43Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/LoopVectorize"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "e9e3a183d6d8d8729223b7131aa57fd9f02f0440",
12
+ "components": [
13
+ "LoopVectorize"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
17
+ [
18
+ 6730,
19
+ 6738
20
+ ],
21
+ [
22
+ 6765,
23
+ 6770
24
+ ],
25
+ [
26
+ 6789,
27
+ 6796
28
+ ]
29
+ ]
30
+ },
31
+ "bug_location_funcname": {
32
+ "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
33
+ "LoopVectorizationCostModel::collectValuesToIgnore"
34
+ ]
35
+ }
36
+ },
37
+ "patch": "commit e9e3a183d6d8d8729223b7131aa57fd9f02f0440\nAuthor: Florian Hahn <[email protected]>\nDate: Sun Aug 18 12:51:17 2024 +0100\n\n [LV] Don't cost branches and conditions to empty blocks.\n \n Update the legacy cost model skip branches with successors blocks\n that are empty or only contain dead instructions, together with their\n conditions. Such branches and conditions won't result in any\n generated code and will be cleaned up by VPlan transforms.\n \n This fixes a difference between the legacy and VPlan-based cost model.\n \n When running LV in its usual pipeline position, such dead blocks should\n already have been cleaned up, but they might be generated manually or by\n fuzzers.\n \n Fixes https://github.com/llvm/llvm-project/issues/100591.\n\ndiff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\nindex 27e99694aafd..55c0ba3dd8f9 100644\n--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\n+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\n@@ -6730,9 +6730,12 @@ void LoopVectorizationCostModel::collectValuesToIgnore() {\n return RequiresScalarEpilogue &&\n !TheLoop->contains(cast<Instruction>(U)->getParent());\n };\n+\n+ LoopBlocksDFS DFS(TheLoop);\n+ DFS.perform(LI);\n MapVector<Value *, SmallVector<Value *>> DeadInvariantStoreOps;\n- for (BasicBlock *BB : TheLoop->blocks())\n- for (Instruction &I : *BB) {\n+ for (BasicBlock *BB : reverse(make_range(DFS.beginRPO(), DFS.endRPO())))\n+ for (Instruction &I : reverse(*BB)) {\n // Find all stores to invariant variables. Since they are going to sink\n // outside the loop we do not need calculate cost for them.\n StoreInst *SI;\n@@ -6765,6 +6768,13 @@ void LoopVectorizationCostModel::collectValuesToIgnore() {\n Value *PointerOp = getLoadStorePointerOperand(&I);\n DeadInterleavePointerOps.push_back(PointerOp);\n }\n+\n+ // Queue branches for analysis. They are dead, if their successors only\n+ // contain dead instructions.\n+ if (auto *Br = dyn_cast<BranchInst>(&I)) {\n+ if (Br->isConditional())\n+ DeadOps.push_back(&I);\n+ }\n }\n \n // Mark ops feeding interleave group members as free, if they are only used\n@@ -6789,8 +6799,36 @@ void LoopVectorizationCostModel::collectValuesToIgnore() {\n // Mark ops that would be trivially dead and are only used by ignored\n // instructions as free.\n BasicBlock *Header = TheLoop->getHeader();\n+\n+ // Returns true if the block contains only dead instructions. Such blocks will\n+ // be removed by VPlan-to-VPlan transforms and won't be considered by the\n+ // VPlan-based cost model, so skip them in the legacy cost-model as well.\n+ auto IsEmptyBlock = [this](BasicBlock *BB) {\n+ return all_of(*BB, [this](Instruction &I) {\n+ return ValuesToIgnore.contains(&I) || VecValuesToIgnore.contains(&I) ||\n+ (isa<BranchInst>(&I) && !cast<BranchInst>(&I)->isConditional());\n+ });\n+ };\n for (unsigned I = 0; I != DeadOps.size(); ++I) {\n auto *Op = dyn_cast<Instruction>(DeadOps[I]);\n+\n+ // Check if the branch should be considered dead.\n+ if (auto *Br = dyn_cast_or_null<BranchInst>(Op)) {\n+ BasicBlock *ThenBB = Br->getSuccessor(0);\n+ BasicBlock *ElseBB = Br->getSuccessor(1);\n+ bool ThenEmpty = IsEmptyBlock(ThenBB);\n+ bool ElseEmpty = IsEmptyBlock(ElseBB);\n+ if ((ThenEmpty && ElseEmpty) ||\n+ (ThenEmpty && ThenBB->getSingleSuccessor() == ElseBB &&\n+ ElseBB->phis().empty()) ||\n+ (ElseEmpty && ElseBB->getSingleSuccessor() == ThenBB &&\n+ ThenBB->phis().empty())) {\n+ VecValuesToIgnore.insert(Br);\n+ DeadOps.push_back(Br->getCondition());\n+ }\n+ continue;\n+ }\n+\n // Skip any op that shouldn't be considered dead.\n if (!Op || !TheLoop->contains(Op) ||\n (isa<PHINode>(Op) && Op->getParent() == Header) ||\n",
38
+ "tests": [
39
+ {
40
+ "file": "llvm/test/Transforms/LoopVectorize/RISCV/blocks-with-dead-instructions.ll",
41
+ "commands": [
42
+ "opt -p loop-vectorize -S %s"
43
+ ],
44
+ "tests": [
45
+ {
46
+ "test_name": "block_with_dead_inst_1",
47
+ "test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\ndefine void @block_with_dead_inst_1(ptr %src, i64 %N) #0 {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %xor1315 = phi i16 [ 1, %entry ], [ %xor, %loop.latch ]\n %xor = xor i16 0, 0\n %gep = getelementptr i16, ptr %src, i64 %iv\n %l = load i16, ptr %gep, align 2\n %c = icmp eq i16 %l, 0\n br i1 %c, label %then, label %loop.latch\n\nthen: ; preds = %loop.header\n %dead.gep = getelementptr i64, ptr %src, i64 %iv\n br label %loop.latch\n\nloop.latch: ; preds = %then, %loop.header\n store i16 %xor, ptr %gep, align 2\n %iv.next = add nsw i64 %iv, 3\n %0 = icmp eq i64 %iv.next, %N\n br i1 %0, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+64bit,+v\" }\n"
48
+ },
49
+ {
50
+ "test_name": "multiple_blocks_with_dead_insts_4",
51
+ "test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\ndefine void @multiple_blocks_with_dead_insts_4(ptr %src, i64 %N) #0 {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %xor1315 = phi i16 [ 1, %entry ], [ %xor, %loop.latch ]\n %xor = xor i16 0, 0\n %gep = getelementptr i16, ptr %src, i64 %iv\n %l = load i16, ptr %gep, align 2\n %c = icmp eq i16 %l, 0\n br i1 %c, label %then, label %else\n\nthen: ; preds = %loop.header\n br label %then.1\n\nthen.1: ; preds = %then\n %dead.gep.1 = getelementptr i64, ptr %src, i64 %iv\n br label %loop.latch\n\nelse: ; preds = %loop.header\n %dead.gep.2 = getelementptr i64, ptr %src, i64 %iv\n br label %loop.latch\n\nloop.latch: ; preds = %else, %then.1\n store i16 %xor, ptr %gep, align 2\n %iv.next = add nsw i64 %iv, 3\n %ec = icmp eq i64 %iv.next, %N\n br i1 %ec, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+64bit,+v\" }\n"
52
+ },
53
+ {
54
+ "test_name": "empty_block_with_phi_1",
55
+ "test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\ndefine void @empty_block_with_phi_1(ptr %src, i64 %N) #0 {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %xor1315 = phi i32 [ 1, %entry ], [ %xor, %loop.latch ]\n %xor = xor i32 0, 0\n %gep = getelementptr i16, ptr %src, i64 %iv\n %l = load i16, ptr %gep, align 2\n %c = icmp eq i16 %l, 0\n br i1 %c, label %then, label %loop.latch\n\nthen: ; preds = %loop.header\n br label %loop.latch\n\nloop.latch: ; preds = %then, %loop.header\n %p = phi i16 [ %l, %loop.header ], [ 99, %then ]\n store i16 %p, ptr %gep, align 2\n %iv.next = add nsw i64 %iv, 1\n %0 = icmp eq i64 %iv.next, %N\n br i1 %0, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+64bit,+v\" }\n"
56
+ },
57
+ {
58
+ "test_name": "multiple_blocks_with_dead_insts_3",
59
+ "test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\ndefine void @multiple_blocks_with_dead_insts_3(ptr %src) #0 {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %xor1315 = phi i16 [ 0, %entry ], [ %xor, %loop.latch ]\n %xor = xor i16 0, 0\n %gep = getelementptr i16, ptr %src, i64 %iv\n %l = load i16, ptr %gep, align 2\n %c = icmp eq i16 %l, 0\n br i1 %c, label %then, label %else\n\nthen: ; preds = %loop.header\n %dead.gep.1 = getelementptr i64, ptr %src, i64 %iv\n br label %loop.latch\n\nelse: ; preds = %loop.header\n %dead.gep.2 = getelementptr i64, ptr %src, i64 %iv\n br label %loop.latch\n\nloop.latch: ; preds = %else, %then\n store i16 %xor, ptr %gep, align 2\n %iv.next = add nsw i64 %iv, 3\n %ec = icmp eq i64 %iv.next, 1000\n br i1 %ec, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+64bit,+v\" }\n"
60
+ },
61
+ {
62
+ "test_name": "multiple_blocks_with_dead_inst_multiple_successors_5",
63
+ "test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\ndefine void @multiple_blocks_with_dead_inst_multiple_successors_5(ptr %src) #0 {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %xor1315 = phi i16 [ 1, %entry ], [ %xor, %loop.latch ]\n %xor = xor i16 0, 0\n %gep = getelementptr i16, ptr %src, i64 %iv\n %l = load i16, ptr %gep, align 2\n %c = icmp eq i16 %l, 0\n br i1 %c, label %then, label %else\n\nthen: ; preds = %loop.header\n br label %then.1\n\nthen.1: ; preds = %then\n %dead.gep.1 = getelementptr i64, ptr %src, i64 %iv\n br label %loop.latch\n\nelse: ; preds = %loop.header\n br label %else.2\n\nelse.2: ; preds = %else\n %dead.gep.2 = getelementptr i64, ptr %src, i64 %iv\n br label %loop.latch\n\nloop.latch: ; preds = %else.2, %then.1\n store i16 %xor, ptr %gep, align 2\n %iv.next = add nsw i64 %iv, 3\n %ec = icmp eq i64 %iv.next, 1000\n br i1 %ec, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+64bit,+v\" }\n"
64
+ },
65
+ {
66
+ "test_name": "multiple_blocks_with_dead_inst_multiple_successors_6",
67
+ "test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\ndefine void @multiple_blocks_with_dead_inst_multiple_successors_6(ptr %src, i1 %ic, i64 %N) #0 {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %xor1315 = phi i16 [ 1, %entry ], [ %xor, %loop.latch ]\n %xor = xor i16 0, 0\n %gep = getelementptr i16, ptr %src, i64 %iv\n %l = load i16, ptr %gep, align 2\n %c = icmp eq i16 %l, 0\n br i1 %c, label %then, label %else\n\nthen: ; preds = %loop.header\n br i1 %ic, label %then.1, label %else\n\nthen.1: ; preds = %then\n %dead.gep.1 = getelementptr i64, ptr %src, i64 %iv\n br label %loop.latch\n\nelse: ; preds = %then, %loop.header\n br label %else.2\n\nelse.2: ; preds = %else\n %dead.gep.2 = getelementptr i64, ptr %src, i64 %iv\n br label %loop.latch\n\nloop.latch: ; preds = %else.2, %then.1\n store i16 %xor, ptr %gep, align 2\n %iv.next = add nsw i64 %iv, 3\n %ec = icmp eq i64 %iv.next, %N\n br i1 %ec, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+64bit,+v\" }\n"
68
+ },
69
+ {
70
+ "test_name": "empty_block_with_phi_2",
71
+ "test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\ndefine void @empty_block_with_phi_2(ptr %src, i64 %N) #0 {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %xor1315 = phi i32 [ 1, %entry ], [ %xor, %loop.latch ]\n %xor = xor i32 0, 0\n %gep = getelementptr i16, ptr %src, i64 %iv\n %l = load i16, ptr %gep, align 2\n %c = icmp eq i16 %l, 0\n br i1 %c, label %loop.latch, label %else\n\nelse: ; preds = %loop.header\n br label %loop.latch\n\nloop.latch: ; preds = %else, %loop.header\n %p = phi i16 [ %l, %loop.header ], [ 99, %else ]\n store i16 %p, ptr %gep, align 2\n %iv.next = add nsw i64 %iv, 1\n %0 = icmp eq i64 %iv.next, %N\n br i1 %0, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+64bit,+v\" }\n"
72
+ },
73
+ {
74
+ "test_name": "block_with_dead_inst_2",
75
+ "test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\ndefine void @block_with_dead_inst_2(ptr %src) #0 {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %xor1315 = phi i16 [ 0, %entry ], [ %xor, %loop.latch ]\n %xor = xor i16 0, 0\n %gep = getelementptr i16, ptr %src, i64 %iv\n %l = load i16, ptr %gep, align 2\n %c = icmp eq i16 %l, 0\n br i1 %c, label %loop.latch, label %else\n\nelse: ; preds = %loop.header\n %dead.gep = getelementptr i64, ptr %src, i64 %iv\n br label %loop.latch\n\nloop.latch: ; preds = %else, %loop.header\n store i16 %xor, ptr %gep, align 2\n %iv.next = add nsw i64 %iv, 3\n %ec = icmp eq i64 %iv.next, 1000\n br i1 %ec, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+64bit,+v\" }\n"
76
+ }
77
+ ]
78
+ }
79
+ ],
80
+ "issue": {
81
+ "title": "[VPlan] Assertion `VF.Width == Width && \"VPlan cost model and legacy cost model disagreed\"' failed.",
82
+ "body": "Tested using 51d4980a133db12888207698e39c469cb7055cac\r\n\r\nTestcase:\r\n```llvm ir\r\ntarget datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\r\ntarget triple = \"riscv64-unknown-linux-gnu\"\r\n\r\ndefine void @f() #0 {\r\nentry:\r\n br label %for.body\r\n\r\nfor.cond.cleanup: ; preds = %cond.end7\r\n ret void\r\n\r\nfor.body: ; preds = %cond.end7, %entry\r\n %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %cond.end7 ]\r\n %xor1315 = phi i32 [ 0, %entry ], [ %xor, %cond.end7 ]\r\n %xor = xor i32 0, 0\r\n %arrayidx = getelementptr [1 x i16], ptr null, i64 0, i64 %indvars.iv\r\n %0 = load i16, ptr %arrayidx, align 2\r\n %tobool1.not = icmp eq i16 %0, 0\r\n br i1 %tobool1.not, label %cond.false, label %cond.end7\r\n\r\ncond.false: ; preds = %for.body\r\n %arrayidx3 = getelementptr [1 x i64], ptr null, i64 0, i64 %indvars.iv\r\n br label %cond.end7\r\n\r\ncond.end7: ; preds = %cond.false, %for.body\r\n %indvars.iv.next = add nsw i64 %indvars.iv, 3\r\n %1 = icmp eq i64 %indvars.iv.next, 0\r\n br i1 %1, label %for.cond.cleanup, label %for.body\r\n}\r\n\r\nattributes #0 = { \"target-features\"=\"+64bit,+a,+c,+d,+f,+m,+relax,+v,+zicsr,+zifencei,+zmmul,+zve32f,+zve32x,+zve64d,+zve64f,+zve64x,+zvl128b,+zvl32b,+zvl64b,-b,-e,-experimental-smmpm,-experimental-smnpm,-experimental-ssnpm,-experimental-sspm,-experimental-ssqosid,-experimental-supm,-experimental-zacas,-experimental-zalasr,-experimental-zicfilp,-experimental-zicfiss,-h,-shcounterenw,-shgatpa,-shtvala,-shvsatpa,-shvstvala,-shvstvecd,-smaia,-smcdeleg,-smcsrind,-smepmp,-smstateen,-ssaia,-ssccfg,-ssccptr,-sscofpmf,-sscounterenw,-sscsrind,-ssstateen,-ssstrict,-sstc,-sstvala,-sstvecd,-ssu64xl,-svade,-svadu,-svbare,-svinval,-svnapot,-svpbmt,-xcvalu,-xcvbi,-xcvbitmanip,-xcvelw,-xcvmac,-xcvmem,-xcvsimd,-xsfcease,-xsfvcp,-xsfvfnrclipxfqf,-xsfvfwmaccqqq,-xsfvqmaccdod,-xsfvqmaccqoq,-xsifivecdiscarddlone,-xsifivecflushdlone,-xtheadba,-xtheadbb,-xtheadbs,-xtheadcmo,-xtheadcondmov,-xtheadfmemidx,-xtheadmac,-xtheadmemidx,-xtheadmempair,-xtheadsync,-xtheadvdot,-xventanacondops,-xwchc,-za128rs,-za64rs,-zaamo,-zabha,-zalrsc,-zama16b,-zawrs,-zba,-zbb,-zbc,-zbkb,-zbkc,-zbkx,-zbs,-zca,-zcb,-zcd,-zce,-zcf,-zcmop,-zcmp,-zcmt,-zdinx,-zfa,-zfbfmin,-zfh,-zfhmin,-zfinx,-zhinx,-zhinxmin,-zic64b,-zicbom,-zicbop,-zicboz,-ziccamoa,-ziccif,-zicclsm,-ziccrse,-zicntr,-zicond,-zihintntl,-zihintpause,-zihpm,-zimop,-zk,-zkn,-zknd,-zkne,-zknh,-zkr,-zks,-zksed,-zksh,-zkt,-ztso,-zvbb,-zvbc,-zvfbfmin,-zvfbfwma,-zvfh,-zvfhmin,-zvkb,-zvkg,-zvkn,-zvknc,-zvkned,-zvkng,-zvknha,-zvknhb,-zvks,-zvksc,-zvksed,-zvksg,-zvksh,-zvkt,-zvl1024b,-zvl16384b,-zvl2048b,-zvl256b,-zvl32768b,-zvl4096b,-zvl512b,-zvl65536b,-zvl8192b\" }\r\n```\r\n\r\nBacktrace:\r\n```\r\n> /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt -passes loop-vectorize reduced.ll -S\r\nopt: /scratch/tc-testing/tc-compiler-fuzz-trunk/llvm/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:10123: bool llvm::LoopVectorizePass::processLoop(llvm::Loop*): Assertion `VF.Width == Width && \"VPlan cost model and legacy cost model disagreed\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0. Program arguments: /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt -passes loop-vectorize reduced.ll -S\r\n1. Running pass \"function(loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>)\" on module \"reduced.ll\"\r\n2. Running pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"f\"\r\n #0 0x00005e0a0dd8f3b0 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2f1f3b0)\r\n #1 0x00005e0a0dd8c7cf llvm::sys::RunSignalHandlers() (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2f1c7cf)\r\n #2 0x00005e0a0dd8c925 SignalHandler(int) Signals.cpp:0:0\r\n #3 0x000073a243a42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #4 0x000073a243a969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\r\n #5 0x000073a243a969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10\r\n #6 0x000073a243a969fc pthread_kill ./nptl/pthread_kill.c:89:10\r\n #7 0x000073a243a42476 gsignal ./signal/../sysdeps/posix/raise.c:27:6\r\n #8 0x000073a243a287f3 abort ./stdlib/abort.c:81:7\r\n #9 0x000073a243a2871b _nl_load_domain ./intl/loadmsgcat.c:1177:9\r\n#10 0x000073a243a39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n#11 0x00005e0a0cdaadd8 llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1f3add8)\r\n#12 0x00005e0a0cdad991 llvm::LoopVectorizePass::runImpl(llvm::Function&, llvm::ScalarEvolution&, llvm::LoopInfo&, llvm::TargetTransformInfo&, llvm::DominatorTree&, llvm::BlockFrequencyInfo*, llvm::TargetLibraryInfo*, llvm::DemandedBits&, llvm::AssumptionCache&, llvm::LoopAccessInfoManager&, llvm::OptimizationRemarkEmitter&, llvm::ProfileSummaryInfo*) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1f3d991)\r\n#13 0x00005e0a0cdae110 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1f3e110)\r\n#14 0x00005e0a0bc1fda6 llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xdafda6)\r\n#15 0x00005e0a0dba750e llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2d3750e)\r\n#16 0x00005e0a0bc22f36 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xdb2f36)\r\n#17 0x00005e0a0dba629b llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2d3629b)\r\n#18 0x00005e0a0bc1f286 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xdaf286)\r\n#19 0x00005e0a0dba43ed llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2d343ed)\r\n#20 0x00005e0a0b4686b6 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x5f86b6)\r\n#21 0x00005e0a0b45a2f1 optMain (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x5ea2f1)\r\n#22 0x000073a243a29d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16\r\n#23 0x000073a243a29e40 call_init ./csu/../csu/libc-start.c:128:20\r\n#24 0x000073a243a29e40 __libc_start_main ./csu/../csu/libc-start.c:379:5\r\n#25 0x00005e0a0b450185 _start (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x5e0185)\r\nzsh: IOT instruction (core dumped) /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt\r\n```\r\n\r\nGodbolt: https://godbolt.org/z/TnYreKbqn\r\n\r\n@fhahn \r\n\r\nFound via fuzzer.",
83
+ "author": "patrick-rivos",
84
+ "labels": [
85
+ "vectorizers",
86
+ "crash"
87
+ ],
88
+ "comments": [
89
+ {
90
+ "author": "fhahn",
91
+ "body": "Another case with dead instructions that get simplified by VPlan-DCE :/"
92
+ },
93
+ {
94
+ "author": "patrick-rivos",
95
+ "body": "Just to add a bit of context here: I'm hitting this assertion >300 times a day so I've allowlisted it in the fuzzer I run. There are likely other interesting cases where this assertion triggers but I don't have the bandwidth to deduplicate this failure to pull out those cases. :-("
96
+ },
97
+ {
98
+ "author": "preames",
99
+ "body": "> Just to add a bit of context here: I'm hitting this assertion >300 times a day so I've allowlisted it in the fuzzer I run. There are likely other interesting cases where this assertion triggers but I don't have the bandwidth to deduplicate this failure to pull out those cases. :-(\r\n\r\n@fhahn This assertion is triggering in a large number of fuzzer runs, and we have some reason to believe there are other failures be masked by this one. (We have at least one instance of this found so far by accident.) This needs to be either fixed or reverted so that tree is green. "
100
+ },
101
+ {
102
+ "author": "fhahn",
103
+ "body": "Will look into a fix now that I'm back. The crash should not reproduce with `opt -passes='instcombine,simplifycfg,loop-vectorize'` for all instances of the same underlying issue."
104
+ },
105
+ {
106
+ "author": "nikic",
107
+ "body": "@fhahn I feel like at this point this assertion is doing a lot more harm than good. It's very fragile, and doesn't seem to help in finding any genuine bugs, just incidental differences in simplification power."
108
+ },
109
+ {
110
+ "author": "artagnon",
111
+ "body": "I was also looking into this bug briefly, but couldn't quite figure out why we didn't choose to rip out the legacy costing."
112
+ },
113
+ {
114
+ "author": "sjoerdmeijer",
115
+ "body": "If e9e3a183d6d8d8729223b7131aa57fd9f02f0440 was supposed to fix this, then I can confirm I am still seeing this assert. \r\n\r\nIf this is indeed something else or new, then I agree with @nikic that this assert is too fragile."
116
+ },
117
+ {
118
+ "author": "fhahn",
119
+ "body": "The assertion originally surfaced real differences that needed fixing; the fuzzer-generated issues over the last weeks mostly were due to unsimplified input, which is very difficult to completely match without actually iteratively simplifying. Seeing the recent https://github.com/llvm/llvm-project/issues/104714 with a C reproducer it was a bit surprising that dead loads (and subsequent dead blocks/conditions) survive until LoopVectorize in the default pipeline.\r\n\r\nThere will be a number of code changes over the next few weeks/months which may introduce unintended divergences the assert is supposed to catch. For that reason it would be beneficial to keep the assert.\r\n\r\nIdeally we would only check if no extra simplifications have been applied on the selected VPlan, which should be possible to check once #103033 lands.\r\n\r\nWe could also guard it with an option, similar to InstCombine's fix point iteration assertion, which can also trigger asserts by default on valid IR input.\r\n\r\n> If [e9e3a18](https://github.com/llvm/llvm-project/commit/e9e3a183d6d8d8729223b7131aa57fd9f02f0440) was supposed to fix this, then I can confirm I am still seeing this assert.\r\n> \r\n\r\nCould you share the reproducer somewhere? Would be good to check if this is due to the simplification issue mentioned above or a genuine divergence"
120
+ },
121
+ {
122
+ "author": "sjoerdmeijer",
123
+ "body": "> Could you share the reproducer somewhere? Would be good to check if this is due to the simplification issue mentioned above or a genuine divergence\r\n\r\nThis runs in the same assert with `opt -S -passes=loop-vectorize`: \r\n\r\n```\r\ntarget datalayout = \"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32\"\r\ntarget triple = \"aarch64-unknown-linux-gnu\"\r\n\r\ndefine void @foo() #0 {\r\nentry:\r\n br label %for.body315.us.us\r\n\r\nfor.body315.us.us: ; preds = %cond.end388.us.us, %entry\r\n %indvars.iv10421 = phi i64 [ %indvars.iv.next1043, %cond.end388.us.us ], [ 0, %entry ]\r\n br i1 false, label %cond.end388.us.us, label %cond.true380.us.us\r\n\r\ncond.true380.us.us: ; preds = %for.body315.us.us\r\n %0 = load i32, ptr null, align 4\r\n br label %cond.end388.us.us\r\n\r\ncond.end388.us.us: ; preds = %cond.true380.us.us, %for.body315.us.us\r\n %indvars.iv.next1043 = add i64 %indvars.iv10421, 1\r\n %cmp313.us.us = icmp slt i64 %indvars.iv10421, 1\r\n br i1 %cmp313.us.us, label %for.body315.us.us, label %for.cond311.for.cond.cleanup314_crit_edge.loopexit, !llvm.loop !0\r\n\r\nfor.cond311.for.cond.cleanup314_crit_edge.loopexit: ; preds = %cond.end388.us.us\r\n ret void\r\n}\r\n\r\nattributes #0 = { \"target-cpu\"=\"neoverse-v2\" }\r\n\r\n!0 = distinct !{!0, !1, !2, !3}\r\n!1 = !{!\"llvm.loop.mustprogress\"}\r\n!2 = !{!\"llvm.loop.vectorize.predicate.enable\", i1 true}\r\n!3 = !{!\"llvm.loop.vectorize.enable\", i1 true}\r\n```"
124
+ }
125
+ ]
126
+ },
127
+ "verified": true
128
+ }
dataset/101213.json ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "101213",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/101213",
4
+ "bug_type": "crash",
5
+ "base_commit": "8364a6e108faea1a6f05f7bb53720a6fc101fed2",
6
+ "knowledge_cutoff": "2024-07-30T18:00:09Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/SLPVectorizer"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "f70f1228035c9610de38e0e376afdacb647c4ad9",
12
+ "components": [
13
+ "SLPVectorizer"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
17
+ [
18
+ 13909,
19
+ 13919
20
+ ]
21
+ ]
22
+ },
23
+ "bug_location_funcname": {
24
+ "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
25
+ "BoUpSLP::vectorizeTree"
26
+ ]
27
+ }
28
+ },
29
+ "patch": "commit f70f1228035c9610de38e0e376afdacb647c4ad9\nAuthor: Alexey Bataev <[email protected]>\nDate: Tue Jul 30 14:02:51 2024 -0700\n\n [SLP]Fix PR101213: Reuse extractelement, only if its vector operand comes before new vector value.\n \n When trying to reuse extractelement instruction, need to check that it\n is inserted into proper position. Its original vector operand should\n come before new vector value, otherwise new extractelement instruction\n must be generated.\n \n Fixes https://github.com/llvm/llvm-project/issues/101213\n\ndiff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\nindex 6501a14d8778..cf87b8621027 100644\n--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n@@ -13909,11 +13909,16 @@ Value *BoUpSLP::vectorizeTree(\n }\n if (!Ex) {\n // \"Reuse\" the existing extract to improve final codegen.\n- if (auto *ES = dyn_cast<ExtractElementInst>(Scalar)) {\n+ if (auto *ES = dyn_cast<ExtractElementInst>(Scalar);\n+ ES && isa<Instruction>(Vec)) {\n Value *V = ES->getVectorOperand();\n if (const TreeEntry *ETE = getTreeEntry(V))\n V = ETE->VectorizedValue;\n- Ex = Builder.CreateExtractElement(V, ES->getIndexOperand());\n+ if (auto *IV = dyn_cast<Instruction>(V);\n+ !IV || IV == Vec || IV->comesBefore(cast<Instruction>(Vec)))\n+ Ex = Builder.CreateExtractElement(V, ES->getIndexOperand());\n+ else\n+ Ex = Builder.CreateExtractElement(Vec, Lane);\n } else if (ReplaceGEP) {\n // Leave the GEPs as is, they are free in most cases and better to\n // keep them as GEPs.\n",
30
+ "tests": [
31
+ {
32
+ "file": "llvm/test/Transforms/SLPVectorizer/X86/extract-vectorized-operand.ll",
33
+ "commands": [
34
+ "opt -S --passes=slp-vectorizer -slp-threshold=-99999 < %s -mtriple=x86_64-unknown-linux-gnu"
35
+ ],
36
+ "tests": [
37
+ {
38
+ "test_name": "test",
39
+ "test_body": "define void @test() {\nbb:\n %0 = shufflevector <2 x ptr addrspace(1)> zeroinitializer, <2 x ptr addrspace(1)> zeroinitializer, <2 x i32> <i32 1, i32 0>\n %1 = extractelement <2 x ptr addrspace(1)> %0, i32 0\n %2 = extractelement <2 x ptr addrspace(1)> %0, i32 1\n br label %bb43\n\nbb20: ; No predecessors!\n br label %bb105\n\nbb43: ; preds = %bb51, %bb\n %phi441 = phi ptr addrspace(1) [ %4, %bb51 ], [ %2, %bb ]\n %phi452 = phi ptr addrspace(1) [ %5, %bb51 ], [ %1, %bb ]\n br i1 false, label %bb105, label %bb51\n\nbb51: ; preds = %bb54, %bb43\n %3 = phi <2 x ptr addrspace(1)> [ poison, %bb54 ], [ zeroinitializer, %bb43 ]\n %4 = extractelement <2 x ptr addrspace(1)> %3, i32 0\n %5 = extractelement <2 x ptr addrspace(1)> %3, i32 1\n br label %bb43\n\nbb54: ; No predecessors!\n br label %bb51\n\nbb105: ; preds = %bb43, %bb20\n %phi106 = phi ptr addrspace(1) [ %1, %bb20 ], [ null, %bb43 ]\n ret void\n}\n"
40
+ }
41
+ ]
42
+ }
43
+ ],
44
+ "issue": {
45
+ "title": "[SLPVectorizer] Instruction does not dominate all uses! LLVM ERROR: Broken module found, compilation aborted!",
46
+ "body": "To reproduce run the following test with -passes slp-vectorizer -slp-threshold=-99999\r\n[Test.ll.tgz](https://github.com/user-attachments/files/16431764/Test.ll.tgz)\r\n\r\nReproducer : https://godbolt.org/z/GW41a7WP6\r\n\r\nStack dump:\r\n```\r\nInstruction does not dominate all uses!\r\n %2 = shufflevector <2 x ptr addrspace(1)> %0, <2 x ptr addrspace(1)> poison, <2 x i32> <i32 1, i32 0>\r\n %1 = extractelement <2 x ptr addrspace(1)> %2, i32 0\r\nLLVM ERROR: Broken module found, compilation aborted!\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes slp-vectorizer -slp-threshold=-99999 <source>\r\n1.\tRunning pass \"verify\" on module \"<source>\"\r\n #0 0x0000000004eff778 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4eff778)\r\n #1 0x0000000004efceec SignalHandler(int) Signals.cpp:0:0\r\n #2 0x00007c0269e42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #3 0x00007c0269e969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\r\n #4 0x00007c0269e42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\r\n #5 0x00007c0269e287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\r\n #6 0x00000000007b3ff7 llvm::json::operator==(llvm::json::Value const&, llvm::json::Value const&) (.cold) JSON.cpp:0:0\r\n #7 0x0000000004e396a8 (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4e396a8)\r\n #8 0x0000000004d360f0 llvm::VerifierPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4d360f0)\r\n #9 0x00000000008d865e llvm::detail::PassModel<llvm::Module, llvm::VerifierPass, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8d865e)\r\n#10 0x0000000004cf9c90 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4cf9c90)\r\n#11 0x00000000008e33d2 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8e33d2)\r\n#12 0x00000000008d62fc optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8d62fc)\r\n#13 0x00007c0269e29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\r\n#14 0x00007c0269e29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\r\n#15 0x00000000008cd75e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8cd75e)\r\nProgram terminated with signal: SIGSEGV\r\nCompiler returned: 139\r\n```\r\n",
47
+ "author": "TatyanaDoubts",
48
+ "labels": [
49
+ "llvm:SLPVectorizer",
50
+ "llvm:crash"
51
+ ],
52
+ "comments": [
53
+ {
54
+ "author": "Zentrik",
55
+ "body": "@alexey-bataev Hi, is there a way to backport this fix for llvm 19, I tried just cherry picking f70f1228035c9610de38e0e376afdacb647c4ad9 but I ended up getting assertion failures of the form `/workspace/srcdir/llvm-project/llvm/lib/IR/Instruction.cpp:321: bool llvm::Instruction::comesBefore(const llvm::Instruction*) const: Assertion 'getParent() == Other->getParent() && \"cross-BB instruction order comparison\"' failed.'`. \r\nI can create an IR reproducer for that failure if need be.\r\nThank you.\r\n\r\nEDIT: Would just adding a check that they're in the same basic block work?"
56
+ },
57
+ {
58
+ "author": "alexey-bataev",
59
+ "body": "> @alexey-bataev Hi, is there a way to backport this fix for llvm 19, I tried just cherry picking [f70f122](https://github.com/llvm/llvm-project/commit/f70f1228035c9610de38e0e376afdacb647c4ad9) but I ended up getting assertion failures of the form `/workspace/srcdir/llvm-project/llvm/lib/IR/Instruction.cpp:321: bool llvm::Instruction::comesBefore(const llvm::Instruction*) const: Assertion 'getParent() == Other->getParent() && \"cross-BB instruction order comparison\"' failed.'`. I can create an IR reproducer for that failure if need be. Thank you.\r\n> \r\n> EDIT: Would just adding a check that they're in the same basic block work?\r\n\r\nYes, check for the same parent should fix it"
60
+ }
61
+ ]
62
+ },
63
+ "verified": true
64
+ }
dataset/101337.json ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "101337",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/101337",
4
+ "bug_type": "crash",
5
+ "base_commit": "1b936e4812ab395328203f65cacd4ffe02bb318e",
6
+ "knowledge_cutoff": "2024-07-31T14:11:24Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/LoopVectorize"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "cd08fadd03904806fa26a1f117879ddae34fbf67",
12
+ "components": [
13
+ "LoopVectorize"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
17
+ [
18
+ 7080,
19
+ 7086
20
+ ]
21
+ ]
22
+ },
23
+ "bug_location_funcname": {
24
+ "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
25
+ "LoopVectorizationPlanner::cost"
26
+ ]
27
+ }
28
+ },
29
+ "patch": "commit cd08fadd03904806fa26a1f117879ddae34fbf67\nAuthor: Florian Hahn <[email protected]>\nDate: Mon Aug 12 14:45:43 2024 +0100\n\n [LV] Include chains feeding inductions in cost precomputation.\n \n Include chain of ops feeding inductions in cost precomputation for\n inductions, not just the induction increment. In VPlan, those\n instructions will be cleaned up, as both phi and increment are generated\n by VPWidenIntOrFpInductionRecipe independently.\n \n Fixes https://github.com/llvm/llvm-project/issues/101337.\n\ndiff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\nindex 542d74ef0e1e..41e4b0fcd9b0 100644\n--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\n+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\n@@ -7080,7 +7080,16 @@ InstructionCost LoopVectorizationPlanner::cost(VPlan &Plan,\n for (const auto &[IV, IndDesc] : Legal->getInductionVars()) {\n Instruction *IVInc = cast<Instruction>(\n IV->getIncomingValueForBlock(OrigLoop->getLoopLatch()));\n- SmallVector<Instruction *> IVInsts = {IV, IVInc};\n+ SmallVector<Instruction *> IVInsts = {IVInc};\n+ for (unsigned I = 0; I != IVInsts.size(); I++) {\n+ for (Value *Op : IVInsts[I]->operands()) {\n+ auto *OpI = dyn_cast<Instruction>(Op);\n+ if (Op == IV || !OpI || !OrigLoop->contains(OpI) || !Op->hasOneUse())\n+ continue;\n+ IVInsts.push_back(OpI);\n+ }\n+ }\n+ IVInsts.push_back(IV);\n for (User *U : IV->users()) {\n auto *CI = cast<Instruction>(U);\n if (!CostCtx.CM.isOptimizableIVTruncate(CI, VF))\n",
30
+ "tests": [
31
+ {
32
+ "file": "llvm/test/Transforms/LoopVectorize/X86/induction-costs.ll",
33
+ "commands": [
34
+ "opt -p loop-vectorize -mtriple=x86_64-apple-macosx -S %s"
35
+ ],
36
+ "tests": [
37
+ {
38
+ "test_name": "iv_and_step_trunc",
39
+ "test_body": "target datalayout = \"e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\n\ndefine i16 @iv_and_step_trunc() {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %rec = phi i16 [ 0, %entry ], [ %rec.next, %loop ]\n %iv.next = add i64 %iv, 1\n %0 = trunc i64 %iv to i16\n %1 = trunc i64 %iv.next to i16\n %rec.next = mul i16 %0, %1\n %ec = icmp eq i64 %iv, 1\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret i16 %rec\n}\n"
40
+ },
41
+ {
42
+ "test_name": "wombat2",
43
+ "test_body": "target datalayout = \"e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\n\ndefine void @wombat2(i32 %arg, ptr %dst) #0 {\nentry:\n %mul = mul i32 %arg, 3\n %zext = zext i32 %arg to i64\n br label %loop\n\nloop: ; preds = %loop, %entry\n %phi = phi i64 [ 4, %entry ], [ %add, %loop ]\n %phi2 = phi i32 [ %mul, %entry ], [ %trunc.1, %loop ]\n %getelementptr = getelementptr i32, ptr %dst, i64 %phi\n %and = and i32 %phi2, 12\n store i32 %and, ptr %getelementptr, align 4\n %mul3 = mul i64 %phi, %zext\n %add = add i64 %phi, 1\n %icmp = icmp ugt i64 %phi, 65\n %trunc.0 = trunc i64 %mul3 to i60\n %trunc.1 = trunc i60 %trunc.0 to i32\n br i1 %icmp, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n\nattributes #0 = { \"target-cpu\"=\"skylake-avx512\" \"target-features\"=\"-avx512f\" }\n"
44
+ },
45
+ {
46
+ "test_name": "with_dead_use",
47
+ "test_body": "target datalayout = \"e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\n\ndefine void @with_dead_use(i32 %arg, ptr %dst) #0 {\nentry:\n %mul = mul i32 %arg, 3\n %zext = zext i32 %arg to i64\n br label %loop\n\nloop: ; preds = %loop, %entry\n %phi = phi i64 [ 4, %entry ], [ %add, %loop ]\n %phi2 = phi i32 [ %mul, %entry ], [ %trunc, %loop ]\n %getelementptr = getelementptr i32, ptr %dst, i64 %phi\n %and = and i32 %phi2, 12\n store i32 %and, ptr %getelementptr, align 4\n %mul3 = mul i64 %phi, %zext\n %add = add i64 %phi, 1\n %icmp = icmp ugt i64 %phi, 65\n %trunc = trunc i64 %mul3 to i32\n %dead.and = and i32 %trunc, 123\n br i1 %icmp, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n\nattributes #0 = { \"target-cpu\"=\"skylake-avx512\" \"target-features\"=\"-avx512f\" }\n"
48
+ },
49
+ {
50
+ "test_name": "test_scalar_predicated_cost",
51
+ "test_body": "target datalayout = \"e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\n\ndefine i32 @test_scalar_predicated_cost(i64 %x, i64 %y, ptr %A) #0 {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %cmp9.not = icmp ule i64 %iv, %y\n br i1 %cmp9.not, label %loop.latch, label %if.then\n\nif.then: ; preds = %loop.header\n %or = or i64 %x, %iv\n %gep = getelementptr i32, ptr %A, i64 %iv\n %t = trunc i64 %or to i32\n store i32 %t, ptr %gep, align 4\n br label %loop.latch\n\nloop.latch: ; preds = %if.then, %loop.header\n %iv.next = add i64 %iv, 1\n %ec = icmp eq i64 %iv, 100\n br i1 %ec, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n ret i32 0\n}\n\nattributes #0 = { \"min-legal-vector-width\"=\"0\" \"target-cpu\"=\"skylake-avx512\" }\n"
52
+ },
53
+ {
54
+ "test_name": "truncated_ivs_with_wide_and_scalar_uses",
55
+ "test_body": "target datalayout = \"e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\n\ndefine void @truncated_ivs_with_wide_and_scalar_uses(i1 %c, ptr %dst) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %iv.16 = trunc i64 %iv to i16\n %iv.32 = trunc i64 %iv to i32\n %gep = getelementptr i16, ptr %dst, i32 %iv.32\n %sel = select i1 %c, i16 %iv.16, i16 10\n store i16 %sel, ptr %gep, align 2\n %iv.next = add i64 %iv, 1\n %ec = icmp eq i64 %iv, 64\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n"
56
+ },
57
+ {
58
+ "test_name": "multiple_truncated_ivs_with_wide_uses",
59
+ "test_body": "target datalayout = \"e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\n\ndefine void @multiple_truncated_ivs_with_wide_uses(i1 %c, ptr %A, ptr %B) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %iv.16 = trunc i64 %iv to i16\n %iv.32 = trunc i64 %iv to i32\n %sel = select i1 %c, i16 %iv.16, i16 10\n %gep.A = getelementptr i16, ptr %A, i64 %iv\n store i16 %sel, ptr %gep.A, align 2\n %gep.B = getelementptr i32, ptr %B, i64 %iv\n store i32 %iv.32, ptr %gep.B, align 4\n %iv.next = add i64 %iv, 1\n %ec = icmp eq i64 %iv, 64\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n"
60
+ },
61
+ {
62
+ "test_name": "wide_iv_trunc_reuse",
63
+ "test_body": "target datalayout = \"e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\n\ndefine void @wide_iv_trunc_reuse(ptr %dst) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 1, %entry ], [ %iv.next, %loop ]\n %iv.2 = phi i32 [ 0, %entry ], [ %iv.trunc, %loop ]\n store i32 %iv.2, ptr %dst, align 4\n %iv.next = add i64 %iv, 1\n %ec = icmp eq i64 %iv, 0\n %iv.trunc = trunc i64 %iv to i32\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n"
64
+ },
65
+ {
66
+ "test_name": "iv_used_widened_and_truncated",
67
+ "test_body": "target datalayout = \"e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\n\ndefine i32 @iv_used_widened_and_truncated(ptr %dst, i64 %N) #0 {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %gep = getelementptr { i32, [8 x i32] }, ptr %dst, i64 %iv\n %t = trunc i64 %iv to i32\n store i32 %t, ptr %gep, align 8\n %iv.next = add i64 %iv, 1\n %c = icmp eq i64 %iv, %N\n br i1 %c, label %exit, label %loop\n\nexit: ; preds = %loop\n ret i32 0\n}\n\nattributes #0 = { \"min-legal-vector-width\"=\"0\" \"target-cpu\"=\"skylake-avx512\" }\n"
68
+ },
69
+ {
70
+ "test_name": "wombat",
71
+ "test_body": "target datalayout = \"e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\n\ndefine void @wombat(i32 %arg, ptr %dst) #0 {\nentry:\n %mul = mul i32 %arg, 3\n %zext = zext i32 %arg to i64\n br label %loop\n\nloop: ; preds = %loop, %entry\n %phi = phi i64 [ 4, %entry ], [ %add, %loop ]\n %phi2 = phi i32 [ %mul, %entry ], [ %trunc, %loop ]\n %getelementptr = getelementptr i32, ptr %dst, i64 %phi\n %and = and i32 %phi2, 12\n store i32 %and, ptr %getelementptr, align 4\n %mul3 = mul i64 %phi, %zext\n %add = add i64 %phi, 1\n %icmp = icmp ugt i64 %phi, 65\n %trunc = trunc i64 %mul3 to i32\n br i1 %icmp, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n\nattributes #0 = { \"target-cpu\"=\"skylake-avx512\" \"target-features\"=\"-avx512f\" }\n"
72
+ },
73
+ {
74
+ "test_name": "wide_iv_trunc",
75
+ "test_body": "target datalayout = \"e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\n\ndefine void @wide_iv_trunc(ptr %dst, i64 %N) {\nentry:\n %cmp = icmp ult i64 %N, 8\n br i1 %cmp, label %loop, label %exit\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %iv.trunc = trunc i64 %iv to i32\n store i32 %iv.trunc, ptr %dst, align 4\n %iv.next = add i64 %iv, 1\n %ec = icmp eq i64 %iv, %N\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop, %entry\n ret void\n}\n"
76
+ },
77
+ {
78
+ "test_name": "multiple_pointer_ivs_with_scalar_uses_only",
79
+ "test_body": "target datalayout = \"e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\n\ndefine void @multiple_pointer_ivs_with_scalar_uses_only(ptr %A, ptr %B) #0 {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv.1 = phi i32 [ 100, %entry ], [ %dec, %loop ]\n %iv.2 = phi i32 [ 2048, %entry ], [ %add38, %loop ]\n %ptr.iv.1 = phi ptr [ %A, %entry ], [ %outptr.0, %loop ]\n %ptr.iv.2 = phi ptr [ %B, %entry ], [ %incdec.ptr36, %loop ]\n %ptr.iv.3 = phi ptr [ %B, %entry ], [ %incdec.ptr33, %loop ]\n %incdec.ptr33 = getelementptr i8, ptr %ptr.iv.3, i64 1\n %0 = load i8, ptr %ptr.iv.3, align 1\n %conv34 = zext i8 %0 to i32\n %incdec.ptr36 = getelementptr i8, ptr %ptr.iv.2, i64 1\n %1 = load i8, ptr %ptr.iv.2, align 1\n %conv37 = zext i8 %1 to i32\n %add38 = add i32 %conv34, %conv37\n %shr42 = lshr i32 %iv.2, 1\n %conv43 = trunc i32 %shr42 to i8\n store i8 %conv43, ptr %ptr.iv.1, align 1\n %dec = add i32 %iv.1, 1\n %outptr.0 = getelementptr i8, ptr %ptr.iv.1, i64 2\n %cmp30.not = icmp eq i32 %dec, 0\n br i1 %cmp30.not, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n\nattributes #0 = { \"min-legal-vector-width\"=\"0\" \"target-cpu\"=\"skylake-avx512\" }\n"
80
+ }
81
+ ]
82
+ }
83
+ ],
84
+ "issue": {
85
+ "title": "Assertion `VF.Width == BestVF && \"VPlan cost model and legacy cost model disagreed\"' failed.",
86
+ "body": "To reproduce run opt with \r\n```\r\n-passes=loop-vectorize --mcpu=skylake-avx512 --mattr=+prfchw,-cldemote,+avx,+aes,+sahf,+pclmul,-xop,+crc32,+xsaves,-avx512fp16,-usermsr,-sm4,-egpr,+sse4.1,-avx512ifma,+xsave,+sse4.2,-tsxldtrk,-sm3,-ptwrite,-widekl,+invpcid,+64bit,+xsavec,-avx10.1-512,-avx512vpopcntdq,+cmov,-avx512vp2intersect,+avx512cd,+movbe,-avxvnniint8,-ccmp,-amx-int8,-kl,-avx10.1-256,+evex512,-avxvnni,+rtm,+adx,+avx2,-hreset,-movdiri,-serialize,-sha512,-vpclmulqdq,+avx512vl,-uintr,-cf,+clflushopt,-raoint,-cmpccxadd,+bmi,-amx-tile,+sse,-gfni,-avxvnniint16,-amx-fp16,-zu,-ndd,+xsaveopt,+rdrnd,+avx512f,-amx-bf16,-avx512bf16,-avx512vnni,-push2pop2,+cx8,+avx512bw,+sse3,+pku,-nf,+fsgsbase,-clzero,-mwaitx,-lwp,+lzcnt,-sha,-movdir64b,-ppx,-wbnoinvd,-enqcmd,-avxneconvert,-tbm,-pconfig,-amx-complex,+ssse3,+cx16,+bmi2,+fma,+popcnt,-avxifma,+f16c,-avx512bitalg,-rdpru,+clwb,+mmx,+sse2,+rdseed,-avx512vbmi2,-prefetchi,-rdpid,-fma4,-avx512vbmi,-shstk,-vaes,-waitpkg,-sgx,+fxsr,+avx512dq,-sse4a,-avx512f\r\n```\r\nwith the following test:\r\n```\r\n; ModuleID = './reduced.ll'\r\nsource_filename = \"./reduced.ll\"\r\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128-ni:1-p2:32:8:8:32-ni:2\"\r\ntarget triple = \"x86_64-unknown-linux-gnu\"\r\n\r\ndefine void @wombat(i32 %arg) #0 gc \"statepoint-example\" {\r\nbb:\r\n %mul = mul i32 %arg, 3\r\n %zext = zext i32 %arg to i64\r\n br label %bb1\r\n\r\nbb1: ; preds = %bb1, %bb\r\n %phi = phi i64 [ %add, %bb1 ], [ 4, %bb ]\r\n %phi2 = phi i32 [ %trunc, %bb1 ], [ %mul, %bb ]\r\n %getelementptr = getelementptr i32, ptr addrspace(1) null, i64 %phi\r\n %and = and i32 %phi2, 0\r\n store i32 0, ptr addrspace(1) %getelementptr, align 4\r\n %mul3 = mul i64 %phi, %zext\r\n %add = add i64 %phi, 1\r\n %icmp = icmp ugt i64 %phi, 65\r\n %trunc = trunc i64 %mul3 to i32\r\n br i1 %icmp, label %bb4, label %bb1\r\n\r\nbb4: ; preds = %bb1\r\n ret void\r\n}\r\n```\r\nReproducer: https://godbolt.org/z/nPsP7h51n\r\n\r\nStack dump:\r\n```\r\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=loop-vectorize --mcpu=skylake-avx512 --mattr=+prfchw,-cldemote,+avx,+aes,+sahf,+pclmul,-xop,+crc32,+xsaves,-avx512fp16,-usermsr,-sm4,-egpr,+sse4.1,-avx512ifma,+xsave,+sse4.2,-tsxldtrk,-sm3,-ptwrite,-widekl,+invpcid,+64bit,+xsavec,-avx10.1-512,-avx512vpopcntdq,+cmov,-avx512vp2intersect,+avx512cd,+movbe,-avxvnniint8,-ccmp,-amx-int8,-kl,-avx10.1-256,+evex512,-avxvnni,+rtm,+adx,+avx2,-hreset,-movdiri,-serialize,-sha512,-vpclmulqdq,+avx512vl,-uintr,-cf,+clflushopt,-raoint,-cmpccxadd,+bmi,-amx-tile,+sse,-gfni,-avxvnniint16,-amx-fp16,-zu,-ndd,+xsaveopt,+rdrnd,+avx512f,-amx-bf16,-avx512bf16,-avx512vnni,-push2pop2,+cx8,+avx512bw,+sse3,+pku,-nf,+fsgsbase,-clzero,-mwaitx,-lwp,+lzcnt,-sha,-movdir64b,-ppx,-wbnoinvd,-enqcmd,-avxneconvert,-tbm,-pconfig,-amx-complex,+ssse3,+cx16,+bmi2,+fma,+popcnt,-avxifma,+f16c,-avx512bitalg,-rdpru,+clwb,+mmx,+sse2,+rdseed,-avx512vbmi2,-prefetchi,-rdpid,-fma4,-avx512vbmi,-shstk,-vaes,-waitpkg,-sgx,+fxsr,+avx512dq,-sse4a,-avx512f <source>\r\n1.\tRunning pass \"function(loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>)\" on module \"<source>\"\r\n2.\tRunning pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"wombat\"\r\n #0 0x0000000004f053c8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4f053c8)\r\n #1 0x0000000004f02b3c SignalHandler(int) Signals.cpp:0:0\r\n #2 0x00007458cc042520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #3 0x00007458cc0969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\r\n #4 0x00007458cc042476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\r\n #5 0x00007458cc0287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\r\n #6 0x00007458cc02871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\r\n #7 0x00007458cc039e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n #8 0x0000000003f83f37 llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3f83f37)\r\n #9 0x0000000003f86659 llvm::LoopVectorizePass::runImpl(llvm::Function&, llvm::ScalarEvolution&, llvm::LoopInfo&, llvm::TargetTransformInfo&, llvm::DominatorTree&, llvm::BlockFrequencyInfo*, llvm::TargetLibraryInfo*, llvm::DemandedBits&, llvm::AssumptionCache&, llvm::LoopAccessInfoManager&, llvm::OptimizationRemarkEmitter&, llvm::ProfileSummaryInfo*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3f86659)\r\n#10 0x0000000003f86cd2 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3f86cd2)\r\n#11 0x0000000002e596ce llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2e596ce)\r\n#12 0x0000000004d02758 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4d02758)\r\n#13 0x0000000000de089e llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xde089e)\r\n#14 0x0000000004d0114e llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4d0114e)\r\n#15 0x0000000000de0eee llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xde0eee)\r\n#16 0x0000000004cff2b0 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4cff2b0)\r\n#17 0x00000000008e3752 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8e3752)\r\n#18 0x00000000008d667c optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8d667c)\r\n#19 0x00007458cc029d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\r\n#20 0x00007458cc029e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\r\n#21 0x00000000008cdade _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8cdade)\r\nProgram terminated with signal: SIGSEGV\r\nCompiler returned: 139\r\n```",
87
+ "author": "TatyanaDoubts",
88
+ "labels": [
89
+ "vectorizers",
90
+ "crash"
91
+ ],
92
+ "comments": [
93
+ {
94
+ "author": "patrick-rivos",
95
+ "body": "Potentially related: https://github.com/llvm/llvm-project/issues/100591"
96
+ }
97
+ ]
98
+ },
99
+ "verified": true
100
+ }
dataset/102187.json ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "102187",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/102187",
4
+ "bug_type": "crash",
5
+ "base_commit": "4b6e3e38c46f8fedb92a30b29cc9654450244e2d",
6
+ "knowledge_cutoff": "2024-08-06T17:31:46Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/SLPVectorizer"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "2601d6f189cf1d4e4e77a7cba83e5d32c87bf079",
12
+ "components": [
13
+ "SLPVectorizer"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
17
+ [
18
+ 14049,
19
+ 14060
20
+ ],
21
+ [
22
+ 14080,
23
+ 14090
24
+ ]
25
+ ]
26
+ },
27
+ "bug_location_funcname": {
28
+ "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
29
+ "BoUpSLP::vectorizeTree"
30
+ ]
31
+ }
32
+ },
33
+ "patch": "commit 2601d6f189cf1d4e4e77a7cba83e5d32c87bf079\nAuthor: Alexey Bataev <[email protected]>\nDate: Tue Aug 6 12:27:36 2024 -0700\n\n [SLP]Fix PR102187: do not insert extractelement before landingpad instruction.\n \n Landingpad instruction must be the very first instruction after the phi\n nodes, so need to inser extractelement/shuffles after this instruction.\n \n Fixes https://github.com/llvm/llvm-project/issues/102187\n\ndiff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\nindex 9589d306581e..5c8873853a73 100644\n--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n@@ -14049,12 +14049,19 @@ Value *BoUpSLP::vectorizeTree(\n \"ExternallyUsedValues map or remain as scalar in vectorized \"\n \"instructions\");\n if (auto *VecI = dyn_cast<Instruction>(Vec)) {\n- if (auto *PHI = dyn_cast<PHINode>(VecI))\n- Builder.SetInsertPoint(PHI->getParent(),\n- PHI->getParent()->getFirstNonPHIIt());\n- else\n+ if (auto *PHI = dyn_cast<PHINode>(VecI)) {\n+ if (PHI->getParent()->isLandingPad())\n+ Builder.SetInsertPoint(\n+ PHI->getParent(),\n+ std::next(\n+ PHI->getParent()->getLandingPadInst()->getIterator()));\n+ else\n+ Builder.SetInsertPoint(PHI->getParent(),\n+ PHI->getParent()->getFirstNonPHIIt());\n+ } else {\n Builder.SetInsertPoint(VecI->getParent(),\n std::next(VecI->getIterator()));\n+ }\n } else {\n Builder.SetInsertPoint(&F->getEntryBlock(), F->getEntryBlock().begin());\n }\n@@ -14080,11 +14087,18 @@ Value *BoUpSLP::vectorizeTree(\n auto VecIt = VectorCasts.find(Key);\n if (VecIt == VectorCasts.end()) {\n IRBuilderBase::InsertPointGuard Guard(Builder);\n- if (auto *IVec = dyn_cast<PHINode>(Vec))\n- Builder.SetInsertPoint(\n- IVec->getParent()->getFirstNonPHIOrDbgOrLifetime());\n- else if (auto *IVec = dyn_cast<Instruction>(Vec))\n+ if (auto *IVec = dyn_cast<PHINode>(Vec)) {\n+ if (IVec->getParent()->isLandingPad())\n+ Builder.SetInsertPoint(IVec->getParent(),\n+ std::next(IVec->getParent()\n+ ->getLandingPadInst()\n+ ->getIterator()));\n+ else\n+ Builder.SetInsertPoint(\n+ IVec->getParent()->getFirstNonPHIOrDbgOrLifetime());\n+ } else if (auto *IVec = dyn_cast<Instruction>(Vec)) {\n Builder.SetInsertPoint(IVec->getNextNonDebugInstruction());\n+ }\n Vec = Builder.CreateIntCast(\n Vec,\n getWidenedType(\n",
34
+ "tests": [
35
+ {
36
+ "file": "llvm/test/Transforms/SLPVectorizer/X86/extractelement-phi-in-landingpad.ll",
37
+ "commands": [
38
+ "opt -S --passes=slp-vectorizer -slp-threshold=-99999 -mtriple=x86_64-unknown-linux-gnu < %s"
39
+ ],
40
+ "tests": [
41
+ {
42
+ "test_name": "test",
43
+ "test_body": "define void @test() personality ptr null {\nbb:\n invoke void null()\n to label %bb65 unwind label %bb4\n\nbb2: ; No predecessors!\n invoke void null()\n to label %bb65 unwind label %bb4\n\nbb4: ; preds = %bb2, %bb\n %phi5 = phi i32 [ 0, %bb ], [ 0, %bb2 ]\n %phi6 = phi i32 [ 0, %bb ], [ 0, %bb2 ]\n %landingpad = landingpad { ptr, i32 }\n cleanup\n call void null(i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5, i32 %phi5)\n ret void\n\nbb65: ; preds = %bb2, %bb\n ret void\n}\n"
44
+ }
45
+ ]
46
+ }
47
+ ],
48
+ "issue": {
49
+ "title": "LLVM ERROR: Broken module found, compilation aborted!",
50
+ "body": "To reproduce run opt with \r\n[Test.ll.tgz](https://github.com/user-attachments/files/16513795/Test.ll.tgz)\r\nusing `-passes slp-vectorizer -slp-threshold=-99999` \r\n\r\nReproducer https://godbolt.org/z/f4szGsMYd\r\n\r\n```\r\nThe unwind destination does not have an exception handling instruction!\r\n %invoke = invoke i64 null(ptr addrspace(1) null, i32 0, i64 0, i32 0)\r\n to label %bb65 unwind label %bb4\r\nThe unwind destination does not have an exception handling instruction!\r\n %invoke3 = invoke i64 null(ptr addrspace(1) null, i32 0, i64 0, i32 0)\r\n to label %bb65 unwind label %bb4\r\nLandingPadInst not the first non-PHI instruction in the block.\r\n %landingpad = landingpad { ptr, i32 }\r\n cleanup\r\nLLVM ERROR: Broken module found, compilation aborted!\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes slp-vectorizer -slp-threshold=-99999 <source>\r\n1.\tRunning pass \"verify\" on module \"<source>\"\r\n #0 0x0000000004f1d2d8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4f1d2d8)\r\n #1 0x0000000004f1aa4c SignalHandler(int) Signals.cpp:0:0\r\n #2 0x0000788c1ca42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #3 0x0000788c1ca969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\r\n #4 0x0000788c1ca42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\r\n #5 0x0000788c1ca287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\r\n #6 0x00000000007b40fd llvm::json::operator==(llvm::json::Value const&, llvm::json::Value const&) (.cold) JSON.cpp:0:0\r\n #7 0x0000000004e571e8 (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4e571e8)\r\n #8 0x0000000004d53550 llvm::VerifierPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4d53550)\r\n #9 0x00000000008d8a7e llvm::detail::PassModel<llvm::Module, llvm::VerifierPass, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8d8a7e)\r\n#10 0x0000000004d17270 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4d17270)\r\n#11 0x00000000008e37f2 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8e37f2)\r\n#12 0x00000000008d671c optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8d671c)\r\n#13 0x0000788c1ca29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\r\n#14 0x0000788c1ca29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\r\n#15 0x00000000008cdb7e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8cdb7e)\r\nProgram terminated with signal: SIGSEGV\r\nCompiler returned: 139\r\n```",
51
+ "author": "TatyanaDoubts",
52
+ "labels": [
53
+ "llvm:SLPVectorizer",
54
+ "crash-on-valid"
55
+ ],
56
+ "comments": []
57
+ },
58
+ "verified": true
59
+ }
dataset/102279.json ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "102279",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/102279",
4
+ "bug_type": "crash",
5
+ "base_commit": "f7e1efe8bcea14686d1c303e058f687b6ca1c79f",
6
+ "knowledge_cutoff": "2024-08-07T07:28:15Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/SLPVectorizer"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "441f94f4bdf6e2b9747ec12194c595098d9c3a5b",
12
+ "components": [
13
+ "SLPVectorizer"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
17
+ [
18
+ 17336,
19
+ 17362
20
+ ]
21
+ ]
22
+ },
23
+ "bug_location_funcname": {
24
+ "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
25
+ "tryToReduce"
26
+ ]
27
+ }
28
+ },
29
+ "patch": "commit 441f94f4bdf6e2b9747ec12194c595098d9c3a5b\nAuthor: Alexey Bataev <[email protected]>\nDate: Wed Aug 7 04:09:55 2024 -0700\n\n [SLP]Fix PR102279: check the tracked values for extractelements, not the original values\n \n If the reduced value was replaced by the extractelement instruction\n during vectorization and we attempt to check if this is so, need to\n check the tracked value, not the original (deleted) instruction.\n Otherwise, the compiler may crash\n \n Fixes https://github.com/llvm/llvm-project/issues/102279\n\ndiff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\nindex c9335b7a89e1..1fee06d145b9 100644\n--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n@@ -17336,27 +17336,23 @@ public:\n // Try to handle shuffled extractelements.\n if (S.getOpcode() == Instruction::ExtractElement && !S.isAltShuffle() &&\n I + 1 < E) {\n- InstructionsState NextS = getSameOpcode(ReducedVals[I + 1], TLI);\n- if (NextS.getOpcode() == Instruction::ExtractElement &&\n- !NextS.isAltShuffle()) {\n- SmallVector<Value *> CommonCandidates(Candidates);\n- for (Value *RV : ReducedVals[I + 1]) {\n- Value *RdxVal = TrackedVals.find(RV)->second;\n- // Check if the reduction value was not overriden by the\n- // extractelement instruction because of the vectorization and\n- // exclude it, if it is not compatible with other values.\n- if (auto *Inst = dyn_cast<Instruction>(RdxVal))\n- if (!NextS.getOpcode() || !NextS.isOpcodeOrAlt(Inst))\n- continue;\n- CommonCandidates.push_back(RdxVal);\n- TrackedToOrig.try_emplace(RdxVal, RV);\n- }\n- SmallVector<int> Mask;\n- if (isFixedVectorShuffle(CommonCandidates, Mask)) {\n- ++I;\n- Candidates.swap(CommonCandidates);\n- ShuffledExtracts = true;\n- }\n+ SmallVector<Value *> CommonCandidates(Candidates);\n+ for (Value *RV : ReducedVals[I + 1]) {\n+ Value *RdxVal = TrackedVals.find(RV)->second;\n+ // Check if the reduction value was not overriden by the\n+ // extractelement instruction because of the vectorization and\n+ // exclude it, if it is not compatible with other values.\n+ auto *Inst = dyn_cast<ExtractElementInst>(RdxVal);\n+ if (!Inst)\n+ continue;\n+ CommonCandidates.push_back(RdxVal);\n+ TrackedToOrig.try_emplace(RdxVal, RV);\n+ }\n+ SmallVector<int> Mask;\n+ if (isFixedVectorShuffle(CommonCandidates, Mask)) {\n+ ++I;\n+ Candidates.swap(CommonCandidates);\n+ ShuffledExtracts = true;\n }\n }\n \n",
30
+ "tests": [
31
+ {
32
+ "file": "llvm/test/Transforms/SLPVectorizer/X86/reduced-value-replace-extractelement.ll",
33
+ "commands": [
34
+ "opt -S --passes=slp-vectorizer -slp-threshold=-99999 < %s -mtriple=x86_64-unknown-linux-gnu"
35
+ ],
36
+ "tests": [
37
+ {
38
+ "test_name": "test",
39
+ "test_body": "define void @test() {\nbb:\n br label %bb1\n\nbb1: ; preds = %bb1, %bb\n %phi = phi i32 [ 0, %bb ], [ %mul9, %bb1 ]\n %phi2 = phi i32 [ 0, %bb ], [ 0, %bb1 ]\n %trunc = trunc i64 0 to i32\n %mul = mul i32 0, %trunc\n %mul3 = mul i32 %trunc, %phi\n %mul4 = mul i32 %mul3, %mul\n %mul5 = mul i32 %mul4, %mul\n %trunc6 = trunc i64 0 to i32\n %mul7 = mul i32 0, %trunc6\n %mul8 = mul i32 %mul5, %mul7\n %mul9 = mul i32 %mul8, %mul7\n br label %bb1\n}\n"
40
+ }
41
+ ]
42
+ },
43
+ {
44
+ "file": "llvm/test/Transforms/SLPVectorizer/X86/reduction-gather-non-scheduled-extracts.ll",
45
+ "commands": [
46
+ "opt -S --passes=slp-vectorizer -mtriple=x86_64-sie-ps5 < %s"
47
+ ],
48
+ "tests": [
49
+ {
50
+ "test_name": "tes",
51
+ "test_body": "define void @tes() {\nentry:\n %0 = extractelement <2 x i1> zeroinitializer, i64 0\n %1 = extractelement <2 x i1> zeroinitializer, i64 0\n %2 = fcmp ole <2 x double> zeroinitializer, zeroinitializer\n %3 = extractelement <2 x i1> %2, i64 0\n %4 = extractelement <2 x i1> zeroinitializer, i64 0\n br label %5\n\n5: ; preds = %entry\n %6 = select i1 false, i1 false, i1 false\n %7 = select i1 %6, i1 %0, i1 false\n %8 = select i1 %7, i1 %1, i1 false\n %9 = select i1 %8, i1 false, i1 false\n %10 = select i1 %9, i1 %3, i1 false\n %11 = select i1 %10, i1 %4, i1 false\n br i1 %11, label %12, label %13\n\n12: ; preds = %5\n ret void\n\n13: ; preds = %5\n ret void\n}\n"
52
+ }
53
+ ]
54
+ }
55
+ ],
56
+ "issue": {
57
+ "title": "Crash in getSameOpcode(llvm::ArrayRef<llvm::Value*>, llvm::TargetLibraryInfo const&, unsigned int)",
58
+ "body": " To reproduce run the test below with `-passes slp-vectorizer -slp-threshold=-99999`\r\n```\r\n; ModuleID = './reduced.ll'\r\nsource_filename = \"./reduced.ll\"\r\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128-ni:1-p2:32:8:8:32-ni:2\"\r\ntarget triple = \"x86_64-unknown-linux-gnu\"\r\n\r\ndefine void @wombat() #0 gc \"statepoint-example\" {\r\nbb:\r\n br label %bb1\r\n\r\nbb1: ; preds = %bb1, %bb\r\n %phi = phi i32 [ 0, %bb ], [ %mul9, %bb1 ]\r\n %phi2 = phi i32 [ 0, %bb ], [ 0, %bb1 ]\r\n %trunc = trunc i64 0 to i32\r\n %mul = mul i32 0, %trunc\r\n %mul3 = mul i32 %trunc, %phi\r\n %mul4 = mul i32 %mul3, %mul\r\n %mul5 = mul i32 %mul4, %mul\r\n %trunc6 = trunc i64 0 to i32\r\n %mul7 = mul i32 0, %trunc6\r\n %mul8 = mul i32 %mul5, %mul7\r\n %mul9 = mul i32 %mul8, %mul7\r\n br label %bb1\r\n}\r\n\r\n```\r\nReproducer: https://godbolt.org/z/sqEov8n9h\r\n\r\nStack dump:\r\n```\r\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes slp-vectorizer -slp-threshold=-99999 <source>\r\n1.\tRunning pass \"function(slp-vectorizer)\" on module \"<source>\"\r\n2.\tRunning pass \"slp-vectorizer\" on function \"wombat\"\r\n #0 0x0000000004f2ff18 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4f2ff18)\r\n #1 0x0000000004f2d68c SignalHandler(int) Signals.cpp:0:0\r\n #2 0x00007a3cdfe42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #3 0x000000000403fb8a getSameOpcode(llvm::ArrayRef<llvm::Value*>, llvm::TargetLibraryInfo const&, unsigned int) (.constprop.1) SLPVectorizer.cpp:0:0\r\n #4 0x000000000406b0a4 (anonymous namespace)::HorizontalReduction::tryToReduce(llvm::slpvectorizer::BoUpSLP&, llvm::DataLayout const&, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo const&) SLPVectorizer.cpp:0:0\r\n #5 0x000000000406dab4 llvm::SLPVectorizerPass::vectorizeHorReduction(llvm::PHINode*, llvm::Instruction*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&, llvm::TargetTransformInfo*, llvm::SmallVectorImpl<llvm::WeakTrackingVH>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x406dab4)\r\n #6 0x00000000040720f8 llvm::SLPVectorizerPass::vectorizeRootInstruction(llvm::PHINode*, llvm::Instruction*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&, llvm::TargetTransformInfo*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x40720f8)\r\n #7 0x00000000040763be llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x40763be)\r\n #8 0x000000000407c648 llvm::SLPVectorizerPass::runImpl(llvm::Function&, llvm::ScalarEvolution*, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo*, llvm::AAResults*, llvm::LoopInfo*, llvm::DominatorTree*, llvm::AssumptionCache*, llvm::DemandedBits*, llvm::OptimizationRemarkEmitter*) (.part.0) SLPVectorizer.cpp:0:0\r\n #9 0x000000000407d11b llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x407d11b)\r\n#10 0x0000000002e7f61e llvm::detail::PassModel<llvm::Function, llvm::SLPVectorizerPass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2e7f61e)\r\n#11 0x0000000004d2d348 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4d2d348)\r\n#12 0x0000000000de6cce llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xde6cce)\r\n#13 0x0000000004d2bd3e llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4d2bd3e)\r\n#14 0x0000000000de731e llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xde731e)\r\n#15 0x0000000004d29ea0 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4d29ea0)\r\n#16 0x00000000008e4312 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8e4312)\r\n#17 0x00000000008d723c optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8d723c)\r\n#18 0x00007a3cdfe29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\r\n#19 0x00007a3cdfe29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\r\n#20 0x00000000008ce6ae _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8ce6ae)\r\nProgram terminated with signal: SIGSEGV\r\nCompiler returned: 139\r\n```",
59
+ "author": "TatyanaDoubts",
60
+ "labels": [
61
+ "llvm:SLPVectorizer",
62
+ "crash"
63
+ ],
64
+ "comments": [
65
+ {
66
+ "author": "RKSimon",
67
+ "body": "CC @alexey-bataev "
68
+ }
69
+ ]
70
+ },
71
+ "verified": true
72
+ }
dataset/102351.json ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "102351",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/102351",
4
+ "bug_type": "miscompilation",
5
+ "base_commit": "203a2ca8cd6af505e11a38aebceeaf864271042c",
6
+ "knowledge_cutoff": "2024-08-07T18:49:59Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/SimplifyCFG"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "3c9022c965b85951f30af140da591f819acef8a0",
12
+ "components": [
13
+ "Local"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Utils/Local.cpp": [
17
+ [
18
+ 1028,
19
+ 1034
20
+ ],
21
+ [
22
+ 1133,
23
+ 1139
24
+ ]
25
+ ]
26
+ },
27
+ "bug_location_funcname": {
28
+ "llvm/lib/Transforms/Utils/Local.cpp": [
29
+ "CanRedirectPredsOfEmptyBBToSucc",
30
+ "llvm::TryToSimplifyUncondBranchFromEmptyBlock"
31
+ ]
32
+ }
33
+ },
34
+ "patch": "commit 3c9022c965b85951f30af140da591f819acef8a0\nAuthor: AdityaK <[email protected]>\nDate: Tue Sep 10 22:39:02 2024 -0700\n\n Bail out jump threading on indirect branches (#103688)\n \n The bug was introduced by\n https://github.com/llvm/llvm-project/pull/68473\n \n Fixes: #102351\n\ndiff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp\nindex d0669e44f821..c85c819263e2 100644\n--- a/llvm/lib/Transforms/Utils/Local.cpp\n+++ b/llvm/lib/Transforms/Utils/Local.cpp\n@@ -1028,7 +1028,14 @@ CanRedirectPredsOfEmptyBBToSucc(BasicBlock *BB, BasicBlock *Succ,\n if (!BB->hasNPredecessorsOrMore(2))\n return false;\n \n- // Get single common predecessors of both BB and Succ\n+ if (any_of(BBPreds, [](const BasicBlock *Pred) {\n+ return isa<PHINode>(Pred->begin()) &&\n+ isa<IndirectBrInst>(Pred->getTerminator());\n+ }))\n+ return false;\n+\n+ // Get the single common predecessor of both BB and Succ. Return false\n+ // when there are more than one common predecessors.\n for (BasicBlock *SuccPred : SuccPreds) {\n if (BBPreds.count(SuccPred)) {\n if (CommonPred)\n@@ -1133,7 +1140,7 @@ bool llvm::TryToSimplifyUncondBranchFromEmptyBlock(BasicBlock *BB,\n \n bool BBKillable = CanPropagatePredecessorsForPHIs(BB, Succ, BBPreds);\n \n- // Even if we can not fold bB into Succ, we may be able to redirect the\n+ // Even if we can not fold BB into Succ, we may be able to redirect the\n // predecessors of BB to Succ.\n bool BBPhisMergeable =\n BBKillable ||\n",
35
+ "tests": [
36
+ {
37
+ "file": "llvm/test/Transforms/SimplifyCFG/switch-branch-fold-indirectbr-102351.ll",
38
+ "commands": [
39
+ "opt < %s -passes=simplifycfg -S"
40
+ ],
41
+ "tests": [
42
+ {
43
+ "test_name": "main",
44
+ "test_body": "@.str = private unnamed_addr constant [23 x i8] c\"OP_1:(instruction=%d)\\0A\\00\", align 1\[email protected] = private unnamed_addr constant [28 x i8] c\"TERMINATE:(instruction=%d)\\0A\\00\", align 1\n\n; Function Attrs: mustprogress norecurse uwtable\ndefine dso_local noundef i32 @main() #0 {\nentry:\n %bytecode = alloca [2 x ptr], align 16\n store ptr blockaddress(@main, %VM__OP_1), ptr %bytecode, align 16, !tbaa !5\n %arrayidx1 = getelementptr inbounds [2 x ptr], ptr %bytecode, i64 0, i64 1\n store ptr blockaddress(@main, %VM__TERMINATE), ptr %arrayidx1, align 8, !tbaa !5\n br label %while.body\n\nwhile.body: ; preds = %entry, %sw.epilog\n %state.0 = phi i32 [ 0, %entry ], [ %state.1, %sw.epilog ]\n %index.0 = phi i32 [ 0, %entry ], [ %index.2, %sw.epilog ]\n switch i32 %state.0, label %sw.epilog [\n i32 0, label %sw.bb\n i32 1, label %VM__OP_1\n i32 2, label %sw.bb4\n ]\n\nsw.bb: ; preds = %while.body\n br label %indirectgoto\n\nVM__OP_1: ; preds = %while.body, %indirectgoto\n %index.1 = phi i32 [ %index.3, %indirectgoto ], [ %index.0, %while.body ]\n br label %sw.epilog\n\nsw.bb4: ; preds = %while.body\n %call = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %index.0)\n %inc = add nsw i32 %index.0, 1\n br label %indirectgoto\n\nsw.epilog: ; preds = %while.body, %VM__OP_1\n %state.1 = phi i32 [ %state.0, %while.body ], [ 2, %VM__OP_1 ]\n %index.2 = phi i32 [ %index.0, %while.body ], [ %index.1, %VM__OP_1 ]\n br label %while.body, !llvm.loop !9\n\nVM__TERMINATE: ; preds = %indirectgoto\n %call7 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %index.3)\n ret i32 0\n\nindirectgoto: ; preds = %sw.bb4, %sw.bb\n %index.3 = phi i32 [ %inc, %sw.bb4 ], [ %index.0, %sw.bb ]\n %idxprom.pn = sext i32 %index.3 to i64\n %indirect.goto.dest.in = getelementptr inbounds [2 x ptr], ptr %bytecode, i64 0, i64 %idxprom.pn\n %indirect.goto.dest = load ptr, ptr %indirect.goto.dest.in, align 8, !tbaa !5\n indirectbr ptr %indirect.goto.dest, [label %VM__OP_1, label %VM__TERMINATE]\n}\ndeclare i32 @printf(ptr noundef, ...) #1\n\nattributes #0 = { mustprogress norecurse uwtable \"min-legal-vector-width\"=\"0\" \"no-trapping-math\"=\"true\" \"stack-protector-buffer-size\"=\"8\" \"target-cpu\"=\"x86-64\" \"target-features\"=\"+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87\" \"tune-cpu\"=\"generic\" }\nattributes #1 = { \"no-trapping-math\"=\"true\" \"stack-protector-buffer-size\"=\"8\" \"target-cpu\"=\"x86-64\" \"target-features\"=\"+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87\" \"tune-cpu\"=\"generic\" }\n\n!llvm.module.flags = !{!0, !1, !2, !3}\n!llvm.ident = !{!4}\n\n!0 = !{i32 1, !\"wchar_size\", i32 4}\n!1 = !{i32 8, !\"PIC Level\", i32 2}\n!2 = !{i32 7, !\"PIE Level\", i32 2}\n!3 = !{i32 7, !\"uwtable\", i32 2}\n!4 = !{!\"clang version 18.0.0git (https://github.com/llvm/llvm-project.git 67782d2de5ea9c8653b8f0110237a3c355291c0e)\"}\n!5 = !{!6, !6, i64 0}\n!6 = !{!\"any pointer\", !7, i64 0}\n!7 = !{!\"omnipotent char\", !8, i64 0}\n!8 = !{!\"Simple C++ TBAA\"}\n!9 = !{!10, !10, i64 0}\n!10 = !{!\"int\", !7, i64 0}\n!11 = distinct !{!11, !12, !13}\n!12 = !{!\"llvm.loop.mustprogress\"}\n!13 = !{!\"llvm.loop.unroll.disable\"}",
45
+ "lli_expected_out": "OP_1:(instruction=0)\nTERMINATE:(instruction=1)\n"
46
+ }
47
+ ]
48
+ }
49
+ ],
50
+ "issue": {
51
+ "title": "Miscompile in code with indirect gotos",
52
+ "body": "The simplifycfg pass (incorrectly?) optimizes one of the case statements.\r\n\r\n```llvm\r\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\r\ntarget triple = \"x86_64-unknown-linux-gnu\"\r\n\r\[email protected] = private unnamed_addr constant [23 x i8] c\"OP_1:(instruction=%d)\\0A\\00\", align 1\r\[email protected] = private unnamed_addr constant [28 x i8] c\"TERMINATE:(instruction=%d)\\0A\\00\", align 1\r\n\r\n; Function Attrs: mustprogress norecurse uwtable\r\ndefine dso_local noundef i32 @main() #0 {\r\nentry:\r\n %bytecode = alloca [2 x ptr], align 16\r\n store ptr blockaddress(@main, %VM__OP_1), ptr %bytecode, align 16, !tbaa !5\r\n %arrayidx1 = getelementptr inbounds [2 x ptr], ptr %bytecode, i64 0, i64 1\r\n store ptr blockaddress(@main, %VM__TERMINATE), ptr %arrayidx1, align 8, !tbaa !5\r\n br label %while.body\r\n\r\nwhile.body: ; preds = %entry, %sw.epilog\r\n %state.0 = phi i32 [ 0, %entry ], [ %state.1, %sw.epilog ]\r\n %index.0 = phi i32 [ 0, %entry ], [ %index.2, %sw.epilog ]\r\n switch i32 %state.0, label %sw.epilog [\r\n i32 0, label %sw.bb\r\n i32 1, label %VM__OP_1\r\n i32 2, label %sw.bb4\r\n ]\r\n\r\nsw.bb: ; preds = %while.body\r\n br label %indirectgoto\r\n\r\nVM__OP_1: ; preds = %while.body, %indirectgoto\r\n %index.1 = phi i32 [ %index.3, %indirectgoto ], [ %index.0, %while.body ]\r\n br label %sw.epilog\r\n\r\nsw.bb4: ; preds = %while.body\r\n %call = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %index.0)\r\n %inc = add nsw i32 %index.0, 1\r\n br label %indirectgoto\r\n\r\nsw.epilog: ; preds = %while.body, %VM__OP_1\r\n %state.1 = phi i32 [ %state.0, %while.body ], [ 2, %VM__OP_1 ]\r\n %index.2 = phi i32 [ %index.0, %while.body ], [ %index.1, %VM__OP_1 ]\r\n br label %while.body, !llvm.loop !9\r\n\r\nVM__TERMINATE: ; preds = %indirectgoto\r\n %call7 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %index.3)\r\n ret i32 0\r\n\r\nindirectgoto: ; preds = %sw.bb4, %sw.bb\r\n %index.3 = phi i32 [ %inc, %sw.bb4 ], [ %index.0, %sw.bb ]\r\n %idxprom.pn = sext i32 %index.3 to i64\r\n %indirect.goto.dest.in = getelementptr inbounds [2 x ptr], ptr %bytecode, i64 0, i64 %idxprom.pn\r\n %indirect.goto.dest = load ptr, ptr %indirect.goto.dest.in, align 8, !tbaa !5\r\n indirectbr ptr %indirect.goto.dest, [label %VM__OP_1, label %VM__TERMINATE]\r\n}\r\ndeclare i32 @printf(ptr noundef, ...) #1\r\n\r\nattributes #0 = { mustprogress norecurse uwtable \"min-legal-vector-width\"=\"0\" \"no-trapping-math\"=\"true\" \"stack-protector-buffer-size\"=\"8\" \"target-cpu\"=\"x86-64\" \"target-features\"=\"+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87\" \"tune-cpu\"=\"generic\" }\r\nattributes #1 = { \"no-trapping-math\"=\"true\" \"stack-protector-buffer-size\"=\"8\" \"target-cpu\"=\"x86-64\" \"target-features\"=\"+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87\" \"tune-cpu\"=\"generic\" }\r\n\r\n!llvm.module.flags = !{!0, !1, !2, !3}\r\n!llvm.ident = !{!4}\r\n\r\n!0 = !{i32 1, !\"wchar_size\", i32 4}\r\n!1 = !{i32 8, !\"PIC Level\", i32 2}\r\n!2 = !{i32 7, !\"PIE Level\", i32 2}\r\n!3 = !{i32 7, !\"uwtable\", i32 2}\r\n!4 = !{!\"clang version 18.0.0git (https://github.com/llvm/llvm-project.git 67782d2de5ea9c8653b8f0110237a3c355291c0e)\"}\r\n!5 = !{!6, !6, i64 0}\r\n!6 = !{!\"any pointer\", !7, i64 0}\r\n!7 = !{!\"omnipotent char\", !8, i64 0}\r\n!8 = !{!\"Simple C++ TBAA\"}\r\n!9 = !{!10, !10, i64 0}\r\n!10 = !{!\"int\", !7, i64 0}\r\n!11 = distinct !{!11, !12, !13}\r\n!12 = !{!\"llvm.loop.mustprogress\"}\r\n!13 = !{!\"llvm.loop.unroll.disable\"}\r\n```\r\n\r\n$ opt -passes=simplifycfg orig.ll -S -o out.ll\r\n```llvm\r\n; ModuleID = 'orig.ll'\r\nsource_filename = \"orig.ll\"\r\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\r\ntarget triple = \"x86_64-unknown-linux-gnu\"\r\n\r\[email protected] = private unnamed_addr constant [23 x i8] c\"OP_1:(instruction=%d)\\0A\\00\", align 1\r\[email protected] = private unnamed_addr constant [28 x i8] c\"TERMINATE:(instruction=%d)\\0A\\00\", align 1\r\n\r\n; Function Attrs: mustprogress norecurse uwtable\r\ndefine dso_local noundef i32 @main() #0 {\r\nentry:\r\n %bytecode = alloca [2 x ptr], align 16\r\n store ptr blockaddress(@main, %VM__OP_1), ptr %bytecode, align 16, !tbaa !5\r\n %arrayidx1 = getelementptr inbounds [2 x ptr], ptr %bytecode, i64 0, i64 1\r\n store ptr blockaddress(@main, %VM__TERMINATE), ptr %arrayidx1, align 8, !tbaa !5\r\n br label %while.body\r\n\r\nwhile.body: ; preds = %sw.epilog, %entry\r\n %state.0 = phi i32 [ 0, %entry ], [ %state.1, %sw.epilog ]\r\n %index.0 = phi i32 [ 0, %entry ], [ %index.0, %sw.epilog ]\r\n switch i32 %state.0, label %sw.epilog [\r\n i32 0, label %VM__TERMINATE\r\n i32 1, label %VM__OP_1\r\n i32 2, label %sw.bb4\r\n ]\r\n\r\nVM__OP_1: ; preds = %while.body\r\n br label %sw.epilog\r\n\r\nsw.bb4: ; preds = %while.body\r\n %call = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %index.0)\r\n %inc = add nsw i32 %index.0, 1\r\n br label %VM__TERMINATE\r\n\r\nsw.epilog: ; preds = %VM__OP_1, %while.body\r\n %state.1 = phi i32 [ %state.0, %while.body ], [ 2, %VM__OP_1 ]\r\n br label %while.body, !llvm.loop !9\r\n\r\nVM__TERMINATE: ; preds = %sw.bb4, %while.body\r\n %index.3 = phi i32 [ %inc, %sw.bb4 ], [ %index.0, %while.body ]\r\n %call7 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef %index.3)\r\n ret i32 0\r\n}\r\n\r\ndeclare i32 @printf(ptr noundef, ...) #1\r\n\r\nattributes #0 = { mustprogress norecurse uwtable \"min-legal-vector-width\"=\"0\" \"no-trapping-math\"=\"true\" \"stack-protector-buffer-size\"=\"8\" \"target-cpu\"=\"x86-64\" \"target-features\"=\"+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87\" \"tune-cpu\"=\"generic\" }\r\nattributes #1 = { \"no-trapping-math\"=\"true\" \"stack-protector-buffer-size\"=\"8\" \"target-cpu\"=\"x86-64\" \"target-features\"=\"+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87\" \"tune-cpu\"=\"generic\" }\r\n\r\n!llvm.module.flags = !{!0, !1, !2, !3}\r\n!llvm.ident = !{!4}\r\n\r\n!0 = !{i32 1, !\"wchar_size\", i32 4}\r\n!1 = !{i32 8, !\"PIC Level\", i32 2}\r\n!2 = !{i32 7, !\"PIE Level\", i32 2}\r\n!3 = !{i32 7, !\"uwtable\", i32 2}\r\n!4 = !{!\"clang version 18.0.0git (https://github.com/llvm/llvm-project.git 67782d2de5ea9c8653b8f0110237a3c355291c0e)\"}\r\n!5 = !{!6, !6, i64 0}\r\n!6 = !{!\"any pointer\", !7, i64 0}\r\n!7 = !{!\"omnipotent char\", !8, i64 0}\r\n!8 = !{!\"Simple C++ TBAA\"}\r\n!9 = !{!10, !10, i64 0}\r\n!10 = !{!\"int\", !7, i64 0}\r\n```",
53
+ "author": "hiraditya",
54
+ "labels": [
55
+ "miscompilation",
56
+ "llvm:transforms"
57
+ ],
58
+ "comments": [
59
+ {
60
+ "author": "hiraditya",
61
+ "body": "Original C code\r\n\r\n```c\r\nextern int printf(const char *fmt, ...);\r\n\r\nint main() {\r\n void* bytecode[2];\r\n bytecode[0] = &&VM__OP_1;\r\n bytecode[1] = &&VM__TERMINATE;\r\n\r\n int state = 0;\r\n int index = 0;\r\n\r\n while (1) {\r\n switch (state) {\r\n case 0:\r\n goto *bytecode[index];\r\n case 1:\r\n // NOTE: THIS IS ONLY REACHABLE VIA INDIRECT GOTOS\r\n VM__OP_1:\r\n state = 2;\r\n break;\r\n case 2:\r\n printf(\"OP_1:(instruction=%d)\\n\", index);\r\n index++;\r\n goto *bytecode[index];\r\n }\r\n }\r\n\r\nVM__TERMINATE:\r\n printf(\"TERMINATE:(instruction=%d)\\n\", index);\r\n return 0;\r\n}\r\n```\r\n\r\nhttps://github.com/llvm/llvm-project/pull/76295 makes the miscompile go away(https://godbolt.org/z/d9bGnhhv6) but I think simplifycfg still has the bug.\r\n"
62
+ },
63
+ {
64
+ "author": "efriedma-quic",
65
+ "body": "Looks like TryToSimplifyUncondBranchFromEmptyBlock is not handling indirectbr predecessors correctly: the indirectbr's successor list is rewritten so it has a successor that isn't address-taken. That edge is then proven impossible, so the indirectbr is completely eliminated."
66
+ }
67
+ ]
68
+ },
69
+ "verified": true
70
+ }
dataset/102597.json ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "102597",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/102597",
4
+ "bug_type": "miscompilation",
5
+ "base_commit": "513c3726ebc0a324f7e5a11d25617bb9557324d6",
6
+ "knowledge_cutoff": "2024-08-09T11:02:59Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/IndVarSimplify"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "3512bcc2e9ab06b0ae2cab78744550b515e54184",
12
+ "components": [
13
+ "ScalarEvolution"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Analysis/ScalarEvolution.cpp": [
17
+ [
18
+ 11961,
19
+ 11969
20
+ ]
21
+ ]
22
+ },
23
+ "bug_location_funcname": {
24
+ "llvm/lib/Analysis/ScalarEvolution.cpp": [
25
+ "ScalarEvolution::computeConstantDifference"
26
+ ]
27
+ }
28
+ },
29
+ "patch": "commit 3512bcc2e9ab06b0ae2cab78744550b515e54184\nAuthor: Nikita Popov <[email protected]>\nDate: Mon Aug 12 15:18:32 2024 +0200\n\n [SCEV] Fix incorrect extension in computeConstantDifference()\n \n The Mul factor was zero-extended here, resulting in incorrect\n results for integers larger than 64-bit.\n \n As we currently only multiply by 1 or -1, just split this into\n two cases -- there's no need for a full multiplication here.\n \n Fixes https://github.com/llvm/llvm-project/issues/102597.\n\ndiff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp\nindex 9ecdcbe2c5de..318a9d773dc2 100644\n--- a/llvm/lib/Analysis/ScalarEvolution.cpp\n+++ b/llvm/lib/Analysis/ScalarEvolution.cpp\n@@ -11961,9 +11961,14 @@ ScalarEvolution::computeConstantDifference(const SCEV *More, const SCEV *Less) {\n SmallDenseMap<const SCEV *, int, 8> Multiplicity;\n APInt Diff(BW, 0);\n auto Add = [&](const SCEV *S, int Mul) {\n- if (auto *C = dyn_cast<SCEVConstant>(S))\n- Diff += C->getAPInt() * Mul;\n- else\n+ if (auto *C = dyn_cast<SCEVConstant>(S)) {\n+ if (Mul == 1) {\n+ Diff += C->getAPInt();\n+ } else {\n+ assert(Mul == -1);\n+ Diff -= C->getAPInt();\n+ }\n+ } else\n Multiplicity[S] += Mul;\n };\n auto Decompose = [&](const SCEV *S, int Mul) {\n",
30
+ "tests": [
31
+ {
32
+ "file": "llvm/test/Transforms/IndVarSimplify/pr102597.ll",
33
+ "commands": [
34
+ "opt -S -passes=indvars < %s"
35
+ ],
36
+ "tests": [
37
+ {
38
+ "test_name": "test",
39
+ "test_body": "define void @test() {\nentry:\n br label %loop\n\nloop: ; preds = %loop.latch, %entry\n %iv = phi i128 [ 3, %entry ], [ %iv.dec, %loop.latch ]\n %tobool = icmp ne i128 %iv, 0\n br i1 %tobool, label %loop.latch, label %if\n\nif: ; preds = %loop\n call void @foo()\n br label %loop.latch\n\nloop.latch: ; preds = %if, %loop\n %iv.dec = add nsw i128 %iv, -1\n %cmp = icmp sgt i128 %iv, 0\n br i1 %cmp, label %loop, label %exit\n\nexit: ; preds = %loop.latch\n ret void\n}\n\ndeclare void @foo()\n",
40
+ "additional_args": "-src-unroll=4 -tgt-unroll=4"
41
+ }
42
+ ]
43
+ }
44
+ ],
45
+ "issue": {
46
+ "title": "[SCEV] WRONG code ",
47
+ "body": "```\r\nint printf(const char *, ...);\r\n__int128 a = 3, c;\r\nchar b;\r\nint main() {\r\n c = 3;\r\n for (; c >= 0; c--) {\r\n b = 0;\r\n for (; b <= 3; b++) {\r\n if (c)\r\n break;\r\n a = 0;\r\n }\r\n }\r\n printf(\"%d\\n\", (int)a);\r\n}\r\n\r\n```\r\n\r\nclang -march=z15 -O1 wrong0.i -o a.out\r\n\r\nThis program should print '0' as 'a' is set to zero inside the loop. It now prints '3' instead. A bisect leads to a recent commit: 79af689 \" [SCEV] Handle more adds in computeConstantDifference() (#101339)\".\r\n\r\nSeems like IndVarSimplify has gone wrong with an i128:\r\nGOOD <> BROKEN\r\n```\r\n; *** IR Dump After IndVarSimplifyPass on loo ; *** IR Dump After IndVarSimplifyPass on loo\r\n\r\n; Preheader: ; Preheader:\r\nentry: entry:\r\n br label %for.cond1.preheader br label %for.cond1.preheader\r\n\r\n; Loop: ; Loop:\r\nfor.cond1.preheader: for.cond1.preheader: \r\n %storemerge11 = phi i128 [ 3, %entry ], [ % %storemerge11 = phi i128 [ 3, %entry ], [ %\r\n %tobool = icmp ne i128 %storemerge11, 0 | br i1 true, label %for.inc5, label %if.end.\r\n br i1 %tobool, label %for.inc5, label %if.e <\r\n\r\nif.end.lr.ph: if.end.lr.ph: \r\n store i128 0, ptr @a, align 8, !tbaa !4 store i128 0, ptr @a, align 8, !tbaa !4\r\n br label %if.end br label %if.end\r\n\r\nif.end: if.end: \r\n %storemerge89 = phi i8 [ 0, %if.end.lr.ph ] %storemerge89 = phi i8 [ 0, %if.end.lr.ph ]\r\n %inc = add nuw nsw i8 %storemerge89, 1 %inc = add nuw nsw i8 %storemerge89, 1\r\n %cmp2 = icmp ugt i8 %storemerge89, 2 %cmp2 = icmp ugt i8 %storemerge89, 2\r\n %or.cond = or i1 %tobool, %cmp2 | %or.cond = or i1 true, %cmp2\r\n br i1 %or.cond, label %for.inc5.loopexit, l br i1 %or.cond, label %for.inc5.loopexit, l\r\n\r\nfor.inc5: for.inc5: \r\n %storemerge8.lcssa = phi i8 [ 0, %for.cond1 %storemerge8.lcssa = phi i8 [ 0, %for.cond1\r\n %dec = add nsw i128 %storemerge11, -1 %dec = add nsw i128 %storemerge11, -1\r\n %cmp = icmp ugt i128 %storemerge11, 0 %cmp = icmp ugt i128 %storemerge11, 0\r\n br i1 %cmp, label %for.cond1.preheader, lab br i1 %cmp, label %for.cond1.preheader, lab\r\n\r\nfor.inc5.loopexit: for.inc5.loopexit: \r\n %inc.lcssa = phi i8 [ %inc, %if.end ] %inc.lcssa = phi i8 [ %inc, %if.end ]\r\n br label %for.inc5 br label %for.inc5\r\n\r\n; Exit blocks ; Exit blocks\r\nfor.end6: for.end6: \r\n %storemerge8.lcssa.lcssa = phi i8 [ %storem %storemerge8.lcssa.lcssa = phi i8 [ %storem\r\n store i128 -1, ptr @c, align 8, !tbaa !4 store i128 -1, ptr @c, align 8, !tbaa !4\r\n store i8 %storemerge8.lcssa.lcssa, ptr @b, store i8 %storemerge8.lcssa.lcssa, ptr @b, \r\n %0 = load i128, ptr @a, align 8, !tbaa !4 %0 = load i128, ptr @a, align 8, !tbaa !4\r\n %conv7 = trunc i128 %0 to i32 %conv7 = trunc i128 %0 to i32\r\n %call = call signext i32 (ptr, ...) @printf %call = call signext i32 (ptr, ...) @printf\r\n ret i32 0 ret i32 0\r\n\r\n```",
48
+ "author": "JonPsson1",
49
+ "labels": [
50
+ "miscompilation",
51
+ "llvm:SCEV"
52
+ ],
53
+ "comments": [
54
+ {
55
+ "author": "nikic",
56
+ "body": "Classic mistake: https://github.com/llvm/llvm-project/blob/2f8f58dd17a11934e8c8ec212b6474f76fb18e61/llvm/lib/Analysis/ScalarEvolution.cpp#L11967 This `* Mul` doesn't do what I wanted it to do :)\r\n\r\nI should really pick up https://github.com/llvm/llvm-project/pull/80309 again to prevent this kind of mistake in the first place."
57
+ },
58
+ {
59
+ "author": "JonPsson1",
60
+ "body": "Is this commit self-contained in the sense that I could revert it on my testing machines? Or will you revert / fix soon?"
61
+ }
62
+ ]
63
+ },
64
+ "verified": true
65
+ }
dataset/102934.json ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "102934",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/102934",
4
+ "bug_type": "crash",
5
+ "base_commit": "2913e71865dfc063a47ddfaf1e2ce07763f69614",
6
+ "knowledge_cutoff": "2024-08-12T16:46:46Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/LoopVectorize"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "2ab910c08c4ed43d6fd9eb2ef9b3ff52e0293cf9",
12
+ "components": [
13
+ "LoopVectorize"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
17
+ [
18
+ 3705,
19
+ 3711
20
+ ]
21
+ ]
22
+ },
23
+ "bug_location_funcname": {
24
+ "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
25
+ "LoopVectorizationCostModel::collectLoopUniforms"
26
+ ]
27
+ }
28
+ },
29
+ "patch": "commit 2ab910c08c4ed43d6fd9eb2ef9b3ff52e0293cf9\nAuthor: Florian Hahn <[email protected]>\nDate: Tue Aug 13 09:23:44 2024 +0100\n\n [LV] Check pointer user are in loop when checking for uniform pointers.\n \n Widening decisions are not set for users outside the loop. Avoid\n crashing by only calling isVectorizedMemAccessUse for users in the loop.\n \n Fixes https://github.com/llvm/llvm-project/issues/102934.\n\ndiff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\nindex 5547116133e8..0d1262fa1872 100644\n--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\n+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\n@@ -3705,7 +3705,8 @@ void LoopVectorizationCostModel::collectLoopUniforms(ElementCount VF) {\n auto *I = cast<Instruction>(V);\n auto UsersAreMemAccesses =\n llvm::all_of(I->users(), [&](User *U) -> bool {\n- return isVectorizedMemAccessUse(cast<Instruction>(U), V);\n+ auto *UI = cast<Instruction>(U);\n+ return TheLoop->contains(UI) && isVectorizedMemAccessUse(UI, V);\n });\n if (UsersAreMemAccesses)\n addToWorklistIfAllowed(I);\n",
30
+ "tests": [
31
+ {
32
+ "file": "llvm/test/Transforms/LoopVectorize/X86/gep-use-outside-loop.ll",
33
+ "commands": [
34
+ "opt -p loop-vectorize -mtriple=x86_64-apple-macosx -mcpu=skylake-avx512 -force-vector-width=4 -force-vector-interleave=1 -S %s"
35
+ ],
36
+ "tests": [
37
+ {
38
+ "test_name": "gep_use_outside_loop",
39
+ "test_body": "define void @gep_use_outside_loop(ptr noalias %dst, ptr %src) {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %gep.dst = getelementptr i16, ptr %dst, i64 %iv\n %gep.src = getelementptr i16, ptr %src, i64 %iv\n %l = load i16, ptr %gep.src, align 2\n %c = icmp eq i16 %l, 10\n br i1 %c, label %loop.latch, label %then\n\nthen: ; preds = %loop.header\n store i16 0, ptr %gep.dst, align 2\n br label %loop.latch\n\nloop.latch: ; preds = %then, %loop.header\n %iv.next = add i64 %iv, 1\n %ec = icmp eq i64 %iv.next, 99\n br i1 %ec, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n store i16 0, ptr %gep.dst, align 2\n ret void\n}\n"
40
+ },
41
+ {
42
+ "test_name": "gep_use_in_dead_block",
43
+ "test_body": "define void @gep_use_in_dead_block(ptr noalias %dst, ptr %src) {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %gep.src = getelementptr i16, ptr %src, i64 %iv\n %l = load i16, ptr %gep.src, align 2\n %c = icmp eq i16 %l, 10\n br i1 %c, label %loop.latch, label %then\n\nthen: ; preds = %loop.header\n %gep.dst = getelementptr i16, ptr %dst, i64 %iv\n store i16 0, ptr %gep.dst, align 2\n br label %loop.latch\n\ndead: ; preds = %dead\n store i16 0, ptr %gep.dst, align 2\n br label %dead\n\nloop.latch: ; preds = %then, %loop.header\n %iv.next = add i64 %iv, 1\n %ec = icmp eq i64 %iv.next, 99\n br i1 %ec, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n ret void\n}\n"
44
+ }
45
+ ]
46
+ }
47
+ ],
48
+ "issue": {
49
+ "title": "[LoopVectorize] Assertion `WideningDecision != CM_Unknown && \"Widening decision should be ready at this moment\"' failed.",
50
+ "body": "Reduced LLVM IR:\r\n```llvm ir\r\n; ModuleID = 'reduced.bc'\r\ntarget datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\r\ntarget triple = \"riscv64-unknown-linux-gnu\"\r\n\r\ndefine i32 @main(i64 %indvars.iv.i) #0 {\r\nentry:\r\n br label %for.body6.i\r\n\r\nfor.body6.i: ; preds = %for.inc34.i, %entry\r\n %indvars.iv.i1 = phi i64 [ 0, %entry ], [ %indvars.iv.next.i, %for.inc34.i ]\r\n br i1 false, label %for.body6.i.for.inc34.i_crit_edge, label %for.cond7.preheader.i\r\n\r\nfor.body6.i.for.inc34.i_crit_edge: ; preds = %for.body6.i\r\n br label %for.inc34.i\r\n\r\nfor.cond7.preheader.i: ; preds = %for.body6.i\r\n %arrayidx30.i = getelementptr [0 x i16], ptr null, i64 0, i64 %indvars.iv.i\r\n store i16 0, ptr %arrayidx30.i, align 2\r\n br label %for.inc34.i\r\n\r\nfor.body19.1.i: ; preds = %for.body19.1.i\r\n store i16 0, ptr %arrayidx30.i, align 2\r\n br label %for.body19.1.i\r\n\r\nfor.inc34.i: ; preds = %for.cond7.preheader.i, %for.body6.i.for.inc34.i_crit_edge\r\n %indvars.iv.next.i = add i64 %indvars.iv.i1, 1\r\n %exitcond.not.i = icmp eq i64 %indvars.iv.next.i, 0\r\n br i1 %exitcond.not.i, label %q.exit, label %for.body6.i\r\n\r\nq.exit: ; preds = %for.inc34.i\r\n ret i32 0\r\n}\r\n\r\nattributes #0 = { \"target-features\"=\"+64bit,+a,+c,+d,+f,+m,+relax,+v,+zicsr,+zifencei,+zmmul,+zve32f,+zve32x,+zve64d,+zve64f,+zve64x,+zvl128b,+zvl256b,+zvl32b,+zvl64b,-b,-e,-experimental-smmpm,-experimental-smnpm,-experimental-ssnpm,-experimental-sspm,-experimental-ssqosid,-experimental-supm,-experimental-zacas,-experimental-zalasr,-experimental-zicfilp,-experimental-zicfiss,-h,-shcounterenw,-shgatpa,-shtvala,-shvsatpa,-shvstvala,-shvstvecd,-smaia,-smcdeleg,-smcsrind,-smepmp,-smstateen,-ssaia,-ssccfg,-ssccptr,-sscofpmf,-sscounterenw,-sscsrind,-ssstateen,-ssstrict,-sstc,-sstvala,-sstvecd,-ssu64xl,-svade,-svadu,-svbare,-svinval,-svnapot,-svpbmt,-xcvalu,-xcvbi,-xcvbitmanip,-xcvelw,-xcvmac,-xcvmem,-xcvsimd,-xsfcease,-xsfvcp,-xsfvfnrclipxfqf,-xsfvfwmaccqqq,-xsfvqmaccdod,-xsfvqmaccqoq,-xsifivecdiscarddlone,-xsifivecflushdlone,-xtheadba,-xtheadbb,-xtheadbs,-xtheadcmo,-xtheadcondmov,-xtheadfmemidx,-xtheadmac,-xtheadmemidx,-xtheadmempair,-xtheadsync,-xtheadvdot,-xventanacondops,-xwchc,-za128rs,-za64rs,-zaamo,-zabha,-zalrsc,-zama16b,-zawrs,-zba,-zbb,-zbc,-zbkb,-zbkc,-zbkx,-zbs,-zca,-zcb,-zcd,-zce,-zcf,-zcmop,-zcmp,-zcmt,-zdinx,-zfa,-zfbfmin,-zfh,-zfhmin,-zfinx,-zhinx,-zhinxmin,-zic64b,-zicbom,-zicbop,-zicboz,-ziccamoa,-ziccif,-zicclsm,-ziccrse,-zicntr,-zicond,-zihintntl,-zihintpause,-zihpm,-zimop,-zk,-zkn,-zknd,-zkne,-zknh,-zkr,-zks,-zksed,-zksh,-zkt,-ztso,-zvbb,-zvbc,-zvfbfmin,-zvfbfwma,-zvfh,-zvfhmin,-zvkb,-zvkg,-zvkn,-zvknc,-zvkned,-zvkng,-zvknha,-zvknhb,-zvks,-zvksc,-zvksed,-zvksg,-zvksh,-zvkt,-zvl1024b,-zvl16384b,-zvl2048b,-zvl32768b,-zvl4096b,-zvl512b,-zvl65536b,-zvl8192b\" }\r\n```\r\n\r\nBacktrace:\r\n```\r\n> /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt -passes=\"loop-vectorize\" -S reduced.ll\r\nopt: /scratch/tc-testing/tc-compiler-fuzz-trunk/llvm/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:3631: llvm::LoopVectorizationCostModel::collectLoopUniforms(llvm::ElementCount)::<lambda(llvm::Instruction*, llvm::ElementCount)>: Assertion `WideningDecision != CM_Unknown && \"Widening decision should be ready at this moment\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0. Program arguments: /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt -passes=loop-vectorize -S reduced.ll\r\n1. Running pass \"function(loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>)\" on module \"reduced.ll\"\r\n2. Running pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"main\"\r\n #0 0x000059f80448a570 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2f4f570)\r\n #1 0x000059f80448798f llvm::sys::RunSignalHandlers() (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2f4c98f)\r\n #2 0x000059f804487ae5 SignalHandler(int) Signals.cpp:0:0\r\n #3 0x0000795355842520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #4 0x00007953558969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\r\n #5 0x00007953558969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10\r\n #6 0x00007953558969fc pthread_kill ./nptl/pthread_kill.c:89:10\r\n #7 0x0000795355842476 gsignal ./signal/../sysdeps/posix/raise.c:27:6\r\n #8 0x00007953558287f3 abort ./stdlib/abort.c:81:7\r\n #9 0x000079535582871b _nl_load_domain ./intl/loadmsgcat.c:1177:9\r\n#10 0x0000795355839e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n#11 0x000059f80347d610 llvm::LoopVectorizationCostModel::collectLoopUniforms(llvm::ElementCount) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1f42610)\r\n#12 0x000059f80348fa77 llvm::LoopVectorizationPlanner::plan(llvm::ElementCount, unsigned int) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1f54a77)\r\n#13 0x000059f803491b83 llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1f56b83)\r\n#14 0x000059f803494de1 llvm::LoopVectorizePass::runImpl(llvm::Function&, llvm::ScalarEvolution&, llvm::LoopInfo&, llvm::TargetTransformInfo&, llvm::DominatorTree&, llvm::BlockFrequencyInfo*, llvm::TargetLibraryInfo*, llvm::DemandedBits&, llvm::AssumptionCache&, llvm::LoopAccessInfoManager&, llvm::OptimizationRemarkEmitter&, llvm::ProfileSummaryInfo*) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1f59de1)\r\n#15 0x000059f803495497 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1f5a497)\r\n#16 0x000059f8022ff336 llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xdc4336)\r\n#17 0x000059f8042a17ff llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2d667ff)\r\n#18 0x000059f8023024c6 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xdc74c6)\r\n#19 0x000059f8042a057b llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2d6557b)\r\n#20 0x000059f8022fe7c6 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xdc37c6)\r\n#21 0x000059f80429e5dd llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2d635dd)\r\n#22 0x000059f801b38c36 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x5fdc36)\r\n#23 0x000059f801b2a881 optMain (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x5ef881)\r\n#24 0x0000795355829d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16\r\n#25 0x0000795355829e40 call_init ./csu/../csu/libc-start.c:128:20\r\n#26 0x0000795355829e40 __libc_start_main ./csu/../csu/libc-start.c:379:5\r\n#27 0x000059f801b206c5 _start (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x5e56c5)\r\nzsh: IOT instruction (core dumped) /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt\r\n```\r\n\r\nFound via fuzzer.",
51
+ "author": "patrick-rivos",
52
+ "labels": [
53
+ "vectorizers",
54
+ "crash-on-valid"
55
+ ],
56
+ "comments": []
57
+ },
58
+ "verified": true
59
+ }
dataset/102994.json ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "102994",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/102994",
4
+ "bug_type": "hang",
5
+ "base_commit": "15e915a44f0d0bf092214586d3ec86e2bb7636d7",
6
+ "knowledge_cutoff": "2024-08-13T02:57:21Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/MemCpyOpt"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "378daa6c6fd10d3704be449f2fe9c55df522a6e9",
12
+ "components": [
13
+ "MemCpyOptimizer"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": [
17
+ [
18
+ 1193,
19
+ 1198
20
+ ]
21
+ ]
22
+ },
23
+ "bug_location_funcname": {
24
+ "llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp": [
25
+ "MemCpyOptPass::processMemCpyMemCpyDependence"
26
+ ]
27
+ }
28
+ },
29
+ "patch": "commit 378daa6c6fd10d3704be449f2fe9c55df522a6e9\nAuthor: Yingwei Zheng <[email protected]>\nDate: Thu Aug 22 17:20:47 2024 +0800\n\n [MemCpyOpt] Avoid infinite loops in `MemCpyOptPass::processMemCpyMemCpyDependence` (#103218)\n \n Closes https://github.com/llvm/llvm-project/issues/102994.\n\ndiff --git a/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp b/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp\nindex 1d779128e454..3f15fa2163d2 100644\n--- a/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp\n+++ b/llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp\n@@ -1193,6 +1193,10 @@ bool MemCpyOptPass::processMemCpyMemCpyDependence(MemCpyInst *M,\n CopySourceAlign = commonAlignment(*CopySourceAlign, MForwardOffset);\n }\n \n+ // Avoid infinite loops\n+ if (BAA.isMustAlias(M->getSource(), CopySource))\n+ return false;\n+\n // Verify that the copied-from memory doesn't change in between the two\n // transfers. For example, in:\n // memcpy(a <- b)\n",
30
+ "tests": [
31
+ {
32
+ "file": "llvm/test/Transforms/MemCpyOpt/pr102994.ll",
33
+ "commands": [
34
+ "opt -S -passes=memcpyopt < %s"
35
+ ],
36
+ "tests": [
37
+ {
38
+ "test_name": "func2",
39
+ "test_body": "@g3 = external global i8, align 1\n\ndefine void @func2(ptr %p) {\nentry:\n %gep1 = getelementptr i8, ptr %p, i64 32\n %gep2 = getelementptr i8, ptr %p, i64 34\n %gep3 = getelementptr i8, ptr %p, i64 32\n call void @llvm.memcpy.p0.p0.i64(ptr %gep1, ptr %gep3, i64 32, i1 false)\n call void @llvm.memcpy.p0.p0.i64(ptr @g3, ptr %gep2, i64 1, i1 false)\n ret void\n}\n\n; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)\ndeclare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #0\n\nattributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }\n"
40
+ },
41
+ {
42
+ "test_name": "func",
43
+ "test_body": "@g1 = external global i8\n@g2 = external global [64 x i8]\n\ndefine void @func() {\nentry:\n call void @llvm.memcpy.p0.p0.i64(ptr getelementptr inbounds (i8, ptr @g2, i64 16), ptr getelementptr inbounds nuw (i8, ptr @g2, i64 16), i64 20, i1 false)\n call void @llvm.memcpy.p0.p0.i64(ptr @g1, ptr getelementptr inbounds (i8, ptr @g2, i64 24), i64 1, i1 false)\n ret void\n}\n\n; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)\ndeclare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #0\n\nattributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }\n"
44
+ }
45
+ ]
46
+ }
47
+ ],
48
+ "issue": {
49
+ "title": "[MemcpyOpt] Infinite loops when forwarding memcpy on globals",
50
+ "body": "Reproducer: https://godbolt.org/z/GKzGEKE18\r\n```\r\n; bin/opt -passes=memcpyopt reduced.ll -S\r\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\r\ntarget triple = \"x86_64-unknown-linux-gnu\"\r\n\r\n%struct.S1 = type { i64, i16, i32, %struct.S0, i8, i32, i8, i32, i8 }\r\n%struct.S0 = type { i32, i32, i32, i32, i16 }\r\n\r\n@g = external global i8\r\n@g_265 = external global %struct.S1\r\n\r\ndefine void @func() {\r\nentry:\r\n call void @llvm.memcpy.p0.p0.i64(ptr getelementptr inbounds (i8, ptr @g_265, i64 16), ptr getelementptr inbounds nuw (i8, ptr @g_265, i64 16), i64 20, i1 false)\r\n call void @llvm.memcpy.p0.p0.i64(ptr @g, ptr getelementptr inbounds (i8, ptr @g_265, i64 24), i64 1, i1 false)\r\n ret void\r\n}\r\n```\r\n```\r\nFound roots: %entry \r\nClobber starting at access 1 = MemoryDef(liveOnEntry)\r\n for instruction call void @llvm.memcpy.p0.p0.i64(ptr getelementptr inbounds (i8, ptr @g_265, i64 16), ptr getelementptr inbounds nuw (i8, ptr @g_265, i64 16), i64 20, i1 false)\r\n is 0 = MemoryDef(liveOnEntry)\r\nClobber starting at access 1 = MemoryDef(liveOnEntry)\r\n for instruction call void @llvm.memcpy.p0.p0.i64(ptr getelementptr inbounds (i8, ptr @g_265, i64 16), ptr getelementptr inbounds nuw (i8, ptr @g_265, i64 16), i64 20, i1 false)\r\n is 1 = MemoryDef(liveOnEntry)\r\nClobber starting at access 1 = MemoryDef(liveOnEntry)\r\n for instruction call void @llvm.memcpy.p0.p0.i64(ptr getelementptr inbounds (i8, ptr @g_265, i64 16), ptr getelementptr inbounds nuw (i8, ptr @g_265, i64 16), i64 20, i1 false)\r\n is 1 = MemoryDef(liveOnEntry)\r\nMemCpyOptPass: Forwarding memcpy->memcpy src:\r\n call void @llvm.memcpy.p0.p0.i64(ptr getelementptr inbounds (i8, ptr @g_265, i64 16), ptr getelementptr inbounds nuw (i8, ptr @g_265, i64 16), i64 20, i1 false)\r\n call void @llvm.memcpy.p0.p0.i64(ptr @g, ptr getelementptr inbounds (i8, ptr @g_265, i64 24), i64 1, i1 false)\r\nClobber starting at access 1 = MemoryDef(liveOnEntry)\r\n for instruction call void @llvm.memcpy.p0.p0.i64(ptr getelementptr inbounds (i8, ptr @g_265, i64 16), ptr getelementptr inbounds nuw (i8, ptr @g_265, i64 16), i64 20, i1 false)\r\n is 0 = MemoryDef(liveOnEntry)\r\nClobber starting at access 1 = MemoryDef(liveOnEntry)\r\n for instruction call void @llvm.memcpy.p0.p0.i64(ptr getelementptr inbounds (i8, ptr @g_265, i64 16), ptr getelementptr inbounds nuw (i8, ptr @g_265, i64 16), i64 20, i1 false)\r\n is 1 = MemoryDef(liveOnEntry)\r\nClobber starting at access 1 = MemoryDef(liveOnEntry)\r\n for instruction call void @llvm.memcpy.p0.p0.i64(ptr getelementptr inbounds (i8, ptr @g_265, i64 16), ptr getelementptr inbounds nuw (i8, ptr @g_265, i64 16), i64 20, i1 false)\r\n is 1 = MemoryDef(liveOnEntry)\r\nMemCpyOptPass: Forwarding memcpy->memcpy src:\r\n call void @llvm.memcpy.p0.p0.i64(ptr getelementptr inbounds (i8, ptr @g_265, i64 16), ptr getelementptr inbounds nuw (i8, ptr @g_265, i64 16), i64 20, i1 false)\r\n call void @llvm.memcpy.p0.p0.i64(ptr @g, ptr getelementptr inbounds (i8, ptr getelementptr inbounds nuw (i8, ptr @g_265, i64 16), i64 8), i64 1, i1 false)\r\n...\r\n```",
51
+ "author": "dtcxzyw",
52
+ "labels": [
53
+ "llvm:hang",
54
+ "llvm:transforms"
55
+ ],
56
+ "comments": []
57
+ },
58
+ "verified": true
59
+ }
dataset/104422.json ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "104422",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/104422",
4
+ "bug_type": "miscompilation",
5
+ "base_commit": "13a6a7975256ebdbce85f1174ae2eec735fa0d7a",
6
+ "knowledge_cutoff": "2024-08-15T09:29:27Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/SLPVectorizer"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "56140a8258a3498cfcd9f0f05c182457d43cbfd2",
12
+ "components": [
13
+ "SLPVectorizer"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
17
+ [
18
+ 15663,
19
+ 15669
20
+ ]
21
+ ]
22
+ },
23
+ "bug_location_funcname": {
24
+ "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
25
+ "BoUpSLP::collectValuesToDemote"
26
+ ]
27
+ }
28
+ },
29
+ "patch": "commit 56140a8258a3498cfcd9f0f05c182457d43cbfd2\nAuthor: Alexey Bataev <[email protected]>\nDate: Thu Aug 15 07:57:37 2024 -0700\n\n [SLP]Fix PR104422: Wrong value truncation\n \n The minbitwidth restrictions can be skipped only for immediate reduced\n values, for other nodes still need to check if external users allow\n bitwidth reduction.\n \n Fixes https://github.com/llvm/llvm-project/issues/104422\n\ndiff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\nindex 81841a8f6928..87b4ed599b5b 100644\n--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n@@ -15663,7 +15663,8 @@ bool BoUpSLP::collectValuesToDemote(\n if (any_of(E.Scalars, [&](Value *V) {\n return !all_of(V->users(), [=](User *U) {\n return getTreeEntry(U) ||\n- (UserIgnoreList && UserIgnoreList->contains(U)) ||\n+ (E.Idx == 0 && UserIgnoreList &&\n+ UserIgnoreList->contains(U)) ||\n (!isa<CmpInst>(U) && U->getType()->isSized() &&\n !U->getType()->isScalableTy() &&\n DL->getTypeSizeInBits(U->getType()) <= BitWidth);\n",
30
+ "tests": [
31
+ {
32
+ "file": "llvm/test/Transforms/SLPVectorizer/X86/operand-is-reduced-val.ll",
33
+ "commands": [
34
+ "opt -S --passes=slp-vectorizer < %s -slp-threshold=-10"
35
+ ],
36
+ "tests": [
37
+ {
38
+ "test_name": "src",
39
+ "test_body": "define i64 @src(i32 %a) {\nentry:\n %0 = sext i32 %a to i64\n %1 = add nsw i64 %0, 4294967297\n %2 = sext i32 %a to i64\n %3 = add nsw i64 %2, 4294967297\n %4 = add i64 %3, %1\n %5 = and i64 %3, 1\n %6 = add i64 %4, %5\n %7 = sext i32 %a to i64\n %8 = add nsw i64 %7, 4294967297\n %9 = add i64 %8, %6\n %10 = and i64 %8, 1\n %11 = add i64 %9, %10\n %12 = sext i32 %a to i64\n %13 = add nsw i64 %12, 4294967297\n %14 = add i64 %13, %11\n %15 = and i64 %13, 1\n %16 = add i64 %14, %15\n %17 = sext i32 %a to i64\n %18 = add nsw i64 %17, 4294967297\n %19 = add i64 %18, %16\n %20 = and i64 %18, 1\n %21 = add i64 %19, %20\n ret i64 %21\n}\n"
40
+ }
41
+ ]
42
+ }
43
+ ],
44
+ "issue": {
45
+ "title": "[SLPVectorizer] Wrong value truncation ",
46
+ "body": "- There seems to be an issue with SLPVectorizer. In the following example, a 2-byte wide value is incorrectly truncated:\r\n\r\n```\r\ndefine i64 @test(ptr addrspace(1) %arr, i32 %a) {\r\nentry:\r\n br label %loop\r\n\r\nloop:\r\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\r\n %local_1_7 = phi i64 [ 0, %entry ], [ %4, %loop ]\r\n %0 = sext i32 %a to i64\r\n %1 = add nsw i64 %0, 4294967297\r\n %2 = add i64 %1, %local_1_7\r\n %3 = and i64 %1, 1\r\n %4 = add i64 %2, %3\r\n %iv.next = add nuw nsw i64 %iv, 1\r\n %5 = icmp ugt i64 %iv, 355\r\n br i1 %5, label %exit, label %loop\r\n\r\nexit:\r\n ret i64 %4\r\n}\r\n```\r\n- In the loop we summarize the constant 4294967297 (`0x1'0000'0001`), but after running SLPVectorizer over the unrolled loop, the constant is truncated to `1`:\r\n```\r\nloop: \r\n %iv = phi i64 [ 0, %entry ], [ %iv.next.16, %loop ]\r\n %local_1_7 = phi i64 [ 0, %entry ], [ %op.rdx3, %loop ]\r\n %2 = add <16 x i32> %1, <i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1>\r\n %3 = sext <16 x i32> %2 to <16 x i64>\r\n...\r\n```\r\n- Command to reproduce: `opt -passes=loop-unroll,slp-vectorizer -unroll-count=17`\r\n- https://godbolt.org/z/zcPefTPzW\r\n- Looks like the issue was caused by the https://github.com/llvm/llvm-project/commit/7f2167868d8c1cedd3915883412b9c787a2f01db\r\n\r\n@alexey-bataev Could you please take a look?\r\n",
47
+ "author": "aleks-tmb",
48
+ "labels": [
49
+ "miscompilation",
50
+ "release:backport",
51
+ "llvm:SLPVectorizer"
52
+ ],
53
+ "comments": [
54
+ {
55
+ "author": "nikic",
56
+ "body": "This probably needs an LLVM 19 backport?\r\n\r\n/cherry-pick 65ac12d3c9877ecf5b97552364e7eead887d94eb 56140a8258a3498cfcd9f0f05c182457d43cbfd2"
57
+ }
58
+ ]
59
+ },
60
+ "verified": true
61
+ }
dataset/104637.json ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "104637",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/104637",
4
+ "bug_type": "crash",
5
+ "base_commit": "13779ec29ed724666407bd60f8c4cc8228107ea5",
6
+ "knowledge_cutoff": "2024-08-16T19:54:48Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/SLPVectorizer"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "4a0bbbcbcf6ebc87e794e7b86b9f4651bffcd806",
12
+ "components": [
13
+ "SLPVectorizer"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
17
+ [
18
+ 7144,
19
+ 7149
20
+ ]
21
+ ]
22
+ },
23
+ "bug_location_funcname": {
24
+ "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
25
+ "BoUpSLP::buildTree_rec"
26
+ ]
27
+ }
28
+ },
29
+ "patch": "commit 4a0bbbcbcf6ebc87e794e7b86b9f4651bffcd806\nAuthor: Alexey Bataev <[email protected]>\nDate: Fri Aug 16 13:24:03 2024 -0700\n\n [SLP]Fix PR104637: do not create new nodes for fully overlapped non-schedulable nodes\n \n If the scalars do not require scheduling and were already vectorized,\n but in the different order, compiler still tries to create the new node.\n It may cause the compiler crash for the gathered operands. Instead need\n to consider such nodes as full overlap and just reshuffle vectorized\n node.\n \n Fixes https://github.com/llvm/llvm-project/issues/104637\n\ndiff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\nindex 667d0df781aa..9ecd8160a978 100644\n--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n@@ -7144,6 +7144,21 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth,\n ReuseShuffleIndices);\n return;\n }\n+ SmallPtrSet<const TreeEntry *, 4> Nodes;\n+ Nodes.insert(getTreeEntry(S.OpValue));\n+ for (const TreeEntry *E : MultiNodeScalars.lookup(S.OpValue))\n+ Nodes.insert(E);\n+ SmallPtrSet<Value *, 8> Values(VL.begin(), VL.end());\n+ if (any_of(Nodes, [&](const TreeEntry *E) {\n+ return all_of(E->Scalars,\n+ [&](Value *V) { return Values.contains(V); });\n+ })) {\n+ LLVM_DEBUG(dbgs() << \"SLP: Gathering due to full overlap.\\n\");\n+ if (TryToFindDuplicates(S))\n+ newTreeEntry(VL, std::nullopt /*not vectorized*/, S, UserTreeIdx,\n+ ReuseShuffleIndices);\n+ return;\n+ }\n } else {\n // Record the reuse of the tree node. FIXME, currently this is only used\n // to properly draw the graph rather than for the actual vectorization.\n",
30
+ "tests": [
31
+ {
32
+ "file": "llvm/test/Transforms/SLPVectorizer/X86/full-non-schedulable-overlap.ll",
33
+ "commands": [
34
+ "opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu < %s"
35
+ ],
36
+ "tests": [
37
+ {
38
+ "test_name": "test",
39
+ "test_body": "define void @test(double %v) {\nentry:\n %mul.3 = fmul double 0.000000e+00, %v\n %mul.4 = fmul double 0.000000e+00, 0.000000e+00\n br label %loop\n\nloop: ; preds = %loop, %entry\n %t48.0 = phi double [ 0.000000e+00, %entry ], [ %5, %loop ]\n %t50.02 = phi double [ 0.000000e+00, %entry ], [ %3, %loop ]\n %t52.0 = phi double [ 0.000000e+00, %entry ], [ %7, %loop ]\n %0 = fmul double %t52.0, %mul.3\n %1 = fmul double %t48.0, %mul.4\n %2 = fadd double %1, %0\n %3 = fadd double %2, %v\n %4 = fmul double 0.000000e+00, %mul.3\n %5 = fadd double 0.000000e+00, %4\n %6 = fmul double 0.000000e+00, %mul.4\n %7 = fadd double 0.000000e+00, %6\n br label %loop\n}\n"
40
+ }
41
+ ]
42
+ }
43
+ ],
44
+ "issue": {
45
+ "title": "SLP Vectorizer crash due to commit ca654acc16c43191228eadfec8f7241dca10b0c3",
46
+ "body": "ca654acc16c43191228eadfec8f7241dca10b0c3 change in SLP Vectorizer causes a crash for this test case:\r\n\r\n```\r\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\r\ntarget triple = \"x86_64-unknown-linux-gnu\"\r\n\r\ndefine void @a_(double %c__fetch.3) {\r\nalloca_0:\r\n %mul.3 = fmul double 0.000000e+00, %c__fetch.3\r\n %mul.4 = fmul double 0.000000e+00, 0.000000e+00\r\n br label %loop.69\r\n\r\nloop.69: ; preds = %loop.69, %alloca_0\r\n %t48.0 = phi double [ 0.000000e+00, %alloca_0 ], [ %5, %loop.69 ]\r\n %t50.0 = phi double [ 0.000000e+00, %alloca_0 ], [ %3, %loop.69 ]\r\n %t52.0 = phi double [ 0.000000e+00, %alloca_0 ], [ %7, %loop.69 ]\r\n %0 = fmul double %t52.0, %mul.3\r\n %1 = fmul double %t48.0, %mul.4\r\n %2 = fadd double %1, %0\r\n %3 = fadd double %2, 0.000000e+00\r\n %4 = fmul double 0.000000e+00, %mul.3\r\n %5 = fadd double 0.000000e+00, %4\r\n %6 = fmul double 0.000000e+00, %mul.4\r\n %7 = fadd double 0.000000e+00, %6\r\n br label %loop.69\r\n}\r\n```\r\n\r\nAfter slp-vectorizer pass IR is being transformed to as incorrect one:\r\n```\r\ndefine void @a_(double %c__fetch.3) {\r\nalloca_0:\r\n %0 = shufflevector <2 x double> %2, <2 x double> <double 0.000000e+00, double poison>, <2 x i32> <i32 2, i32 0>\r\n %1 = fmul <2 x double> zeroinitializer, %0\r\n %2 = insertelement <2 x double> <double poison, double 0.000000e+00>, double %c__fetch.3, i32 0\r\n %3 = fmul <2 x double> zeroinitializer, %2\r\n br label %loop.69\r\n\r\nloop.69: ; preds = %loop.69, %alloca_0\r\n %t50.0 = phi double [ 0.000000e+00, %alloca_0 ], [ %9, %loop.69 ]\r\n %4 = phi <2 x double> [ zeroinitializer, %alloca_0 ], [ %11, %loop.69 ]\r\n %5 = fmul <2 x double> %4, %1\r\n %6 = extractelement <2 x double> %5, i32 0\r\n %7 = extractelement <2 x double> %5, i32 1\r\n %8 = fadd double %6, %7\r\n %9 = fadd double %8, 0.000000e+00\r\n %10 = fmul <2 x double> zeroinitializer, %3\r\n %11 = fadd <2 x double> zeroinitializer, %10\r\n br label %loop.69\r\n}\r\n```\r\n\r\nError message:\r\n\r\n```\r\nInstruction does not dominate all uses!\r\n %2 = insertelement <2 x double> <double poison, double 0.000000e+00>, double %c__fetch.3, i32 0\r\n %0 = shufflevector <2 x double> %2, <2 x double> <double 0.000000e+00, double poison>, <2 x i32> <i32 2, i32 0>\r\nLLVM ERROR: Broken module found, compilation aborted!\r\n```\r\n\r\nReverting the mentioned commit makes this test pass. @alexey-bataev could you please take a look?\r\n",
47
+ "author": "ivankelarev",
48
+ "labels": [
49
+ "llvm:SLPVectorizer",
50
+ "crash"
51
+ ],
52
+ "comments": [
53
+ {
54
+ "author": "ivankelarev",
55
+ "body": "Update: It appears that the mentioned commit merely obscures a more fundamental issue. The following test continues to fail even after the commit has been reverted:\r\n\r\n```\r\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\r\ntarget triple = \"x86_64-unknown-linux-gnu\"\r\n\r\ndefine void @a_(double %c__fetch.3) {\r\nalloca_0:\r\n %mul.3 = fmul double 0.000000e+00, %c__fetch.3\r\n %mul.4 = fmul double 0.000000e+00, 0.000000e+00\r\n br label %loop.69\r\n\r\nloop.69: ; preds = %loop.69, %alloca_0\r\n %t48.0 = phi double [ 0.000000e+00, %alloca_0 ], [ %5, %loop.69 ]\r\n %t50.02 = phi double [ 0.000000e+00, %alloca_0 ], [ %3, %loop.69 ]\r\n %t52.0 = phi double [ 0.000000e+00, %alloca_0 ], [ %7, %loop.69 ]\r\n %0 = fmul double %t52.0, %mul.3\r\n %1 = fmul double %t48.0, %mul.4\r\n %2 = fadd double %1, %0\r\n %3 = fadd double %2, %c__fetch.3\r\n %4 = fmul double 0.000000e+00, %mul.3\r\n %5 = fadd double 0.000000e+00, %4\r\n %6 = fmul double 0.000000e+00, %mul.4\r\n %7 = fadd double 0.000000e+00, %6\r\n br label %loop.69\r\n}\r\n```"
56
+ },
57
+ {
58
+ "author": "ivankelarev",
59
+ "body": "It appears that the actual problematic commit is the following:\r\n\r\n```\r\ncommit 66775f8ccdcc8264ef349518e1c59d96d4227823\r\nAuthor: Alexey Bataev <[email protected]>\r\nDate: Mon Oct 16 12:50:29 2023 -0700\r\n\r\n [SLP]Fix PR69196: Instruction does not dominate all uses\r\n \r\n During emission of the postponed gathers, need to insert them before\r\n user instruction to avoid use before definition crash.\r\n```\r\nFor compiler builds prior to this change, the test passes, and the correct code is generated as follows:\r\n```\r\ndefine void @a_(double %c__fetch.3) {\r\nalloca_0:\r\n %0 = insertelement <2 x double> <double poison, double 0.000000e+00>, double %c__fetch.3, i32 0\r\n %1 = fmul <2 x double> zeroinitializer, %0\r\n %2 = shufflevector <2 x double> %0, <2 x double> <double 0.000000e+00, double poison>, <2 x i32> <i32 2, i32 0>\r\n %3 = fmul <2 x double> zeroinitializer, %2\r\n br label %loop.69\r\n\r\nloop.69: ; preds = %loop.69, %alloca_0\r\n %t50.02 = phi double [ 0.000000e+00, %alloca_0 ], [ %9, %loop.69 ]\r\n %4 = phi <2 x double> [ zeroinitializer, %alloca_0 ], [ %11, %loop.69 ]\r\n %5 = fmul <2 x double> %4, %3\r\n %6 = extractelement <2 x double> %5, i32 0\r\n %7 = extractelement <2 x double> %5, i32 1\r\n %8 = fadd double %6, %7\r\n %9 = fadd double %8, %c__fetch.3\r\n %10 = fmul <2 x double> zeroinitializer, %1\r\n %11 = fadd <2 x double> zeroinitializer, %10\r\n br label %loop.69\r\n}\r\n```\r\n\r\nAlthough the commit may seem quite old, there is a test case for which it causes incorrect code generation. Alexey, could you please revisit this change and address the code generation issue for the provided test case?"
60
+ },
61
+ {
62
+ "author": "alexey-bataev",
63
+ "body": "> It appears that the actual problematic commit is the following:\r\n> \r\n> ```\r\n> commit 66775f8ccdcc8264ef349518e1c59d96d4227823\r\n> Author: Alexey Bataev <[email protected]>\r\n> Date: Mon Oct 16 12:50:29 2023 -0700\r\n> \r\n> [SLP]Fix PR69196: Instruction does not dominate all uses\r\n> \r\n> During emission of the postponed gathers, need to insert them before\r\n> user instruction to avoid use before definition crash.\r\n> ```\r\n> \r\n> For compiler builds prior to this change, the test passes, and the correct code is generated as follows:\r\n> \r\n> ```\r\n> define void @a_(double %c__fetch.3) {\r\n> alloca_0:\r\n> %0 = insertelement <2 x double> <double poison, double 0.000000e+00>, double %c__fetch.3, i32 0\r\n> %1 = fmul <2 x double> zeroinitializer, %0\r\n> %2 = shufflevector <2 x double> %0, <2 x double> <double 0.000000e+00, double poison>, <2 x i32> <i32 2, i32 0>\r\n> %3 = fmul <2 x double> zeroinitializer, %2\r\n> br label %loop.69\r\n> \r\n> loop.69: ; preds = %loop.69, %alloca_0\r\n> %t50.02 = phi double [ 0.000000e+00, %alloca_0 ], [ %9, %loop.69 ]\r\n> %4 = phi <2 x double> [ zeroinitializer, %alloca_0 ], [ %11, %loop.69 ]\r\n> %5 = fmul <2 x double> %4, %3\r\n> %6 = extractelement <2 x double> %5, i32 0\r\n> %7 = extractelement <2 x double> %5, i32 1\r\n> %8 = fadd double %6, %7\r\n> %9 = fadd double %8, %c__fetch.3\r\n> %10 = fmul <2 x double> zeroinitializer, %1\r\n> %11 = fadd <2 x double> zeroinitializer, %10\r\n> br label %loop.69\r\n> }\r\n> ```\r\n> \r\n> Although the commit may seem quite old, there is a test case for which it causes incorrect code generation. Alexey, could you please revisit this change and address the code generation issue for the provided test case?\r\n\r\nThe actual problem is not in this commit, the fix is almost ready"
64
+ }
65
+ ]
66
+ },
67
+ "verified": true
68
+ }
dataset/104714.json ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "104714",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/104714",
4
+ "bug_type": "crash",
5
+ "base_commit": "a2d8743cc86f96f6b1cbd85798328bd3fb2bf4de",
6
+ "knowledge_cutoff": "2024-08-18T15:54:27Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/LoopVectorize"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "cb4efe1d078144a72306732a56afea3885650e8d",
12
+ "components": [
13
+ "LoopVectorize"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
17
+ [
18
+ 7237,
19
+ 7242
20
+ ],
21
+ [
22
+ 7292,
23
+ 7298
24
+ ]
25
+ ]
26
+ },
27
+ "bug_location_funcname": {
28
+ "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
29
+ "LoopVectorizationPlanner::computeBestVF",
30
+ "LoopVectorizationPlanner::cost"
31
+ ]
32
+ }
33
+ },
34
+ "patch": "commit cb4efe1d078144a72306732a56afea3885650e8d\nAuthor: Florian Hahn <[email protected]>\nDate: Thu Aug 22 21:38:06 2024 +0100\n\n [VPlan] Don't trigger VF assertion if VPlan has extra simplifications.\n \n There are cases where VPlans contain some simplifications that are very\n hard to accurately account for up-front in the legacy cost model. Those\n cases are caused by un-simplified inputs, which trigger the assert\n ensuring both the legacy and VPlan-based cost model agree on the VF.\n \n To avoid false positives due to missed simplifications in general, only\n trigger the assert if the chosen VPlan doesn't contain any additional\n simplifications.\n \n Fixes https://github.com/llvm/llvm-project/issues/104714.\n Fixes https://github.com/llvm/llvm-project/issues/105713.\n\ndiff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\nindex 8e9324ba718b..32e8f3312578 100644\n--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\n+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\n@@ -7237,6 +7237,56 @@ InstructionCost LoopVectorizationPlanner::cost(VPlan &Plan,\n return Cost;\n }\n \n+/// Return true if the original loop \\ TheLoop contains any instructions that do\n+/// not have corresponding recipes in \\p Plan and are not marked to be ignored\n+/// in \\p CostCtx. This means the VPlan contains simplification that the legacy\n+/// cost-model did not account for.\n+static bool\n+planContainsAdditionalSimplifications(VPlan &Plan, ElementCount VF,\n+ VPCostContext &CostCtx, Loop *TheLoop,\n+ LoopVectorizationCostModel &CM) {\n+ // First collect all instructions for the recipes in Plan.\n+ auto GetInstructionForCost = [](const VPRecipeBase *R) -> Instruction * {\n+ if (auto *S = dyn_cast<VPSingleDefRecipe>(R))\n+ return dyn_cast_or_null<Instruction>(S->getUnderlyingValue());\n+ if (auto *WidenMem = dyn_cast<VPWidenMemoryRecipe>(R))\n+ return &WidenMem->getIngredient();\n+ return nullptr;\n+ };\n+\n+ DenseSet<Instruction *> SeenInstrs;\n+ auto Iter = vp_depth_first_deep(Plan.getEntry());\n+ for (VPBasicBlock *VPBB : VPBlockUtils::blocksOnly<VPBasicBlock>(Iter)) {\n+ for (VPRecipeBase &R : *VPBB) {\n+ if (auto *IR = dyn_cast<VPInterleaveRecipe>(&R)) {\n+ auto *IG = IR->getInterleaveGroup();\n+ unsigned NumMembers = IG->getNumMembers();\n+ for (unsigned I = 0; I != NumMembers; ++I) {\n+ if (Instruction *M = IG->getMember(I))\n+ SeenInstrs.insert(M);\n+ }\n+ continue;\n+ }\n+ if (Instruction *UI = GetInstructionForCost(&R))\n+ SeenInstrs.insert(UI);\n+ }\n+ }\n+\n+ // Return true if the loop contains any instructions that are not also part of\n+ // the VPlan or are skipped for VPlan-based cost computations. This indicates\n+ // that the VPlan contains extra simplifications.\n+ return any_of(\n+ TheLoop->blocks(), [&SeenInstrs, VF, &CostCtx, &CM](BasicBlock *BB) {\n+ return any_of(*BB, [&SeenInstrs, VF, &CostCtx, &CM](Instruction &I) {\n+ if (isa<PHINode>(&I))\n+ return false;\n+ return !SeenInstrs.contains(&I) &&\n+ !CostCtx.skipCostComputation(&I, true) &&\n+ !CM.canTruncateToMinimalBitwidth(&I, VF);\n+ });\n+ });\n+}\n+\n VectorizationFactor LoopVectorizationPlanner::computeBestVF() {\n if (VPlans.empty())\n return VectorizationFactor::Disabled();\n@@ -7292,7 +7342,20 @@ VectorizationFactor LoopVectorizationPlanner::computeBestVF() {\n // cost-model and will be retired once the VPlan-based cost-model is\n // stabilized.\n VectorizationFactor LegacyVF = selectVectorizationFactor();\n- assert(BestFactor.Width == LegacyVF.Width &&\n+ VPlan &BestPlan = getPlanFor(BestFactor.Width);\n+\n+ // Pre-compute the cost and use it to check if BestPlan contains any\n+ // simplifications not accounted for in the legacy cost model. If that's the\n+ // case, don't trigger the assertion, as the extra simplifications may cause a\n+ // different VF to be picked by the VPlan-based cost model.\n+ LLVMContext &LLVMCtx = OrigLoop->getHeader()->getContext();\n+ VPCostContext CostCtx(CM.TTI, *CM.TLI, Legal->getWidestInductionType(),\n+ LLVMCtx, CM);\n+ precomputeCosts(BestPlan, BestFactor.Width, CostCtx);\n+ assert((BestFactor.Width == LegacyVF.Width ||\n+ planContainsAdditionalSimplifications(getPlanFor(BestFactor.Width),\n+ BestFactor.Width, CostCtx,\n+ OrigLoop, CM)) &&\n \" VPlan cost model and legacy cost model disagreed\");\n assert((BestFactor.Width.isScalar() || BestFactor.ScalarCost > 0) &&\n \"when vectorizing, the scalar cost must be computed.\");\n",
35
+ "tests": [
36
+ {
37
+ "file": "llvm/test/Transforms/LoopVectorize/RISCV/blocks-with-dead-instructions.ll",
38
+ "commands": [
39
+ "opt -p loop-vectorize -S %s"
40
+ ],
41
+ "tests": [
42
+ {
43
+ "test_name": "empty_block_with_phi_2",
44
+ "test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\ndefine void @empty_block_with_phi_2(ptr %src, i64 %N) #0 {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %xor1315 = phi i32 [ 1, %entry ], [ %xor, %loop.latch ]\n %xor = xor i32 0, 0\n %gep = getelementptr i16, ptr %src, i64 %iv\n %l = load i16, ptr %gep, align 2\n %c = icmp eq i16 %l, 0\n br i1 %c, label %loop.latch, label %else\n\nelse: ; preds = %loop.header\n br label %loop.latch\n\nloop.latch: ; preds = %else, %loop.header\n %p = phi i16 [ %l, %loop.header ], [ 99, %else ]\n store i16 %p, ptr %gep, align 2\n %iv.next = add nsw i64 %iv, 1\n %0 = icmp eq i64 %iv.next, %N\n br i1 %0, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+64bit,+v\" }\n"
45
+ },
46
+ {
47
+ "test_name": "dead_load_in_block",
48
+ "test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\ndefine void @dead_load_in_block(ptr %dst, ptr %src, i8 %N, i64 %x) #0 {\nentry:\n %N.ext = zext i8 %N to i64\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %l.0 = load i32, ptr %src, align 4\n %c.0 = icmp eq i32 %l.0, 0\n br i1 %c.0, label %loop.latch, label %then\n\nthen: ; preds = %loop.header\n %gep.src.x = getelementptr i32, ptr %src, i64 %x\n %l.dead = load i32, ptr %gep.src.x, align 4\n br label %loop.latch\n\nloop.latch: ; preds = %then, %loop.header\n %gep.dst = getelementptr i32, ptr %dst, i64 %iv\n store i32 0, ptr %gep.dst, align 4\n %iv.next = add i64 %iv, 3\n %cmp = icmp ult i64 %iv, %N.ext\n br i1 %cmp, label %loop.header, label %exit\n\nexit: ; preds = %loop.latch\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+64bit,+v\" }\n"
49
+ },
50
+ {
51
+ "test_name": "multiple_blocks_with_dead_insts_3",
52
+ "test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\ndefine void @multiple_blocks_with_dead_insts_3(ptr %src) #0 {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %xor1315 = phi i16 [ 0, %entry ], [ %xor, %loop.latch ]\n %xor = xor i16 0, 0\n %gep = getelementptr i16, ptr %src, i64 %iv\n %l = load i16, ptr %gep, align 2\n %c = icmp eq i16 %l, 0\n br i1 %c, label %then, label %else\n\nthen: ; preds = %loop.header\n %dead.gep.1 = getelementptr i64, ptr %src, i64 %iv\n br label %loop.latch\n\nelse: ; preds = %loop.header\n %dead.gep.2 = getelementptr i64, ptr %src, i64 %iv\n br label %loop.latch\n\nloop.latch: ; preds = %else, %then\n store i16 %xor, ptr %gep, align 2\n %iv.next = add nsw i64 %iv, 3\n %ec = icmp eq i64 %iv.next, 1000\n br i1 %ec, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+64bit,+v\" }\n"
53
+ },
54
+ {
55
+ "test_name": "multiple_blocks_with_dead_insts_4",
56
+ "test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\ndefine void @multiple_blocks_with_dead_insts_4(ptr %src, i64 %N) #0 {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %xor1315 = phi i16 [ 1, %entry ], [ %xor, %loop.latch ]\n %xor = xor i16 0, 0\n %gep = getelementptr i16, ptr %src, i64 %iv\n %l = load i16, ptr %gep, align 2\n %c = icmp eq i16 %l, 0\n br i1 %c, label %then, label %else\n\nthen: ; preds = %loop.header\n br label %then.1\n\nthen.1: ; preds = %then\n %dead.gep.1 = getelementptr i64, ptr %src, i64 %iv\n br label %loop.latch\n\nelse: ; preds = %loop.header\n %dead.gep.2 = getelementptr i64, ptr %src, i64 %iv\n br label %loop.latch\n\nloop.latch: ; preds = %else, %then.1\n store i16 %xor, ptr %gep, align 2\n %iv.next = add nsw i64 %iv, 3\n %ec = icmp eq i64 %iv.next, %N\n br i1 %ec, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+64bit,+v\" }\n"
57
+ },
58
+ {
59
+ "test_name": "empty_block_with_phi_1",
60
+ "test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\ndefine void @empty_block_with_phi_1(ptr %src, i64 %N) #0 {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %xor1315 = phi i32 [ 1, %entry ], [ %xor, %loop.latch ]\n %xor = xor i32 0, 0\n %gep = getelementptr i16, ptr %src, i64 %iv\n %l = load i16, ptr %gep, align 2\n %c = icmp eq i16 %l, 0\n br i1 %c, label %then, label %loop.latch\n\nthen: ; preds = %loop.header\n br label %loop.latch\n\nloop.latch: ; preds = %then, %loop.header\n %p = phi i16 [ %l, %loop.header ], [ 99, %then ]\n store i16 %p, ptr %gep, align 2\n %iv.next = add nsw i64 %iv, 1\n %0 = icmp eq i64 %iv.next, %N\n br i1 %0, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+64bit,+v\" }\n"
61
+ },
62
+ {
63
+ "test_name": "block_with_dead_inst_2",
64
+ "test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\ndefine void @block_with_dead_inst_2(ptr %src) #0 {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %xor1315 = phi i16 [ 0, %entry ], [ %xor, %loop.latch ]\n %xor = xor i16 0, 0\n %gep = getelementptr i16, ptr %src, i64 %iv\n %l = load i16, ptr %gep, align 2\n %c = icmp eq i16 %l, 0\n br i1 %c, label %loop.latch, label %else\n\nelse: ; preds = %loop.header\n %dead.gep = getelementptr i64, ptr %src, i64 %iv\n br label %loop.latch\n\nloop.latch: ; preds = %else, %loop.header\n store i16 %xor, ptr %gep, align 2\n %iv.next = add nsw i64 %iv, 3\n %ec = icmp eq i64 %iv.next, 1000\n br i1 %ec, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+64bit,+v\" }\n"
65
+ },
66
+ {
67
+ "test_name": "multiple_blocks_with_dead_inst_multiple_successors_6",
68
+ "test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\ndefine void @multiple_blocks_with_dead_inst_multiple_successors_6(ptr %src, i1 %ic, i64 %N) #0 {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %xor1315 = phi i16 [ 1, %entry ], [ %xor, %loop.latch ]\n %xor = xor i16 0, 0\n %gep = getelementptr i16, ptr %src, i64 %iv\n %l = load i16, ptr %gep, align 2\n %c = icmp eq i16 %l, 0\n br i1 %c, label %then, label %else\n\nthen: ; preds = %loop.header\n br i1 %ic, label %then.1, label %else\n\nthen.1: ; preds = %then\n %dead.gep.1 = getelementptr i64, ptr %src, i64 %iv\n br label %loop.latch\n\nelse: ; preds = %then, %loop.header\n br label %else.2\n\nelse.2: ; preds = %else\n %dead.gep.2 = getelementptr i64, ptr %src, i64 %iv\n br label %loop.latch\n\nloop.latch: ; preds = %else.2, %then.1\n store i16 %xor, ptr %gep, align 2\n %iv.next = add nsw i64 %iv, 3\n %ec = icmp eq i64 %iv.next, %N\n br i1 %ec, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+64bit,+v\" }\n"
69
+ },
70
+ {
71
+ "test_name": "multiple_blocks_with_dead_inst_multiple_successors_5",
72
+ "test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\ndefine void @multiple_blocks_with_dead_inst_multiple_successors_5(ptr %src) #0 {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %xor1315 = phi i16 [ 1, %entry ], [ %xor, %loop.latch ]\n %xor = xor i16 0, 0\n %gep = getelementptr i16, ptr %src, i64 %iv\n %l = load i16, ptr %gep, align 2\n %c = icmp eq i16 %l, 0\n br i1 %c, label %then, label %else\n\nthen: ; preds = %loop.header\n br label %then.1\n\nthen.1: ; preds = %then\n %dead.gep.1 = getelementptr i64, ptr %src, i64 %iv\n br label %loop.latch\n\nelse: ; preds = %loop.header\n br label %else.2\n\nelse.2: ; preds = %else\n %dead.gep.2 = getelementptr i64, ptr %src, i64 %iv\n br label %loop.latch\n\nloop.latch: ; preds = %else.2, %then.1\n store i16 %xor, ptr %gep, align 2\n %iv.next = add nsw i64 %iv, 3\n %ec = icmp eq i64 %iv.next, 1000\n br i1 %ec, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+64bit,+v\" }\n"
73
+ },
74
+ {
75
+ "test_name": "block_with_dead_inst_1",
76
+ "test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\ndefine void @block_with_dead_inst_1(ptr %src, i64 %N) #0 {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %xor1315 = phi i16 [ 1, %entry ], [ %xor, %loop.latch ]\n %xor = xor i16 0, 0\n %gep = getelementptr i16, ptr %src, i64 %iv\n %l = load i16, ptr %gep, align 2\n %c = icmp eq i16 %l, 0\n br i1 %c, label %then, label %loop.latch\n\nthen: ; preds = %loop.header\n %dead.gep = getelementptr i64, ptr %src, i64 %iv\n br label %loop.latch\n\nloop.latch: ; preds = %then, %loop.header\n store i16 %xor, ptr %gep, align 2\n %iv.next = add nsw i64 %iv, 3\n %0 = icmp eq i64 %iv.next, %N\n br i1 %0, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+64bit,+v\" }\n"
77
+ }
78
+ ]
79
+ }
80
+ ],
81
+ "issue": {
82
+ "title": "[VPlan] Assertion `VF.Width == BestVF && \"VPlan cost model and legacy cost model disagreed\"' failed.",
83
+ "body": "Tested using d082f1f37d8cb7a0c6875537ba873a631b154d53\r\n\r\nC Testcase:\r\n```c\r\nint a;\r\nextern int b[];\r\nsigned char c;\r\nint d[1];\r\nvoid e() {\r\n for (short f = 2; f < c; f += 3) {\r\n a = ({ d[f - 1]; }) ? d[f] : 0;\r\n b[f] = 0;\r\n }\r\n}\r\n```\r\nCommand:\r\n```\r\n/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/clang -march=rv64gcv_zvl256b -O3 red.c -o /dev/null\r\n```\r\n\r\nTestcase:\r\n```llvm ir\r\n; ModuleID = 'reduced.bc'\r\ntarget datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\r\ntarget triple = \"riscv64-unknown-linux-gnu\"\r\n\r\ndefine void @e(i8 %0, i64 %indvars.iv) #0 {\r\nentry:\r\n %1 = zext i8 %0 to i64\r\n br label %for.body\r\n\r\nfor.cond.for.cond.cleanup_crit_edge: ; preds = %cond.end\r\n ret void\r\n\r\nfor.body: ; preds = %cond.end, %entry\r\n %indvars.iv1 = phi i64 [ 0, %entry ], [ %indvars.iv.next, %cond.end ]\r\n %sub = add i64 0, 0\r\n %arrayidx = getelementptr [1 x i32], ptr null, i64 0, i64 %sub\r\n %2 = load i32, ptr %arrayidx, align 4\r\n %tobool.not = icmp eq i32 %2, 0\r\n br i1 %tobool.not, label %cond.end, label %cond.true\r\n\r\ncond.true: ; preds = %for.body\r\n %arrayidx5 = getelementptr [1 x i32], ptr null, i64 0, i64 %indvars.iv\r\n %3 = load i32, ptr %arrayidx5, align 4\r\n br label %cond.end\r\n\r\ncond.end: ; preds = %cond.true, %for.body\r\n %arrayidx7 = getelementptr [0 x i32], ptr null, i64 0, i64 %indvars.iv1\r\n store i32 0, ptr %arrayidx7, align 4\r\n %indvars.iv.next = add i64 %indvars.iv1, 3\r\n %cmp = icmp ult i64 %indvars.iv1, %1\r\n br i1 %cmp, label %for.body, label %for.cond.for.cond.cleanup_crit_edge\r\n}\r\n\r\nattributes #0 = { \"target-features\"=\"+64bit,+a,+c,+d,+f,+m,+relax,+v,+zicsr,+zifencei,+zmmul,+zve32f,+zve32x,+zve64d,+zve64f,+zve64x,+zvl128b,+zvl256b,+zvl32b,+zvl64b,-b,-e,-experimental-smmpm,-experimental-smnpm,-experimental-ssnpm,-experimental-sspm,-experimental-ssqosid,-experimental-supm,-experimental-zacas,-experimental-zalasr,-experimental-zicfilp,-experimental-zicfiss,-h,-shcounterenw,-shgatpa,-shtvala,-shvsatpa,-shvstvala,-shvstvecd,-smaia,-smcdeleg,-smcsrind,-smepmp,-smstateen,-ssaia,-ssccfg,-ssccptr,-sscofpmf,-sscounterenw,-sscsrind,-ssstateen,-ssstrict,-sstc,-sstvala,-sstvecd,-ssu64xl,-svade,-svadu,-svbare,-svinval,-svnapot,-svpbmt,-xcvalu,-xcvbi,-xcvbitmanip,-xcvelw,-xcvmac,-xcvmem,-xcvsimd,-xsfcease,-xsfvcp,-xsfvfnrclipxfqf,-xsfvfwmaccqqq,-xsfvqmaccdod,-xsfvqmaccqoq,-xsifivecdiscarddlone,-xsifivecflushdlone,-xtheadba,-xtheadbb,-xtheadbs,-xtheadcmo,-xtheadcondmov,-xtheadfmemidx,-xtheadmac,-xtheadmemidx,-xtheadmempair,-xtheadsync,-xtheadvdot,-xventanacondops,-xwchc,-za128rs,-za64rs,-zaamo,-zabha,-zalrsc,-zama16b,-zawrs,-zba,-zbb,-zbc,-zbkb,-zbkc,-zbkx,-zbs,-zca,-zcb,-zcd,-zce,-zcf,-zcmop,-zcmp,-zcmt,-zdinx,-zfa,-zfbfmin,-zfh,-zfhmin,-zfinx,-zhinx,-zhinxmin,-zic64b,-zicbom,-zicbop,-zicboz,-ziccamoa,-ziccif,-zicclsm,-ziccrse,-zicntr,-zicond,-zihintntl,-zihintpause,-zihpm,-zimop,-zk,-zkn,-zknd,-zkne,-zknh,-zkr,-zks,-zksed,-zksh,-zkt,-ztso,-zvbb,-zvbc,-zvfbfmin,-zvfbfwma,-zvfh,-zvfhmin,-zvkb,-zvkg,-zvkn,-zvknc,-zvkned,-zvkng,-zvknha,-zvknhb,-zvks,-zvksc,-zvksed,-zvksg,-zvksh,-zvkt,-zvl1024b,-zvl16384b,-zvl2048b,-zvl32768b,-zvl4096b,-zvl512b,-zvl65536b,-zvl8192b\" }\r\n```\r\n\r\nCommand/backtrace:\r\n```\r\n> /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt -passes loop-vectorize reduced.ll -S\r\nopt: /scratch/tc-testing/tc-compiler-fuzz-trunk/llvm/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:10037: bool llvm::LoopVectorizePass::processLoop(llvm::Loop*): Assertion `VF.Width == BestVF && \"VPlan cost model and legacy cost model disagreed\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0. Program arguments: /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt -passes loop-vectorize reduced.ll -S\r\n1. Running pass \"function(loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>)\" on module \"reduced.ll\"\r\n2. Running pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"e\"\r\n #0 0x000063e889a673c0 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2ff63c0)\r\n #1 0x000063e889a647df llvm::sys::RunSignalHandlers() (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2ff37df)\r\n #2 0x000063e889a64935 SignalHandler(int) Signals.cpp:0:0\r\n #3 0x00007a5322242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #4 0x00007a53222969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\r\n #5 0x00007a53222969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10\r\n #6 0x00007a53222969fc pthread_kill ./nptl/pthread_kill.c:89:10\r\n #7 0x00007a5322242476 gsignal ./signal/../sysdeps/posix/raise.c:27:6\r\n #8 0x00007a53222287f3 abort ./stdlib/abort.c:81:7\r\n #9 0x00007a532222871b _nl_load_domain ./intl/loadmsgcat.c:1177:9\r\n#10 0x00007a5322239e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n#11 0x000063e888a5ba9a llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1feaa9a)\r\n#12 0x000063e888a5df51 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1fecf51)\r\n#13 0x000063e888a5e5c7 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1fed5c7)\r\n#14 0x000063e8878c6096 llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xe55096)\r\n#15 0x000063e88987deef llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2e0ceef)\r\n#16 0x000063e8878c91d6 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xe581d6)\r\n#17 0x000063e88987cc6b llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2e0bc6b)\r\n#18 0x000063e8878c54c6 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xe544c6)\r\n#19 0x000063e88987accd llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2e09ccd)\r\n#20 0x000063e8870f3eb6 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x682eb6)\r\n#21 0x000063e8870e5c41 optMain (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x674c41)\r\n#22 0x00007a5322229d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16\r\n#23 0x00007a5322229e40 call_init ./csu/../csu/libc-start.c:128:20\r\n#24 0x00007a5322229e40 __libc_start_main ./csu/../csu/libc-start.c:379:5\r\n#25 0x000063e8870dbff5 _start (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x66aff5)\r\nzsh: IOT instruction (core dumped) /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt\r\n```\r\nGodbolt: https://godbolt.org/z/v1nbzWqMb\r\n\r\nFound via fuzzer.\r\n\r\ncc @fhahn ",
84
+ "author": "patrick-rivos",
85
+ "labels": [
86
+ "vectorizers",
87
+ "crash"
88
+ ],
89
+ "comments": [
90
+ {
91
+ "author": "patrick-rivos",
92
+ "body": "Linking some meta-discussion about the assert here: https://github.com/llvm/llvm-project/issues/100591"
93
+ },
94
+ {
95
+ "author": "zhendongsu",
96
+ "body": "Some additional reproducers on x86_64-linux-gnu in case they are of help:\r\n\r\n```\r\n[519] % clangtk -v\r\nclang version 20.0.0git (https://github.com/llvm/llvm-project.git 410f751144e8b2e9574f03e0d0fb8560fe3cb797)\r\nTarget: x86_64-unknown-linux-gnu\r\nThread model: posix\r\nInstalledDir: /local/suz-local/software/local/clang-trunk/bin\r\nBuild config: +assertions\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9\r\nSelected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11\r\nCandidate multilib: .;@m64\r\nSelected multilib: .;@m64\r\n[520] % \r\n[520] % clangtk -Os small.c\r\nclang-20: /local/suz-local/software/clangbuild/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:7288: llvm::VectorizationFactor llvm::LoopVectorizationPlanner::computeBestVF(): Assertion `BestFactor.Width == LegacyVF.Width && \" VPlan cost model and legacy cost model disagreed\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.\r\nStack dump:\r\n0.\tProgram arguments: /local/suz-local/software/local/clang-trunk/bin/clang-20 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -dumpdir a- -disable-free -clear-ast-before-backend -main-file-name small.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/local/suz-local/software/emitesting/bugs/WAIT/20240822-clangtk-m64-Os-Wall-Wextra-pipe-fPIC-build-182745/delta -fcoverage-compilation-dir=/local/suz-local/software/emitesting/bugs/WAIT/20240822-clangtk-m64-Os-Wall-Wextra-pipe-fPIC-build-182745/delta -resource-dir /local/suz-local/software/local/clang-trunk/lib/clang/20 -I /usr/local/include -I /local/suz-local/software/local/include -internal-isystem /local/suz-local/software/local/clang-trunk/lib/clang/20/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -Os -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcolor-diagnostics -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/small-e51115.o -x c small.c\r\n1.\t<eof> parser at end of file\r\n2.\tOptimizer\r\n3.\tRunning pass \"function<eager-inv>(float2int,lower-constant-intrinsics,loop(loop-rotate<header-duplication;no-prepare-for-lto>,loop-deletion),loop-distribute,inject-tli-mappings,loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,infer-alignment,loop-load-elim,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,slp-vectorizer,vector-combine,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,loop-unroll<O2>,transform-warning,sroa<preserve-cfg>,infer-alignment,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,loop-sink,instsimplify,div-rem-pairs,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch;speculate-unpredictables>)\" on module \"small.c\"\r\n4.\tRunning pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"main\"\r\n #0 0x00005559685ec3ef llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x42ea3ef)\r\n #1 0x00005559685e9934 SignalHandler(int) Signals.cpp:0:0\r\n #2 0x00007f0380f76420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)\r\n #3 0x00007f03809ad00b raise /build/glibc-LcI20x/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1\r\n #4 0x00007f038098c859 abort /build/glibc-LcI20x/glibc-2.31/stdlib/abort.c:81:7\r\n #5 0x00007f038098c729 get_sysdep_segment_value /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:509:8\r\n #6 0x00007f038098c729 _nl_load_domain /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:970:34\r\n #7 0x00007f038099dfd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)\r\n #8 0x0000555969ef4948 llvm::LoopVectorizationPlanner::computeBestVF() (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5bf2948)\r\n #9 0x0000555969f0f9ea llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5c0d9ea)\r\n#10 0x0000555969f12691 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5c10691)\r\n#11 0x0000555969f12d43 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5c10d43)\r\n#12 0x0000555969a9d326 llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x579b326)\r\n#13 0x0000555967f872a1 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x3c852a1)\r\n#14 0x0000555965ae2ae6 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x17e0ae6)\r\n#15 0x0000555967f85bed llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x3c83bed)\r\n#16 0x0000555965ae19e6 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x17df9e6)\r\n#17 0x0000555967f83cf1 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x3c81cf1)\r\n#18 0x00005559688a0c29 (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>&, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>&, clang::BackendConsumer*) BackendUtil.cpp:0:0\r\n#19 0x00005559688a3d83 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x45a1d83)\r\n#20 0x0000555968f440fa clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4c420fa)\r\n#21 0x000055596ad8938c clang::ParseAST(clang::Sema&, bool, bool) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x6a8738c)\r\n#22 0x0000555968f44598 clang::CodeGenAction::ExecuteAction() (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4c42598)\r\n#23 0x00005559691dec59 clang::FrontendAction::Execute() (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4edcc59)\r\n#24 0x00005559691603be clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4e5e3be)\r\n#25 0x00005559692cb886 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4fc9886)\r\n#26 0x00005559656b5dd5 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x13b3dd5)\r\n#27 0x00005559656aee7a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\r\n#28 0x00005559656b284e clang_main(int, char**, llvm::ToolContext const&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x13b084e)\r\n#29 0x00005559655a31bb main (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x12a11bb)\r\n#30 0x00007f038098e083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3\r\n#31 0x00005559656ae90e _start (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x13ac90e)\r\nclangtk: error: unable to execute command: Aborted\r\nclangtk: error: clang frontend command failed due to signal (use -v to see invocation)\r\nclang version 20.0.0git (https://github.com/llvm/llvm-project.git 410f751144e8b2e9574f03e0d0fb8560fe3cb797)\r\nTarget: x86_64-unknown-linux-gnu\r\nThread model: posix\r\nInstalledDir: /local/suz-local/software/local/clang-trunk/bin\r\nBuild config: +assertions\r\nclangtk: note: diagnostic msg: \r\n********************\r\n\r\nPLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:\r\nPreprocessed source(s) and associated run script(s) are located at:\r\nclangtk: note: diagnostic msg: /tmp/small-1b0f28.c\r\nclangtk: note: diagnostic msg: /tmp/small-1b0f28.sh\r\nclangtk: note: diagnostic msg: \r\n\r\n********************\r\n[521] % \r\n[521] % cat small.c\r\nchar a;\r\nint b, *c = &b, d[3], e;\r\nint main() {\r\n int f, g[3] = {0,0,0};\r\n g[e] = *c = 0;\r\n for (; *c < 3; (*c)++) {\r\n f = a ? b % a : 0;\r\n g[2] &= d[*c] & f;\r\n }\r\n return 0;\r\n}\r\n```\r\n\r\n```\r\n[537] % clangtk -O3 small.c\r\nclang-20: /local/suz-local/software/clangbuild/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:7288: llvm::VectorizationFactor llvm::LoopVectorizationPlanner::computeBestVF(): Assertion `BestFactor.Width == LegacyVF.Width && \" VPlan cost model and legacy cost model disagreed\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.\r\nStack dump:\r\n0.\tProgram arguments: /local/suz-local/software/local/clang-trunk/bin/clang-20 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -dumpdir a- -disable-free -clear-ast-before-backend -main-file-name small.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/local/suz-local/software/emitesting/bugs/WAIT/20240814-clangtk-m64-O3-build-085604/delta -fcoverage-compilation-dir=/local/suz-local/software/emitesting/bugs/WAIT/20240814-clangtk-m64-O3-build-085604/delta -resource-dir /local/suz-local/software/local/clang-trunk/lib/clang/20 -I /usr/local/include -I /local/suz-local/software/local/include -internal-isystem /local/suz-local/software/local/clang-trunk/lib/clang/20/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O3 -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcolor-diagnostics -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/small-83d1cf.o -x c small.c\r\n1.\t<eof> parser at end of file\r\n2.\tOptimizer\r\n3.\tRunning pass \"function<eager-inv>(float2int,lower-constant-intrinsics,chr,loop(loop-rotate<header-duplication;no-prepare-for-lto>,loop-deletion),loop-distribute,inject-tli-mappings,loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,infer-alignment,loop-load-elim,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,slp-vectorizer,vector-combine,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,loop-unroll<O3>,transform-warning,sroa<preserve-cfg>,infer-alignment,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,loop-sink,instsimplify,div-rem-pairs,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch;speculate-unpredictables>)\" on module \"small.c\"\r\n4.\tRunning pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"main\"\r\n #0 0x0000558427a123ef llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x42ea3ef)\r\n #1 0x0000558427a0f934 SignalHandler(int) Signals.cpp:0:0\r\n #2 0x00007fa32f70a420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)\r\n #3 0x00007fa32f14100b raise /build/glibc-LcI20x/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1\r\n #4 0x00007fa32f120859 abort /build/glibc-LcI20x/glibc-2.31/stdlib/abort.c:81:7\r\n #5 0x00007fa32f120729 get_sysdep_segment_value /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:509:8\r\n #6 0x00007fa32f120729 _nl_load_domain /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:970:34\r\n #7 0x00007fa32f131fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)\r\n #8 0x000055842931a948 llvm::LoopVectorizationPlanner::computeBestVF() (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5bf2948)\r\n #9 0x00005584293359ea llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5c0d9ea)\r\n#10 0x0000558429338691 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5c10691)\r\n#11 0x0000558429338d43 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5c10d43)\r\n#12 0x0000558428ec3326 llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x579b326)\r\n#13 0x00005584273ad2a1 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x3c852a1)\r\n#14 0x0000558424f08ae6 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x17e0ae6)\r\n#15 0x00005584273abbed llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x3c83bed)\r\n#16 0x0000558424f079e6 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x17df9e6)\r\n#17 0x00005584273a9cf1 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x3c81cf1)\r\n#18 0x0000558427cc6c29 (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>&, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>&, clang::BackendConsumer*) BackendUtil.cpp:0:0\r\n#19 0x0000558427cc9d83 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x45a1d83)\r\n#20 0x000055842836a0fa clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4c420fa)\r\n#21 0x000055842a1af38c clang::ParseAST(clang::Sema&, bool, bool) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x6a8738c)\r\n#22 0x000055842836a598 clang::CodeGenAction::ExecuteAction() (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4c42598)\r\n#23 0x0000558428604c59 clang::FrontendAction::Execute() (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4edcc59)\r\n#24 0x00005584285863be clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4e5e3be)\r\n#25 0x00005584286f1886 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4fc9886)\r\n#26 0x0000558424adbdd5 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x13b3dd5)\r\n#27 0x0000558424ad4e7a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\r\n#28 0x0000558424ad884e clang_main(int, char**, llvm::ToolContext const&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x13b084e)\r\n#29 0x00005584249c91bb main (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x12a11bb)\r\n#30 0x00007fa32f122083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3\r\n#31 0x0000558424ad490e _start (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x13ac90e)\r\nclangtk: error: unable to execute command: Aborted\r\nclangtk: error: clang frontend command failed due to signal (use -v to see invocation)\r\nclang version 20.0.0git (https://github.com/llvm/llvm-project.git 410f751144e8b2e9574f03e0d0fb8560fe3cb797)\r\nTarget: x86_64-unknown-linux-gnu\r\nThread model: posix\r\nInstalledDir: /local/suz-local/software/local/clang-trunk/bin\r\nBuild config: +assertions\r\nclangtk: note: diagnostic msg: \r\n********************\r\n\r\nPLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:\r\nPreprocessed source(s) and associated run script(s) are located at:\r\nclangtk: note: diagnostic msg: /tmp/small-aeee73.c\r\nclangtk: note: diagnostic msg: /tmp/small-aeee73.sh\r\nclangtk: note: diagnostic msg: \r\n\r\n********************\r\n[538] % \r\n[538] % cat small.c\r\nint a[1], *d, e, f[1];\r\nstatic int b, c, *volatile g = &c;\r\nvoid h(int i) { b = b >> 1 ^ a[b ^ i & 1]; }\r\nvoid j(long i) {\r\n b = b >> 1 ^ b;\r\n b = b >> 1 ^ a[b ^ 1];\r\n h(i >> 1);\r\n h(i >> 3);\r\n h(i >> 2);\r\n h(i >> 4);\r\n h(i >> 5);\r\n}\r\nstatic void m() {\r\n int l;\r\n while (e) {\r\n c = 0;\r\n for (; c < 5; c++) {\r\n l = 0;\r\n for (; l < 7; l++)\r\n if (*d)\r\n j(f[c * l]);\r\n }\r\n }\r\n}\r\nint main() {\r\n if (e) {\r\n m();\r\n g;\r\n }\r\n return 0;\r\n}\r\n```\r\n"
97
+ },
98
+ {
99
+ "author": "fhahn",
100
+ "body": "@zhendongsu thanks for the report, it was the same issue as the test case @sjoerdmeijer shared at https://github.com/llvm/llvm-project/issues/100591, which was a different underlying issue to the one for this issue.\r\n\r\nBoth should be fixed now, please let me know if you find any other instances of this triggering."
101
+ },
102
+ {
103
+ "author": "zhendongsu",
104
+ "body": "Hi @fhahn, here is another related instance that still triggers:\r\n```\r\n[512] % clangtk -v\r\nclang version 20.0.0git (https://github.com/llvm/llvm-project.git f22b1da8791edd557ce34c87190e329df2e1c892)\r\nTarget: x86_64-unknown-linux-gnu\r\nThread model: posix\r\nInstalledDir: /local/suz-local/software/local/clang-trunk/bin\r\nBuild config: +assertions\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9\r\nSelected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11\r\nCandidate multilib: .;@m64\r\nSelected multilib: .;@m64\r\n[513] % \r\n[513] % clangtk -Os small.c\r\nclang-20: /local/suz-local/software/clangbuild/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:7359: llvm::VectorizationFactor llvm::LoopVectorizationPlanner::computeBestVF(): Assertion `(BestFactor.Width == LegacyVF.Width || planContainsAdditionalSimplifications(getPlanFor(BestFactor.Width), BestFactor.Width, CostCtx, OrigLoop, CM)) && \" VPlan cost model and legacy cost model disagreed\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.\r\nStack dump:\r\n0.\tProgram arguments: /local/suz-local/software/local/clang-trunk/bin/clang-20 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -dumpdir a- -disable-free -clear-ast-before-backend -main-file-name small.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/local/suz-local/software/emitesting/bugs/20240825-clangtk-m64-Os-Wall-Wextra-pipe-fPIC-build-043108/delta -fcoverage-compilation-dir=/local/suz-local/software/emitesting/bugs/20240825-clangtk-m64-Os-Wall-Wextra-pipe-fPIC-build-043108/delta -resource-dir /local/suz-local/software/local/clang-trunk/lib/clang/20 -I /usr/local/include -I /local/suz-local/software/local/include -internal-isystem /local/suz-local/software/local/clang-trunk/lib/clang/20/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -Os -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcolor-diagnostics -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/small-d7ba19.o -x c small.c\r\n1.\t<eof> parser at end of file\r\n2.\tOptimizer\r\n3.\tRunning pass \"function<eager-inv>(float2int,lower-constant-intrinsics,loop(loop-rotate<header-duplication;no-prepare-for-lto>,loop-deletion),loop-distribute,inject-tli-mappings,loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,infer-alignment,loop-load-elim,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,slp-vectorizer,vector-combine,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,loop-unroll<O2>,transform-warning,sroa<preserve-cfg>,infer-alignment,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,loop-sink,instsimplify,div-rem-pairs,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch;speculate-unpredictables>)\" on module \"small.c\"\r\n4.\tRunning pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"main\"\r\n #0 0x0000564ef7a4babf llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x42ddabf)\r\n #1 0x0000564ef7a49004 SignalHandler(int) Signals.cpp:0:0\r\n #2 0x00007f89634f9420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)\r\n #3 0x00007f8962f3000b raise /build/glibc-LcI20x/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1\r\n #4 0x00007f8962f0f859 abort /build/glibc-LcI20x/glibc-2.31/stdlib/abort.c:81:7\r\n #5 0x00007f8962f0f729 get_sysdep_segment_value /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:509:8\r\n #6 0x00007f8962f0f729 _nl_load_domain /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:970:34\r\n #7 0x00007f8962f20fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)\r\n #8 0x0000564ef9358b42 llvm::LoopVectorizationPlanner::computeBestVF() (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5beab42)\r\n #9 0x0000564ef937504a llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5c0704a)\r\n#10 0x0000564ef9377c81 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5c09c81)\r\n#11 0x0000564ef9378333 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5c0a333)\r\n#12 0x0000564ef8f026e6 llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x57946e6)\r\n#13 0x0000564ef73e68d1 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x3c788d1)\r\n#14 0x0000564ef4f4ff46 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x17e1f46)\r\n#15 0x0000564ef73e521d llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x3c7721d)\r\n#16 0x0000564ef4f4ee46 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x17e0e46)\r\n#17 0x0000564ef73e3321 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x3c75321)\r\n#18 0x0000564ef7d04bb1 (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>&, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>&, clang::BackendConsumer*) BackendUtil.cpp:0:0\r\n#19 0x0000564ef7d07d73 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4599d73)\r\n#20 0x0000564ef83a840c clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4c3a40c)\r\n#21 0x0000564efa1f004c clang::ParseAST(clang::Sema&, bool, bool) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x6a8204c)\r\n#22 0x0000564ef83a8828 clang::CodeGenAction::ExecuteAction() (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4c3a828)\r\n#23 0x0000564ef8643cb9 clang::FrontendAction::Execute() (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4ed5cb9)\r\n#24 0x0000564ef85c543e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4e5743e)\r\n#25 0x0000564ef8730876 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4fc2876)\r\n#26 0x0000564ef4b21e55 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x13b3e55)\r\n#27 0x0000564ef4b1aefa ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\r\n#28 0x0000564ef4b1e8ce clang_main(int, char**, llvm::ToolContext const&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x13b08ce)\r\n#29 0x0000564ef4a0f1bb main (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x12a11bb)\r\n#30 0x00007f8962f11083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3\r\n#31 0x0000564ef4b1a98e _start (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x13ac98e)\r\nclangtk: error: unable to execute command: Aborted\r\nclangtk: error: clang frontend command failed due to signal (use -v to see invocation)\r\nclang version 20.0.0git (https://github.com/llvm/llvm-project.git f22b1da8791edd557ce34c87190e329df2e1c892)\r\nTarget: x86_64-unknown-linux-gnu\r\nThread model: posix\r\nInstalledDir: /local/suz-local/software/local/clang-trunk/bin\r\nBuild config: +assertions\r\nclangtk: note: diagnostic msg: \r\n********************\r\n\r\nPLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:\r\nPreprocessed source(s) and associated run script(s) are located at:\r\nclangtk: note: diagnostic msg: /tmp/small-6fc973.c\r\nclangtk: note: diagnostic msg: /tmp/small-6fc973.sh\r\nclangtk: note: diagnostic msg: \r\n\r\n********************\r\n[514] % \r\n[514] % cat small.c\r\nint a, d;\r\nstatic int b = 1, c;\r\nvoid e() {\r\n while (a)\r\n b--;\r\n}\r\nint main() {\r\n for (d = 0; d < 3; d++)\r\n if (a)\r\n for (c = 0; c < 2; c++)\r\n if (b)\r\n break;\r\n return 0;\r\n}\r\n```\r\n\r\nCompiler Explorer: https://godbolt.org/z/zanjboPYo"
105
+ },
106
+ {
107
+ "author": "zhendongsu",
108
+ "body": "Hi @fhahn, another reproducer that triggers at -O{s,2,3}:\r\n```\r\n[520] % clangtk -v\r\nclang version 20.0.0git (https://github.com/llvm/llvm-project.git 7e6b1504c7cf6976ac8e9012c4513ffa258bd8eb)\r\nTarget: x86_64-unknown-linux-gnu\r\nThread model: posix\r\nInstalledDir: /local/suz-local/software/local/clang-trunk/bin\r\nBuild config: +assertions\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9\r\nSelected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11\r\nCandidate multilib: .;@m64\r\nSelected multilib: .;@m64\r\n[521] % \r\n[521] % clangtk -O3 small.c\r\nclang-20: /local/suz-local/software/clangbuild/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:7359: llvm::VectorizationFactor llvm::LoopVectorizationPlanner::computeBestVF(): Assertion `(BestFactor.Width == LegacyVF.Width || planContainsAdditionalSimplifications(getPlanFor(BestFactor.Width), BestFactor.Width, CostCtx, OrigLoop, CM)) && \" VPlan cost model and legacy cost model disagreed\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.\r\nStack dump:\r\n0.\tProgram arguments: /local/suz-local/software/local/clang-trunk/bin/clang-20 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -dumpdir a- -disable-free -clear-ast-before-backend -main-file-name small.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/local/suz-local/software/emitesting/bugs/20240826-clangtk-m64-Os-build-191303/delta -fcoverage-compilation-dir=/local/suz-local/software/emitesting/bugs/20240826-clangtk-m64-Os-build-191303/delta -resource-dir /local/suz-local/software/local/clang-trunk/lib/clang/20 -I /usr/local/include -I /local/suz-local/software/local/include -internal-isystem /local/suz-local/software/local/clang-trunk/lib/clang/20/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O3 -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcolor-diagnostics -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/small-bd6e8d.o -x c small.c\r\n1.\t<eof> parser at end of file\r\n2.\tOptimizer\r\n3.\tRunning pass \"function<eager-inv>(float2int,lower-constant-intrinsics,chr,loop(loop-rotate<header-duplication;no-prepare-for-lto>,loop-deletion),loop-distribute,inject-tli-mappings,loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,infer-alignment,loop-load-elim,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,slp-vectorizer,vector-combine,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,loop-unroll<O3>,transform-warning,sroa<preserve-cfg>,infer-alignment,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,loop-sink,instsimplify,div-rem-pairs,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch;speculate-unpredictables>)\" on module \"small.c\"\r\n4.\tRunning pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"main\"\r\n #0 0x0000561e24237f5f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x42f4f5f)\r\n #1 0x0000561e242354a4 SignalHandler(int) Signals.cpp:0:0\r\n #2 0x00007f7461dc8420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)\r\n #3 0x00007f74617ff00b raise /build/glibc-LcI20x/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1\r\n #4 0x00007f74617de859 abort /build/glibc-LcI20x/glibc-2.31/stdlib/abort.c:81:7\r\n #5 0x00007f74617de729 get_sysdep_segment_value /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:509:8\r\n #6 0x00007f74617de729 _nl_load_domain /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:970:34\r\n #7 0x00007f74617effd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)\r\n #8 0x0000561e25b45232 llvm::LoopVectorizationPlanner::computeBestVF() (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5c02232)\r\n #9 0x0000561e25b616ca llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5c1e6ca)\r\n#10 0x0000561e25b64301 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5c21301)\r\n#11 0x0000561e25b649b3 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5c219b3)\r\n#12 0x0000561e256ef0a6 llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x57ac0a6)\r\n#13 0x0000561e23bd2da1 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x3c8fda1)\r\n#14 0x0000561e21724f86 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x17e1f86)\r\n#15 0x0000561e23bd16ed llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x3c8e6ed)\r\n#16 0x0000561e21723e86 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x17e0e86)\r\n#17 0x0000561e23bcf7f1 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x3c8c7f1)\r\n#18 0x0000561e244f0f41 (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>&, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>&, clang::BackendConsumer*) BackendUtil.cpp:0:0\r\n#19 0x0000561e244f4103 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x45b1103)\r\n#20 0x0000561e24b9480c clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4c5180c)\r\n#21 0x0000561e269dcc5c clang::ParseAST(clang::Sema&, bool, bool) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x6a99c5c)\r\n#22 0x0000561e24b94c28 clang::CodeGenAction::ExecuteAction() (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4c51c28)\r\n#23 0x0000561e24e30189 clang::FrontendAction::Execute() (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4eed189)\r\n#24 0x0000561e24db162e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4e6e62e)\r\n#25 0x0000561e24f1cde6 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4fd9de6)\r\n#26 0x0000561e212f6ed5 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x13b3ed5)\r\n#27 0x0000561e212eff7a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\r\n#28 0x0000561e212f394e clang_main(int, char**, llvm::ToolContext const&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x13b094e)\r\n#29 0x0000561e211e41eb main (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x12a11eb)\r\n#30 0x00007f74617e0083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3\r\n#31 0x0000561e212efa0e _start (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x13aca0e)\r\nclangtk: error: unable to execute command: Aborted\r\nclangtk: error: clang frontend command failed due to signal (use -v to see invocation)\r\nclang version 20.0.0git (https://github.com/llvm/llvm-project.git 7e6b1504c7cf6976ac8e9012c4513ffa258bd8eb)\r\nTarget: x86_64-unknown-linux-gnu\r\nThread model: posix\r\nInstalledDir: /local/suz-local/software/local/clang-trunk/bin\r\nBuild config: +assertions\r\nclangtk: note: diagnostic msg: \r\n********************\r\n\r\nPLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:\r\nPreprocessed source(s) and associated run script(s) are located at:\r\nclangtk: note: diagnostic msg: /tmp/small-796071.c\r\nclangtk: note: diagnostic msg: /tmp/small-796071.sh\r\nclangtk: note: diagnostic msg: \r\n\r\n********************\r\n[522] % \r\n[522] % cat small.c\r\nchar a;\r\nstatic char b, *c = &b, **d = &c;\r\nint e;\r\nunsigned f;\r\nchar g(int h) { return a << h; }\r\nint main() {\r\n char ***i[2] = {&d, &d};\r\n int *j;\r\n for (; f < 3; f++) {\r\n j = &e;\r\n *j = g(**d);\r\n }\r\n return 0;\r\n}\r\n```\r\n\r\nCompiler Explorer: https://godbolt.org/z/7Y5PzTx4P"
109
+ }
110
+ ]
111
+ },
112
+ "verified": true
113
+ }
dataset/104761.json ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "104761",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/104761",
4
+ "bug_type": "crash",
5
+ "base_commit": "5cfa8baef33636827e5aa8dd76888c724433b53e",
6
+ "knowledge_cutoff": "2024-08-19T11:00:31Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Analysis/LoopCacheAnalysis"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "2e6deb1dd3a4422807633ba08773e8d786e43d4c",
12
+ "components": [
13
+ "LoopCacheAnalysis"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/include/llvm/Analysis/LoopCacheAnalysis.h": [
17
+ [
18
+ 16,
19
+ 21
20
+ ],
21
+ [
22
+ 31,
23
+ 37
24
+ ],
25
+ [
26
+ 192,
27
+ 199
28
+ ]
29
+ ],
30
+ "llvm/lib/Analysis/LoopCacheAnalysis.cpp": [
31
+ [
32
+ 328,
33
+ 333
34
+ ],
35
+ [
36
+ 338,
37
+ 351
38
+ ],
39
+ [
40
+ 696,
41
+ 702
42
+ ]
43
+ ]
44
+ },
45
+ "bug_location_funcname": {
46
+ "llvm/lib/Analysis/LoopCacheAnalysis.cpp": [
47
+ "CacheCost::computeLoopCacheCost",
48
+ "IndexedReference::computeRefCost",
49
+ "IndexedReference::tryDelinearizeFixedSize"
50
+ ]
51
+ }
52
+ },
53
+ "patch": "commit 2e6deb1dd3a4422807633ba08773e8d786e43d4c\nAuthor: Sjoerd Meijer <[email protected]>\nDate: Thu Nov 14 08:40:45 2024 +0000\n\n [LoopInterchange] Fix overflow in cost calculation (#111807)\n \n If the iteration count is really large, e.g. UINT_MAX, then the cost\n calculation can overflows and trigger an assert. So saturate the cost to\n INT_MAX if this is the case by using InstructionCost as a type which\n already supports this kind of overflow handling.\n \n This fixes #104761\n\ndiff --git a/llvm/include/llvm/Analysis/LoopCacheAnalysis.h b/llvm/include/llvm/Analysis/LoopCacheAnalysis.h\nindex 4fd2485e39d6..3e22487e5e34 100644\n--- a/llvm/include/llvm/Analysis/LoopCacheAnalysis.h\n+++ b/llvm/include/llvm/Analysis/LoopCacheAnalysis.h\n@@ -16,6 +16,7 @@\n \n #include \"llvm/Analysis/LoopAnalysisManager.h\"\n #include \"llvm/IR/PassManager.h\"\n+#include \"llvm/Support/InstructionCost.h\"\n #include <optional>\n \n namespace llvm {\n@@ -31,7 +32,7 @@ class ScalarEvolution;\n class SCEV;\n class TargetTransformInfo;\n \n-using CacheCostTy = int64_t;\n+using CacheCostTy = InstructionCost;\n using LoopVectorTy = SmallVector<Loop *, 8>;\n \n /// Represents a memory reference as a base pointer and a set of indexing\n@@ -192,8 +193,6 @@ class CacheCost {\n using LoopCacheCostTy = std::pair<const Loop *, CacheCostTy>;\n \n public:\n- static CacheCostTy constexpr InvalidCost = -1;\n-\n /// Construct a CacheCost object for the loop nest described by \\p Loops.\n /// The optional parameter \\p TRT can be used to specify the max. distance\n /// between array elements accessed in a loop so that the elements are\ndiff --git a/llvm/lib/Analysis/LoopCacheAnalysis.cpp b/llvm/lib/Analysis/LoopCacheAnalysis.cpp\nindex 7ca9f15ad5fc..2897b922f61e 100644\n--- a/llvm/lib/Analysis/LoopCacheAnalysis.cpp\n+++ b/llvm/lib/Analysis/LoopCacheAnalysis.cpp\n@@ -328,6 +328,8 @@ CacheCostTy IndexedReference::computeRefCost(const Loop &L,\n const SCEV *TripCount =\n computeTripCount(*AR->getLoop(), *Sizes.back(), SE);\n Type *WiderType = SE.getWiderType(RefCost->getType(), TripCount->getType());\n+ // For the multiplication result to fit, request a type twice as wide.\n+ WiderType = WiderType->getExtendedType();\n RefCost = SE.getMulExpr(SE.getNoopOrZeroExtend(RefCost, WiderType),\n SE.getNoopOrZeroExtend(TripCount, WiderType));\n }\n@@ -338,14 +340,18 @@ CacheCostTy IndexedReference::computeRefCost(const Loop &L,\n assert(RefCost && \"Expecting a valid RefCost\");\n \n // Attempt to fold RefCost into a constant.\n+ // CacheCostTy is a signed integer, but the tripcount value can be large\n+ // and may not fit, so saturate/limit the value to the maximum signed\n+ // integer value.\n if (auto ConstantCost = dyn_cast<SCEVConstant>(RefCost))\n- return ConstantCost->getValue()->getZExtValue();\n+ return ConstantCost->getValue()->getLimitedValue(\n+ std::numeric_limits<int64_t>::max());\n \n LLVM_DEBUG(dbgs().indent(4)\n << \"RefCost is not a constant! Setting to RefCost=InvalidCost \"\n \"(invalid value).\\n\");\n \n- return CacheCost::InvalidCost;\n+ return CacheCostTy::getInvalid();\n }\n \n bool IndexedReference::tryDelinearizeFixedSize(\n@@ -696,7 +702,7 @@ CacheCostTy\n CacheCost::computeLoopCacheCost(const Loop &L,\n const ReferenceGroupsTy &RefGroups) const {\n if (!L.isLoopSimplifyForm())\n- return InvalidCost;\n+ return CacheCostTy::getInvalid();\n \n LLVM_DEBUG(dbgs() << \"Considering loop '\" << L.getName()\n << \"' as innermost loop.\\n\");\n",
54
+ "tests": [
55
+ {
56
+ "file": "llvm/test/Analysis/LoopCacheAnalysis/interchange-refcost-overflow.ll",
57
+ "commands": [
58
+ "opt < %s -passes='print<loop-cache-cost>' -disable-output 2>&1"
59
+ ],
60
+ "tests": [
61
+ {
62
+ "test_name": "foo",
63
+ "test_body": "@A = external local_unnamed_addr global [11 x [11 x [11 x i32]]], align 16\n\ndefine void @foo(i32 noundef %b) {\nentry:\n %0 = sext i32 %b to i64\n br label %outer.loop\n\nouter.loop: ; preds = %outer.loop.cleanup, %entry\n %indvars.iv = phi i64 [ %indvars.iv.next, %outer.loop.cleanup ], [ 0, %entry ]\n br label %inner.loop\n\nouter.loop.cleanup: ; preds = %inner.loop\n %indvars.iv.next = add nsw i64 %indvars.iv, %0\n br label %outer.loop\n\ninner.loop: ; preds = %inner.loop, %outer.loop\n %inner.iv = phi i64 [ 0, %outer.loop ], [ %add, %inner.loop ]\n %arrayidx3 = getelementptr inbounds [11 x [11 x [11 x i32]]], ptr @A, i64 0, i64 %indvars.iv, i64 %inner.iv, i64 %inner.iv\n store i32 0, ptr %arrayidx3, align 4\n %add = add nuw i64 %inner.iv, 2\n %cmp = icmp ult i64 %inner.iv, -5\n br i1 %cmp, label %inner.loop, label %outer.loop.cleanup\n}\n"
64
+ }
65
+ ]
66
+ }
67
+ ],
68
+ "issue": {
69
+ "title": "[LoopInterchange] Assertion `getActiveBits() <= 64 && \"Too many bits for uint64_t\"",
70
+ "body": "With options \"-O3 --target=aarch64 func.cpp -mllvm -enable-loopinterchange\" and this input:\r\n```\r\nunsigned int A[11][11][11] __attribute__((aligned(16)));\r\nvoid a(int b) {\r\n for (int c;; c += b)\r\n for (long d = 0; d < -3ULL; d += 2ULL)\r\n A[c][d][d] = 0;\r\n}\r\n```\r\n\r\nLoop-interchange runs in an assert:\r\n\r\n```\r\nllvm-project/llvm/include/llvm/ADT/APInt.h:1501: uint64_t llvm::APInt::getZExtValue() const: Assertion `getActiveBits() <= 64 && \"Too many bits for uint64_t\"' failed.\r\n```\r\n\r\nIR reproducer, compile this with \"opt -passes=loop-interchange -S\":\r\n\r\n```\r\ntarget datalayout = \"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32\"\r\ntarget triple = \"aarch64-unknown-linux-gnu\"\r\n\r\n@A = local_unnamed_addr global [11 x [11 x [11 x i32]]] zeroinitializer, align 16\r\n\r\ndefine void @_Z1ai(i32 noundef %b) local_unnamed_addr #0 {\r\nentry:\r\n %0 = sext i32 %b to i64\r\n br label %for.cond\r\n\r\n; Loop:\r\nfor.cond: ; preds = %for.cond.cleanup, %entry\r\n %indvars.iv = phi i64 [ %indvars.iv.next, %for.cond.cleanup ], [ 0, %entry ]\r\n br label %for.body\r\n\r\nfor.cond.cleanup: ; preds = %for.body\r\n %indvars.iv.next = add nsw i64 %indvars.iv, %0\r\n br label %for.cond\r\n\r\nfor.body: ; preds = %for.cond, %for.body\r\n %d.010 = phi i64 [ 0, %for.cond ], [ %add, %for.body ]\r\n %arrayidx3 = getelementptr inbounds [11 x [11 x [11 x i32]]], ptr @A, i64 0, i64 %indvars.iv, i64 %d.010, i64 %d.010\r\n store i32 0, ptr %arrayidx3, align 4\r\n %add = add nuw i64 %d.010, 2\r\n %cmp = icmp ult i64 %d.010, -5\r\n br i1 %cmp, label %for.body, label %for.cond.cleanup\r\n}\r\n```",
71
+ "author": "sjoerdmeijer",
72
+ "labels": [
73
+ "crash-on-valid",
74
+ "llvm:analysis"
75
+ ],
76
+ "comments": [
77
+ {
78
+ "author": "RKSimon",
79
+ "body": "```\r\nopt: /root/llvm-project/llvm/include/llvm/ADT/APInt.h:1501: uint64_t llvm::APInt::getZExtValue() const: Assertion `getActiveBits() <= 64 && \"Too many bits for uint64_t\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=loop-interchange -debug <source>\r\n1.\tRunning pass \"function(loop(loop-interchange))\" on module \"<source>\"\r\n2.\tRunning pass \"loop(loop-interchange)\" on function \"_Z1ai\"\r\n #0 0x0000000004f7f528 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4f7f528)\r\n #1 0x0000000004f7cc9c SignalHandler(int) Signals.cpp:0:0\r\n #2 0x00007f497b842520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #3 0x00007f497b8969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\r\n #4 0x00007f497b842476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\r\n #5 0x00007f497b8287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\r\n #6 0x00007f497b82871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\r\n #7 0x00007f497b839e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n #8 0x00000000045677cc llvm::IndexedReference::computeRefCost(llvm::Loop const&, unsigned int) const (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x45677cc)\r\n #9 0x000000000456995f llvm::CacheCost::computeLoopCacheCost(llvm::Loop const&, llvm::SmallVector<llvm::SmallVector<std::unique_ptr<llvm::IndexedReference, std::default_delete<llvm::IndexedReference>>, 8u>, 8u> const&) const (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x456995f)\r\n#10 0x000000000456c137 llvm::CacheCost::calculateCacheFootprint() (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x456c137)\r\n#11 0x0000000004573d5c llvm::CacheCost::getCacheCost(llvm::Loop&, llvm::LoopStandardAnalysisResults&, llvm::DependenceInfo&, std::optional<unsigned int>) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4573d5c)\r\n#12 0x0000000003c71d66 llvm::LoopInterchangePass::run(llvm::LoopNest&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3c71d66)\r\n#13 0x0000000002eb0a6e llvm::detail::PassModel<llvm::LoopNest, llvm::LoopInterchangePass, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>::run(llvm::LoopNest&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2eb0a6e)\r\n#14 0x0000000003c85255 llvm::PassManager<llvm::Loop, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>::runWithLoopNestPasses(llvm::Loop&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3c85255)\r\n#15 0x0000000003c85ce3 llvm::PassManager<llvm::Loop, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>::run(llvm::Loop&, llvm::AnalysisManager<llvm::Loop, llvm::LoopStandardAnalysisResults&>&, llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3c85ce3)\r\n#16 0x0000000003c868b8 llvm::FunctionToLoopPassAdaptor::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3c868b8)\r\n#17 0x0000000000df128e llvm::detail::PassModel<llvm::Function, llvm::FunctionToLoopPassAdaptor, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xdf128e)\r\n#18 0x0000000004d7c368 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4d7c368)\r\n#19 0x0000000000df14be llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xdf14be)\r\n#20 0x0000000004d7ad5e llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4d7ad5e)\r\n#21 0x0000000000df0f8e llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xdf0f8e)\r\n#22 0x0000000004d78ec0 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4d78ec0)\r\n#23 0x00000000008e7582 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8e7582)\r\n#24 0x00000000008da45c optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8da45c)\r\n#25 0x00007f497b829d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\r\n#26 0x00007f497b829e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\r\n#27 0x00000000008d1eee _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8d1eee)\r\n```\r\nWhich seems to be due to the getZExtValue() call inside IndexedReference::computeRefCost\r\nhttps://github.com/llvm/llvm-project/blob/b05c55472bf7cadcd0e4cb1a669b3474695b0524/llvm/lib/Analysis/LoopCacheAnalysis.cpp#L340:L343"
80
+ },
81
+ {
82
+ "author": "svs-quic",
83
+ "body": "cc: @caojoshua "
84
+ },
85
+ {
86
+ "author": "sjoerdmeijer",
87
+ "body": "I have a fix, will put it up for review tomorrow. "
88
+ }
89
+ ]
90
+ },
91
+ "verified": true
92
+ }
dataset/105120.json ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "105120",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/105120",
4
+ "bug_type": "crash",
5
+ "base_commit": "6ec3130a38e6982a61e7fa74bd5223c95c0bb918",
6
+ "knowledge_cutoff": "2024-08-20T17:04:34Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/SLPVectorizer"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "e31252bf54dedadfe78b36d07ea6084156faa38a",
12
+ "components": [
13
+ "SLPVectorizer"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
17
+ [
18
+ 7227,
19
+ 7232
20
+ ],
21
+ [
22
+ 7238,
23
+ 7247
24
+ ]
25
+ ]
26
+ },
27
+ "bug_location_funcname": {
28
+ "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
29
+ "BoUpSLP::buildTree_rec"
30
+ ]
31
+ }
32
+ },
33
+ "patch": "commit e31252bf54dedadfe78b36d07ea6084156faa38a\nAuthor: Alexey Bataev <[email protected]>\nDate: Wed Aug 21 11:47:00 2024 -0700\n\n [SLP]Fix PR105120: fix the order of phi nodes vectorization.\n \n The operands of the phi nodes should be vectorized in the same order, in\n which they were created, otherwise the compiler may crash when trying\n to correctly build dependency for nodes with non-schedulable\n instructions for gather/buildvector nodes.\n \n Fixes https://github.com/llvm/llvm-project/issues/105120\n\ndiff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\nindex dee6d688b1b9..848e0de20e7b 100644\n--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n@@ -7227,6 +7227,22 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth,\n \n unsigned ShuffleOrOp = S.isAltShuffle() ?\n (unsigned) Instruction::ShuffleVector : S.getOpcode();\n+ auto CreateOperandNodes = [&](TreeEntry *TE, const auto &Operands) {\n+ // Postpone PHI nodes creation\n+ SmallVector<unsigned> PHIOps;\n+ for (unsigned I : seq<unsigned>(Operands.size())) {\n+ ArrayRef<Value *> Op = Operands[I];\n+ if (Op.empty())\n+ continue;\n+ InstructionsState S = getSameOpcode(Op, *TLI);\n+ if (S.getOpcode() != Instruction::PHI || S.isAltShuffle())\n+ buildTree_rec(Op, Depth + 1, {TE, I});\n+ else\n+ PHIOps.push_back(I);\n+ }\n+ for (unsigned I : PHIOps)\n+ buildTree_rec(Operands[I], Depth + 1, {TE, I});\n+ };\n switch (ShuffleOrOp) {\n case Instruction::PHI: {\n auto *PH = cast<PHINode>(VL0);\n@@ -7238,10 +7254,12 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth,\n // Keeps the reordered operands to avoid code duplication.\n PHIHandler Handler(*DT, PH, VL);\n Handler.buildOperands();\n- for (unsigned I : seq<unsigned>(0, PH->getNumOperands()))\n+ for (unsigned I : seq<unsigned>(PH->getNumOperands()))\n TE->setOperand(I, Handler.getOperands(I));\n- for (unsigned I : seq<unsigned>(0, PH->getNumOperands()))\n- buildTree_rec(Handler.getOperands(I), Depth + 1, {TE, I});\n+ SmallVector<ArrayRef<Value *>> Operands(PH->getNumOperands());\n+ for (unsigned I : seq<unsigned>(PH->getNumOperands()))\n+ Operands[I] = Handler.getOperands(I);\n+ CreateOperandNodes(TE, Operands);\n return;\n }\n case Instruction::ExtractValue:\n",
34
+ "tests": [
35
+ {
36
+ "file": "llvm/test/Transforms/SLPVectorizer/X86/phi-nodes-as-operand-reorder.ll",
37
+ "commands": [
38
+ "opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu -slp-threshold=-99999 < %s"
39
+ ],
40
+ "tests": [
41
+ {
42
+ "test_name": "test",
43
+ "test_body": "define void @test() {\nbb:\n br label %bb1\n\nbb1: ; preds = %bb3, %bb\n %phi = phi i32 [ 0, %bb ], [ %add5, %bb3 ]\n %phi2 = phi i32 [ 0, %bb ], [ %add, %bb3 ]\n br i1 false, label %bb6, label %bb3\n\nbb3: ; preds = %bb1\n %add = add i32 0, 0\n %add4 = add i32 0, 0\n %add5 = add i32 %phi, 0\n br i1 false, label %bb6, label %bb1\n\nbb6: ; preds = %bb3, %bb1\n %phi7 = phi i32 [ %phi2, %bb1 ], [ %add4, %bb3 ]\n %phi8 = phi i32 [ %phi, %bb1 ], [ %add5, %bb3 ]\n ret void\n}\n"
44
+ }
45
+ ]
46
+ }
47
+ ],
48
+ "issue": {
49
+ "title": "[SLPVectorizer] Instruction does not dominate all uses! LLVM ERROR: Broken module found, compilation aborted!",
50
+ "body": "To reproduce run the test below with -passes slp-vectorizer -slp-threshold=-99999\r\n```\r\n; ModuleID = './reduced.ll'\r\nsource_filename = \"./reduced.ll\"\r\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128-ni:1-p2:32:8:8:32-ni:2\"\r\ntarget triple = \"x86_64-unknown-linux-gnu\"\r\n\r\ndefine void @wombat() #0 gc \"statepoint-example\" {\r\nbb:\r\n br label %bb1\r\n\r\nbb1: ; preds = %bb3, %bb\r\n %phi = phi i32 [ 0, %bb ], [ %add5, %bb3 ]\r\n %phi2 = phi i32 [ 0, %bb ], [ %add, %bb3 ]\r\n br i1 false, label %bb6, label %bb3\r\n\r\nbb3: ; preds = %bb1\r\n %add = add i32 0, 0\r\n %add4 = add i32 0, 0\r\n %add5 = add i32 %phi, 0\r\n br i1 false, label %bb6, label %bb1\r\n\r\nbb6: ; preds = %bb3, %bb1\r\n %phi7 = phi i32 [ %phi2, %bb1 ], [ %add4, %bb3 ]\r\n %phi8 = phi i32 [ %phi, %bb1 ], [ %add5, %bb3 ]\r\n ret void\r\n}\r\n```\r\nReproducer: https://godbolt.org/z/W96s5a1cb\r\n\r\n```\r\nInstruction does not dominate all uses!\r\n %2 = shufflevector <2 x i32> %0, <2 x i32> <i32 0, i32 poison>, <2 x i32> <i32 2, i32 1>\r\n %1 = add <2 x i32> zeroinitializer, %2\r\nLLVM ERROR: Broken module found, compilation aborted!\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes slp-vectorizer -slp-threshold=-99999 <source>\r\n1.\tRunning pass \"verify\" on module \"<source>\"\r\n #0 0x0000000004f84b88 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4f84b88)\r\n #1 0x0000000004f822fc SignalHandler(int) Signals.cpp:0:0\r\n #2 0x000074dcb3642520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #3 0x000074dcb36969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\r\n #4 0x000074dcb3642476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\r\n #5 0x000074dcb36287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\r\n #6 0x00000000007b7cc5 llvm::json::operator==(llvm::json::Value const&, llvm::json::Value const&) (.cold) JSON.cpp:0:0\r\n #7 0x0000000004ebea18 (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4ebea18)\r\n #8 0x0000000004dbae20 llvm::VerifierPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4dbae20)\r\n #9 0x00000000008dbbde llvm::detail::PassModel<llvm::Module, llvm::VerifierPass, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8dbbde)\r\n#10 0x0000000004d7ebb0 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4d7ebb0)\r\n#11 0x00000000008e6912 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8e6912)\r\n#12 0x00000000008d97ec optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8d97ec)\r\n#13 0x000074dcb3629d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\r\n#14 0x000074dcb3629e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\r\n#15 0x00000000008d127e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8d127e)\r\nProgram terminated with signal: SIGSEGV\r\nCompiler returned: 139\r\n```",
51
+ "author": "TatyanaDoubts",
52
+ "labels": [
53
+ "llvm:SLPVectorizer",
54
+ "llvm:crash"
55
+ ],
56
+ "comments": [
57
+ {
58
+ "author": "alexey-bataev",
59
+ "body": "Yes"
60
+ }
61
+ ]
62
+ },
63
+ "verified": true
64
+ }
dataset/105722.json ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "105722",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/105722",
4
+ "bug_type": "crash",
5
+ "base_commit": "84497c6f4f6c79b0d8c38da666724eed7e9e8db5",
6
+ "knowledge_cutoff": "2024-08-22T19:30:39Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/LoopVectorize"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "533e6bbd0d344a710c491a9eb0ce0ba0852b08cb",
12
+ "components": [
13
+ "LoopVectorize"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": [
17
+ [
18
+ 13,
19
+ 18
20
+ ],
21
+ [
22
+ 173,
23
+ 178
24
+ ]
25
+ ]
26
+ },
27
+ "bug_location_funcname": {
28
+ "llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": [
29
+ "getVPValueOrAddLiveIn"
30
+ ]
31
+ }
32
+ },
33
+ "patch": "commit 533e6bbd0d344a710c491a9eb0ce0ba0852b08cb\nAuthor: Florian Hahn <[email protected]>\nDate: Mon Aug 26 09:15:58 2024 +0100\n\n [VPlan] Simplify live-ins if they are SCEVConstant.\n \n The legacy cost model in some parts checks if any of the operands are\n constants via SCEV. Update VPlan construction to replace live-ins that\n are constants via SCEV with such constants. This means VPlans (and\n codegen) reflects what we computing the cost of and removes another case\n where the legacy and VPlan cost model diverged.\n \n Fixes https://github.com/llvm/llvm-project/issues/105722.\n\ndiff --git a/llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h b/llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h\nindex 0b27933925d8..0fbdeeddaf4a 100644\n--- a/llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h\n+++ b/llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h\n@@ -13,6 +13,7 @@\n #include \"VPlan.h\"\n #include \"llvm/ADT/DenseMap.h\"\n #include \"llvm/ADT/PointerUnion.h\"\n+#include \"llvm/Analysis/ScalarEvolutionExpressions.h\"\n #include \"llvm/IR/IRBuilder.h\"\n \n namespace llvm {\n@@ -173,6 +174,11 @@ public:\n if (auto *R = Ingredient2Recipe.lookup(I))\n return R->getVPSingleValue();\n }\n+ ScalarEvolution &SE = *PSE.getSE();\n+ if (!isa<Constant>(V) && SE.isSCEVable(V->getType()))\n+ if (auto *C = dyn_cast<SCEVConstant>(PSE.getSE()->getSCEV(V)))\n+ return Plan.getOrAddLiveIn(C->getValue());\n+\n return Plan.getOrAddLiveIn(V);\n }\n };\n",
34
+ "tests": [
35
+ {
36
+ "file": "llvm/test/Transforms/LoopVectorize/X86/cost-model.ll",
37
+ "commands": [
38
+ "opt < %s -passes=loop-vectorize -mtriple=x86_64-apple-macosx10.8.0 -mcpu=corei7-avx -S"
39
+ ],
40
+ "tests": [
41
+ {
42
+ "test_name": "cost_assume",
43
+ "test_body": "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-apple-macosx10.8.0\"\n\ndefine i64 @cost_assume(ptr %end, i64 %N) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %0 = phi i64 [ 0, %entry ], [ %1, %loop ]\n %1 = add i64 %0, 1\n %iv.next = add nsw i64 %iv, 1\n %c = icmp ne i64 %N, 0\n tail call void @llvm.assume(i1 %c)\n %gep = getelementptr nusw [9 x i8], ptr null, i64 %iv.next\n %ec = icmp eq ptr %gep, %end\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret i64 %1\n}\n\n; Function Attrs: nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write)\ndeclare void @llvm.assume(i1 noundef) #0\n\nattributes #0 = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) }\n"
44
+ },
45
+ {
46
+ "test_name": "cost_model_1",
47
+ "test_body": "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-apple-macosx10.8.0\"\n\n@c = external global [2048 x i32], align 16\n@b = external global [2048 x i32], align 16\n@d = external global [2048 x i32], align 16\n@a = external global [2048 x i32], align 16\n\n; Function Attrs: noinline nounwind ssp uwtable\ndefine void @cost_model_1() #0 {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]\n %0 = shl nsw i64 %indvars.iv, 1\n %arrayidx = getelementptr inbounds [2048 x i32], ptr @c, i64 0, i64 %0\n %1 = load i32, ptr %arrayidx, align 8\n %idxprom1 = sext i32 %1 to i64\n %arrayidx2 = getelementptr inbounds [2048 x i32], ptr @b, i64 0, i64 %idxprom1\n %2 = load i32, ptr %arrayidx2, align 4\n %arrayidx4 = getelementptr inbounds [2048 x i32], ptr @d, i64 0, i64 %indvars.iv\n %3 = load i32, ptr %arrayidx4, align 4\n %idxprom5 = sext i32 %3 to i64\n %arrayidx6 = getelementptr inbounds [2048 x i32], ptr @a, i64 0, i64 %idxprom5\n store i32 %2, ptr %arrayidx6, align 4\n %indvars.iv.next = add i64 %indvars.iv, 1\n %lftr.wideiv = trunc i64 %indvars.iv.next to i32\n %exitcond = icmp eq i32 %lftr.wideiv, 256\n br i1 %exitcond, label %for.end, label %for.body\n\nfor.end: ; preds = %for.body\n ret void\n}\n\nattributes #0 = { noinline nounwind ssp uwtable }\n"
48
+ },
49
+ {
50
+ "test_name": "avx512_cond_load_cost",
51
+ "test_body": "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-apple-macosx10.8.0\"\n\ndefine i64 @avx512_cond_load_cost(ptr %src, i32 %a, i64 %b, i32 %c, i32 %d) #0 {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %c.1 = icmp slt i32 %iv, 0\n br i1 %c.1, label %if.then, label %loop.latch\n\nif.then: ; preds = %loop.header\n %0 = urem i32 %a, %c\n %mul = sub i32 0, %0\n %div = udiv i32 %c, %d\n %or = or i32 %div, %mul\n %ext = sext i32 %or to i64\n %gep = getelementptr { i64, i64, i64 }, ptr %src, i64 %ext, i32 2\n %l = load i64, ptr %gep, align 8\n %or.2 = or i64 %l, %b\n br label %loop.latch\n\nloop.latch: ; preds = %if.then, %loop.header\n %res = phi i64 [ 0, %loop.header ], [ %or.2, %if.then ]\n %iv.next = add i32 %iv, 1\n %ec = icmp ult i32 %iv, %c\n br i1 %ec, label %loop.header, label %exit\n\nexit: ; preds = %loop.latch\n ret i64 %res\n}\n\nattributes #0 = { \"target-features\"=\"+avx512bw,+avx512cd,+avx512dq,+avx512f,+avx512vl\" }\n"
52
+ },
53
+ {
54
+ "test_name": "multi_exit",
55
+ "test_body": "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-apple-macosx10.8.0\"\n\ndefine void @multi_exit(ptr %dst, ptr %src.1, ptr %src.2, i64 %A, i64 %B) #0 {\nentry:\n br label %loop\n\nloop: ; preds = %loop.latch, %entry\n %iv.1.wide = phi i64 [ 0, %entry ], [ %iv.1.next.wide, %loop.latch ]\n %iv.1 = phi i32 [ 0, %entry ], [ %iv.1.next, %loop.latch ]\n %ec.1 = icmp ult i64 %iv.1.wide, %A\n br i1 %ec.1, label %loop.latch, label %exit\n\nloop.latch: ; preds = %loop\n %l.1 = load i64, ptr %src.1, align 8\n %l.2 = load i64, ptr %src.2, align 8\n %cmp55.us = icmp eq i64 %l.1, 0\n %cmp.i.us = icmp ne i64 %l.2, 0\n %and = and i1 %cmp.i.us, %cmp55.us\n %ext = zext i1 %and to i8\n store i8 %ext, ptr %dst, align 1\n %iv.1.next = add i32 %iv.1, 1\n %iv.1.next.wide = zext i32 %iv.1.next to i64\n %ec.2 = icmp ult i64 %iv.1.next.wide, %B\n br i1 %ec.2, label %loop, label %exit\n\nexit: ; preds = %loop.latch, %loop\n ret void\n}\n\nattributes #0 = { \"target-cpu\"=\"penryn\" }\n"
56
+ },
57
+ {
58
+ "test_name": "cost_duplicate_recipe_for_sinking",
59
+ "test_body": "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-apple-macosx10.8.0\"\n\ndefine void @cost_duplicate_recipe_for_sinking(ptr %A, i64 %N) #0 {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n %iv.shl = shl nsw i64 %iv, 2\n %gep.0 = getelementptr nusw double, ptr %A, i64 %iv.shl\n %l = load double, ptr %gep.0, align 8\n %c = fcmp oeq double %l, 0.000000e+00\n br i1 %c, label %if.then, label %loop.latch\n\nif.then: ; preds = %loop.header\n %gep.1 = getelementptr double, ptr %A, i64 %iv.shl\n store double 0.000000e+00, ptr %gep.1, align 8\n br label %loop.latch\n\nloop.latch: ; preds = %if.then, %loop.header\n %iv.next = add nsw i64 %iv, 1\n %ec = icmp eq i64 %iv, %N\n br i1 %ec, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n ret void\n}\n\nattributes #0 = { \"target-cpu\"=\"znver3\" }\n"
60
+ },
61
+ {
62
+ "test_name": "any_of_cost",
63
+ "test_body": "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-apple-macosx10.8.0\"\n\ndefine i1 @any_of_cost(ptr %start, ptr %end) #0 {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %any.of = phi i1 [ false, %entry ], [ %any.of.next, %loop ]\n %ptr.iv = phi ptr [ %start, %entry ], [ %ptr.iv.next, %loop ]\n %gep = getelementptr i8, ptr %ptr.iv, i64 8\n %l = load ptr, ptr %gep, align 8\n %cmp13.not.not = icmp eq ptr %l, null\n %any.of.next = select i1 %cmp13.not.not, i1 %any.of, i1 false\n %ptr.iv.next = getelementptr inbounds i8, ptr %ptr.iv, i64 40\n %cmp.not = icmp eq ptr %ptr.iv, %end\n br i1 %cmp.not, label %exit, label %loop\n\nexit: ; preds = %loop\n ret i1 %any.of.next\n}\n\nattributes #0 = { \"target-cpu\"=\"penryn\" }\n"
64
+ },
65
+ {
66
+ "test_name": "live_in_known_1_via_scev",
67
+ "test_body": "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-apple-macosx10.8.0\"\n\ndefine i64 @live_in_known_1_via_scev() {\nentry:\n %sel = select i1 false, i32 3, i32 0\n br label %ph\n\nph: ; preds = %entry\n %p = phi i32 [ 1, %entry ]\n %N = add nuw nsw i32 %sel, 6\n %p.ext = zext nneg i32 %p to i64\n br label %loop\n\nloop: ; preds = %loop, %ph\n %iv = phi i32 [ 0, %ph ], [ %iv.next, %loop ]\n %red = phi i64 [ 3, %ph ], [ %red.mul, %loop ]\n %red.mul = mul nsw i64 %red, %p.ext\n %iv.next = add nuw nsw i32 %iv, 1\n %ec = icmp eq i32 %iv.next, %N\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n %res = phi i64 [ %red.mul, %loop ]\n ret i64 %res\n}\n"
68
+ },
69
+ {
70
+ "test_name": "reduction_store",
71
+ "test_body": "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-apple-macosx10.8.0\"\n\ndefine void @reduction_store(ptr noalias %src, ptr %dst, i1 %x) #0 {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %red = phi i32 [ 0, %entry ], [ %red.next, %loop ]\n %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]\n %gep.src = getelementptr inbounds i32, ptr %src, i32 %iv\n %l = load i32, ptr %gep.src, align 4\n %l.and = and i32 %l, 3\n store i32 %l.and, ptr %dst, align 4\n %x.ext = zext i1 %x to i64\n %lshr = lshr i64 %x.ext, 12\n %t = trunc i64 %lshr to i32\n %red.next = and i32 %red, %t\n store i32 %red.next, ptr %dst, align 4\n %iv.next = add i32 %iv, 1\n %ec = icmp eq i32 %iv, 29\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n\nattributes #0 = { \"target-cpu\"=\"znver3\" }\n"
72
+ },
73
+ {
74
+ "test_name": "PR27826",
75
+ "test_body": "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-apple-macosx10.8.0\"\n\ndefine float @PR27826(ptr nocapture readonly %a, ptr nocapture readonly %b, i32 %n) {\nentry:\n %cmp = icmp sgt i32 %n, 0\n br i1 %cmp, label %preheader, label %for.end\n\npreheader: ; preds = %entry\n %t0 = sext i32 %n to i64\n br label %for\n\nfor: ; preds = %for, %preheader\n %indvars.iv = phi i64 [ 0, %preheader ], [ %indvars.iv.next, %for ]\n %s.02 = phi float [ 0.000000e+00, %preheader ], [ %add4, %for ]\n %arrayidx = getelementptr inbounds float, ptr %a, i64 %indvars.iv\n %t1 = load float, ptr %arrayidx, align 4\n %arrayidx3 = getelementptr inbounds float, ptr %b, i64 %indvars.iv\n %t2 = load float, ptr %arrayidx3, align 4\n %add = fadd fast float %t1, %s.02\n %add4 = fadd fast float %add, %t2\n %indvars.iv.next = add nuw nsw i64 %indvars.iv, 32\n %cmp1 = icmp slt i64 %indvars.iv.next, %t0\n br i1 %cmp1, label %for, label %loopexit\n\nloopexit: ; preds = %for\n %add4.lcssa = phi float [ %add4, %for ]\n br label %for.end\n\nfor.end: ; preds = %loopexit, %entry\n %s.0.lcssa = phi float [ 0.000000e+00, %entry ], [ %add4.lcssa, %loopexit ]\n ret float %s.0.lcssa\n}\n"
76
+ }
77
+ ]
78
+ }
79
+ ],
80
+ "issue": {
81
+ "title": "[clang] Assertion failed in Vectorize",
82
+ "body": "To reproduce, compile it with -O2: clang -O2 example.c\r\n\r\n```c\r\n#include <stdint.h>\r\nint a;\r\nlong b;\r\nstatic int32_t c;\r\nvoid d(int e, int h) {\r\n int f = a = 1;\r\n for (; a <= e; a++)\r\n f *= a;\r\n a = 0;\r\n for (; a < h; a++)\r\n b *= f;\r\n}\r\nlong g() {}\r\nint32_t i() {\r\n for (; g();)\r\n for (c = 3;;)\r\n ;\r\n}\r\nuint16_t j() { d(c + 1, c + 6); }\r\n```\r\n\r\nThe error message is as follows:\r\n\r\n```\r\nllvm/lib/Transforms/Vectorize/LoopVectorize.cpp:9985: bool llvm::LoopVectorizePass::processLoop(llvm::Loop *): Assertion `VF.Width == BestVF && \"VPlan cost model and legacy cost model disagreed\"' failed.\r\n```",
83
+ "author": "cardigan1008",
84
+ "labels": [
85
+ "vectorizers",
86
+ "confirmed",
87
+ "crash"
88
+ ],
89
+ "comments": [
90
+ {
91
+ "author": "EugeneZelenko",
92
+ "body": "See https://godbolt.org/z/jc8qqo8Ta"
93
+ },
94
+ {
95
+ "author": "shafik",
96
+ "body": "Looks like a recent regression since it does not crash on trunk: https://godbolt.org/z/sKjdvMq54\r\n\r\nAssertion:\r\n\r\n```console\r\nclang++: /root/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:7288: \r\nllvm::VectorizationFactor llvm::LoopVectorizationPlanner::computeBestVF():\r\nAssertion `BestFactor.Width == LegacyVF.Width && \" VPlan cost model and legacy cost model disagreed\"' failed.\r\n```\r\n\r\nBacktrace: \r\n\r\n```console\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.\r\nStack dump:\r\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/clang++ -gdwarf-4 -g -o /app/output.s -mllvm --x86-asm-syntax=intel -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -x c -O2 <source>\r\n1.\t<eof> parser at end of file\r\n2.\tOptimizer\r\n3.\tRunning pass \"function<eager-inv>(float2int,lower-constant-intrinsics,loop(loop-rotate<header-duplication;no-prepare-for-lto>,loop-deletion),loop-distribute,inject-tli-mappings,loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,infer-alignment,loop-load-elim,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,slp-vectorizer,vector-combine,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,loop-unroll<O2>,transform-warning,sroa<preserve-cfg>,infer-alignment,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,loop-sink,instsimplify,div-rem-pairs,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch;speculate-unpredictables>)\" on module \"<source>\"\r\n4.\tRunning pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"j\"\r\n #0 0x0000000003b02648 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3b02648)\r\n #1 0x0000000003b0033c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3b0033c)\r\n #2 0x0000000003a492b8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0\r\n #3 0x000078485ee42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #4 0x000078485ee969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\r\n #5 0x000078485ee42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\r\n #6 0x000078485ee287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\r\n #7 0x000078485ee2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\r\n #8 0x000078485ee39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n #9 0x00000000054df418 llvm::LoopVectorizationPlanner::computeBestVF() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x54df418)\r\n#10 0x00000000054fa07a llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x54fa07a)\r\n#11 0x00000000054fcd39 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x54fcd39)\r\n#12 0x00000000054fd3c3 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x54fd3c3)\r\n#13 0x00000000050ac09e llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x50ac09e)\r\n#14 0x00000000034cac68 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x34cac68)\r\n#15 0x00000000010bce6e llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x10bce6e)\r\n#16 0x00000000034c966e llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x34c966e)\r\n#17 0x00000000010bc75e llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x10bc75e)\r\n#18 0x00000000034c7800 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x34c7800)\r\n#19 0x0000000003da8895 (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>&, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>&, clang::BackendConsumer*) BackendUtil.cpp:0:0\r\n#20 0x0000000003dab9fd clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3dab9fd)\r\n#21 0x00000000044196ac clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44196ac)\r\n#22 0x000000000651f80c clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x651f80c)\r\n#23 0x0000000004419b18 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4419b18)\r\n#24 0x00000000046a79f9 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x46a79f9)\r\n#25 0x000000000462b30e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x462b30e)\r\n#26 0x000000000479104e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x479104e)\r\n#27 0x0000000000ca5b0f cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xca5b0f)\r\n#28 0x0000000000c9ed5a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\r\n#29 0x000000000445d1d9 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0\r\n#30 0x0000000003a49764 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3a49764)\r\n#31 0x000000000445d7cf clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0\r\n#32 0x0000000004423365 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4423365)\r\n#33 0x0000000004423dcd clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4423dcd)\r\n#34 0x000000000442b9e5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x442b9e5)\r\n#35 0x0000000000ca2f05 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xca2f05)\r\n#36 0x0000000000b776e4 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xb776e4)\r\n#37 0x000078485ee29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\r\n#38 0x000078485ee29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\r\n#39 0x0000000000c9e80e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc9e80e)\r\nclang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)\r\nCompiler returned: 134\r\n```"
97
+ },
98
+ {
99
+ "author": "cardigan1008",
100
+ "body": "The crash persists in the above cases even with the applied patches. "
101
+ },
102
+ {
103
+ "author": "fhahn",
104
+ "body": "@cardigan1008 I can't reproduce the crash locally with latest main. If it still reproduces on current main for you, could you share the crashing IR, using `-mllvm -print-on-crash -mllvm -print-module-scope`?"
105
+ },
106
+ {
107
+ "author": "cardigan1008",
108
+ "body": "@fhahn Apologies for the confusion. I pulled the latest version, and this case is now working. However, I encountered a similar crash with another case that I'm currently fuzzing. I'll open a separate issue as soon as I've finished reducing it."
109
+ },
110
+ {
111
+ "author": "cardigan1008",
112
+ "body": "Hi @fhahn , I have submitted another issue with the same crash in #106248 . "
113
+ }
114
+ ]
115
+ },
116
+ "verified": true
117
+ }
dataset/105785.json ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "105785",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/105785",
4
+ "bug_type": "miscompilation",
5
+ "base_commit": "1241c762c165972690c4edfb82ec7421c1e64658",
6
+ "knowledge_cutoff": "2024-08-23T05:45:52Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/ConstraintElimination"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "85b6aac7c25f9d2a976a76045ace1e7afebb5965",
12
+ "components": [
13
+ "ConstraintElimination"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": [
17
+ [
18
+ 1464,
19
+ 1470
20
+ ]
21
+ ]
22
+ },
23
+ "bug_location_funcname": {
24
+ "llvm/lib/Transforms/Scalar/ConstraintElimination.cpp": [
25
+ "checkAndReplaceCmp"
26
+ ]
27
+ }
28
+ },
29
+ "patch": "commit 3ff9d92aae0945daa85ec6f85f05a3aeaaa9f962\nAuthor: Yingwei Zheng <[email protected]>\nDate: Fri Aug 23 16:06:00 2024 +0800\n\n [ConstraintElim] Fix miscompilation caused by PR97974 (#105790)\n \n Fixes https://github.com/llvm/llvm-project/issues/105785.\n \n (cherry picked from commit 85b6aac7c25f9d2a976a76045ace1e7afebb5965)\n\ndiff --git a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp\nindex c31173879af1..37022104d0a9 100644\n--- a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp\n+++ b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp\n@@ -1464,7 +1464,7 @@ static bool checkAndReplaceCmp(CmpIntrinsic *I, ConstraintInfo &Info,\n ToRemove.push_back(I);\n return true;\n }\n- if (checkCondition(ICmpInst::ICMP_EQ, LHS, RHS, I, Info)) {\n+ if (checkCondition(ICmpInst::ICMP_EQ, LHS, RHS, I, Info).value_or(false)) {\n I->replaceAllUsesWith(ConstantInt::get(I->getType(), 0));\n ToRemove.push_back(I);\n return true;\n",
30
+ "tests": [
31
+ {
32
+ "file": "llvm/test/Transforms/ConstraintElimination/pr105785.ll",
33
+ "commands": [
34
+ "opt -passes=constraint-elimination -S %s"
35
+ ],
36
+ "tests": [
37
+ {
38
+ "test_name": "pr105785",
39
+ "test_body": "define void @pr105785(ptr %p) {\nentry:\n br label %for.cond\n\nfor.cond: ; preds = %for.cond1, %entry\n %for.ind = phi i32 [ 0, %entry ], [ 1, %for.cond1 ]\n %cmp = icmp eq i32 %for.ind, 0\n br i1 %cmp, label %for.cond1, label %for.end6\n\nfor.cond1: ; preds = %for.body3, %for.cond\n %for.ind2 = phi i32 [ %inc, %for.body3 ], [ 0, %for.cond ]\n %cmp2 = icmp ult i32 %for.ind2, 3\n br i1 %cmp2, label %for.body3, label %for.cond\n\nfor.body3: ; preds = %for.cond1\n %scmp = call i32 @llvm.scmp.i32.i32(i32 %for.ind, i32 1)\n store i32 %scmp, ptr %p, align 4\n %inc = add nuw nsw i32 %for.ind2, 1\n br label %for.cond1\n\nfor.end6: ; preds = %for.cond\n ret void\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.scmp.i32.i32(i32, i32) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"
40
+ }
41
+ ]
42
+ }
43
+ ],
44
+ "issue": {
45
+ "title": "[ConstraintElim] Miscompilation with cmp intrinsic",
46
+ "body": "Reproducer: https://alive2.llvm.org/ce/z/Tvz2NA\r\n```\r\n; bin/opt -passes=constraint-elimination test.ll -S\r\ndefine void @h(ptr %p) {\r\nentry:\r\n br label %for.cond\r\n\r\nfor.cond: ; preds = %for.cond1, %entry\r\n %storemerge = phi i32 [ 0, %entry ], [ 1, %for.cond1 ]\r\n %cmp = icmp eq i32 %storemerge, 0\r\n br i1 %cmp, label %for.cond1, label %for.end6\r\n\r\nfor.cond1: ; preds = %for.cond, %for.body3\r\n %i.0 = phi i32 [ %inc, %for.body3 ], [ 0, %for.cond ]\r\n %cmp2 = icmp ult i32 %i.0, 3\r\n br i1 %cmp2, label %for.body3, label %for.cond\r\n\r\nfor.body3: ; preds = %for.cond1\r\n %sub.i = tail call range(i32 -1, 2) i32 @llvm.scmp.i32.i32(i32 1, i32 %storemerge)\r\n store i32 %sub.i, ptr %p, align 4\r\n %inc = add nuw nsw i32 %i.0, 1\r\n br label %for.cond1\r\n\r\nfor.end6:\r\n ret void\r\n}\r\n```\r\n\r\n```\r\ndefine void @h(ptr %p) {\r\nentry:\r\n br label %for.cond\r\n\r\nfor.cond: ; preds = %for.cond1, %entry\r\n %storemerge = phi i32 [ 0, %entry ], [ 1, %for.cond1 ]\r\n %cmp = icmp eq i32 %storemerge, 0\r\n br i1 %cmp, label %for.cond1, label %for.end6\r\n\r\nfor.cond1: ; preds = %for.body3, %for.cond\r\n %i.0 = phi i32 [ %inc, %for.body3 ], [ 0, %for.cond ]\r\n %cmp2 = icmp ult i32 %i.0, 3\r\n br i1 %cmp2, label %for.body3, label %for.cond\r\n\r\nfor.body3: ; preds = %for.cond1\r\n store i32 0, ptr %p, align 4\r\n %inc = add nuw nsw i32 %i.0, 1\r\n br label %for.cond1\r\n\r\nfor.end6: ; preds = %for.cond\r\n ret void\r\n}\r\n```\r\n\r\nThe result of scmp should be 1 instead of 0.\r\n\r\nReduced C reproducer:\r\n```\r\n#include <stdio.h>\r\n#include <stdint.h>\r\n\r\nint builtin_scmp(int d, int e) { return (d > e) - (d < e); }\r\nint32_t f = 0;\r\nint64_t g = 0;\r\nvoid h() {\r\n for (f = 0; f <= 0; f++) {\r\n int i;\r\n for (i = 0; i < 3; i++)\r\n g = builtin_scmp(1, f);\r\n }\r\n}\r\nint main() {\r\n h();\r\n printf(\"%d\\n\", (int)g);\r\n return 0;\r\n}\r\n```\r\n\r\nI will post a fix later.\r\n",
47
+ "author": "dtcxzyw",
48
+ "labels": [
49
+ "miscompilation",
50
+ "llvm:transforms"
51
+ ],
52
+ "comments": []
53
+ },
54
+ "verified": true
55
+ }
dataset/105904.json ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "105904",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/105904",
4
+ "bug_type": "crash",
5
+ "base_commit": "499e13514aaf2efdcd85520ade791ed635502adb",
6
+ "knowledge_cutoff": "2024-08-23T22:57:57Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/SLPVectorizer"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "b9d3da8c8d277a7fc2223c659122bb377a0e54e0",
12
+ "components": [
13
+ "SLPVectorizer"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
17
+ [
18
+ 3011,
19
+ 3017
20
+ ]
21
+ ]
22
+ },
23
+ "bug_location_funcname": {
24
+ "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
25
+ "isOperandGatherNode"
26
+ ]
27
+ }
28
+ },
29
+ "patch": "commit b9d3da8c8d277a7fc2223c659122bb377a0e54e0\nAuthor: Alexey Bataev <[email protected]>\nDate: Mon Aug 26 04:31:44 2024 -0700\n\n [SLP]Fix PR105904: the root node might be a gather node without user for reductions.\n \n Before checking the user components of the gather/buildvector nodes,\n need to check if the node has users at all. Root nodes might not have\n users, if it is a node for the reduction.\n \n Fixes https://github.com/llvm/llvm-project/issues/105904\n\ndiff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\nindex 949579772b94..def73e8d0c0d 100644\n--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n@@ -3011,7 +3011,8 @@ private:\n }\n \n bool isOperandGatherNode(const EdgeInfo &UserEI) const {\n- return isGather() && UserTreeIndices.front().EdgeIdx == UserEI.EdgeIdx &&\n+ return isGather() && (Idx > 0 || !UserTreeIndices.empty()) &&\n+ UserTreeIndices.front().EdgeIdx == UserEI.EdgeIdx &&\n UserTreeIndices.front().UserTE == UserEI.UserTE;\n }\n \n",
30
+ "tests": [
31
+ {
32
+ "file": "llvm/test/Transforms/SLPVectorizer/RISCV/gather-node-with-no-users.ll",
33
+ "commands": [
34
+ "opt -S --passes=slp-vectorizer -mtriple=riscv64-unknown-linux-gnu -mattr=+v,+zvl512b < %s"
35
+ ],
36
+ "tests": [
37
+ {
38
+ "test_name": "test",
39
+ "test_body": "define void @test(ptr %c) {\nentry:\n %arrayidx8.5.3 = getelementptr i8, ptr %c, i64 222\n %0 = load i8, ptr %arrayidx8.5.3, align 1\n %arrayidx8.7.3 = getelementptr i8, ptr %c, i64 228\n %1 = load i8, ptr %arrayidx8.7.3, align 1\n %arrayidx8.434 = getelementptr i8, ptr %c, i64 276\n %2 = load i8, ptr %arrayidx8.434, align 1\n %arrayidx8.1.4 = getelementptr i8, ptr %c, i64 279\n %3 = load i8, ptr %arrayidx8.1.4, align 1\n %arrayidx8.2.4 = getelementptr i8, ptr %c, i64 282\n %4 = load i8, ptr %arrayidx8.2.4, align 1\n %arrayidx8.3.4 = getelementptr i8, ptr %c, i64 285\n %5 = load i8, ptr %arrayidx8.3.4, align 1\n %arrayidx8.4.4 = getelementptr i8, ptr %c, i64 288\n %6 = load i8, ptr %arrayidx8.4.4, align 1\n %7 = load i8, ptr %c, align 1\n %8 = load i8, ptr %c, align 1\n %arrayidx8.536 = getelementptr i8, ptr %c, i64 345\n %9 = load i8, ptr %arrayidx8.536, align 1\n %arrayidx8.1.5 = getelementptr i8, ptr %c, i64 348\n %10 = load i8, ptr %arrayidx8.1.5, align 1\n %arrayidx8.2.5 = getelementptr i8, ptr %c, i64 351\n %11 = load i8, ptr %arrayidx8.2.5, align 1\n %arrayidx8.3.5 = getelementptr i8, ptr %c, i64 354\n %12 = load i8, ptr %arrayidx8.3.5, align 1\n %arrayidx8.4.5 = getelementptr i8, ptr %c, i64 357\n %13 = load i8, ptr %arrayidx8.4.5, align 1\n %arrayidx8.5.5 = getelementptr i8, ptr %c, i64 360\n %14 = load i8, ptr %arrayidx8.5.5, align 1\n %arrayidx8.6.5 = getelementptr i8, ptr %c, i64 363\n %15 = load i8, ptr %arrayidx8.6.5, align 1\n br label %for.cond\n\nfor.cond: ; preds = %for.cond, %entry\n %a.promoted2226 = phi i8 [ 0, %entry ], [ %or18.6.5, %for.cond ]\n %or18.7.3 = or i8 %0, %1\n %or18.435 = or i8 %or18.7.3, %2\n %or18.1.4 = or i8 %or18.435, %3\n %or18.2.4 = or i8 %or18.1.4, %4\n %or18.3.4 = or i8 %or18.2.4, %5\n %or18.4.4 = or i8 %or18.3.4, %6\n %or18.5.4 = or i8 %or18.4.4, %7\n %or18.6.4 = or i8 %or18.5.4, %8\n %or18.537 = or i8 %or18.6.4, %9\n %or18.1.5 = or i8 %or18.537, %10\n %or18.2.5 = or i8 %or18.1.5, %11\n %or18.3.5 = or i8 %or18.2.5, %12\n %or18.4.5 = or i8 %or18.3.5, %13\n %or18.5.5 = or i8 %or18.4.5, %14\n %or18.6.5 = or i8 %or18.5.5, %15\n br label %for.cond\n}\n"
40
+ }
41
+ ]
42
+ }
43
+ ],
44
+ "issue": {
45
+ "title": "[SLP Vectorizer] Assertion `!empty()' failed.",
46
+ "body": "Testcase:\r\n```llvm ir\r\n ModuleID = 'reduced.bc'\r\ntarget datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\r\ntarget triple = \"riscv64-unknown-linux-gnu\"\r\n\r\ndefine void @b(ptr %c) #0 {\r\nentry:\r\n %arrayidx8.5.3 = getelementptr i8, ptr %c, i64 222\r\n %0 = load i8, ptr %arrayidx8.5.3, align 1\r\n %arrayidx8.7.3 = getelementptr i8, ptr %c, i64 228\r\n %1 = load i8, ptr %arrayidx8.7.3, align 1\r\n %arrayidx8.434 = getelementptr i8, ptr %c, i64 276\r\n %2 = load i8, ptr %arrayidx8.434, align 1\r\n %arrayidx8.1.4 = getelementptr i8, ptr %c, i64 279\r\n %3 = load i8, ptr %arrayidx8.1.4, align 1\r\n %arrayidx8.2.4 = getelementptr i8, ptr %c, i64 282\r\n %4 = load i8, ptr %arrayidx8.2.4, align 1\r\n %arrayidx8.3.4 = getelementptr i8, ptr %c, i64 285\r\n %5 = load i8, ptr %arrayidx8.3.4, align 1\r\n %arrayidx8.4.4 = getelementptr i8, ptr %c, i64 288\r\n %6 = load i8, ptr %arrayidx8.4.4, align 1\r\n %7 = load i8, ptr %c, align 1\r\n %8 = load i8, ptr %c, align 1\r\n %arrayidx8.536 = getelementptr i8, ptr %c, i64 345\r\n %9 = load i8, ptr %arrayidx8.536, align 1\r\n %arrayidx8.1.5 = getelementptr i8, ptr %c, i64 348\r\n %10 = load i8, ptr %arrayidx8.1.5, align 1\r\n %arrayidx8.2.5 = getelementptr i8, ptr %c, i64 351\r\n %11 = load i8, ptr %arrayidx8.2.5, align 1\r\n %arrayidx8.3.5 = getelementptr i8, ptr %c, i64 354\r\n %12 = load i8, ptr %arrayidx8.3.5, align 1\r\n %arrayidx8.4.5 = getelementptr i8, ptr %c, i64 357\r\n %13 = load i8, ptr %arrayidx8.4.5, align 1\r\n %arrayidx8.5.5 = getelementptr i8, ptr %c, i64 360\r\n %14 = load i8, ptr %arrayidx8.5.5, align 1\r\n %arrayidx8.6.5 = getelementptr i8, ptr %c, i64 363\r\n %15 = load i8, ptr %arrayidx8.6.5, align 1\r\n br label %for.cond\r\n\r\nfor.cond: ; preds = %for.cond, %entry\r\n %a.promoted2226 = phi i8 [ 0, %entry ], [ %or18.6.5, %for.cond ]\r\n %or18.7.3 = or i8 %0, %1\r\n %or18.435 = or i8 %or18.7.3, %2\r\n %or18.1.4 = or i8 %or18.435, %3\r\n %or18.2.4 = or i8 %or18.1.4, %4\r\n %or18.3.4 = or i8 %or18.2.4, %5\r\n %or18.4.4 = or i8 %or18.3.4, %6\r\n %or18.5.4 = or i8 %or18.4.4, %7\r\n %or18.6.4 = or i8 %or18.5.4, %8\r\n %or18.537 = or i8 %or18.6.4, %9\r\n %or18.1.5 = or i8 %or18.537, %10\r\n %or18.2.5 = or i8 %or18.1.5, %11\r\n %or18.3.5 = or i8 %or18.2.5, %12\r\n %or18.4.5 = or i8 %or18.3.5, %13\r\n %or18.5.5 = or i8 %or18.4.5, %14\r\n %or18.6.5 = or i8 %or18.5.5, %15\r\n br label %for.cond\r\n}\r\n\r\nattributes #0 = { \"target-features\"=\"+64bit,+relax,+xsifivecflushdlone,+zicsr,+zve32x,+zve64x,+zvl1024b,+zvl128b,+zvl256b,+zvl32b,+zvl512b,+zvl64b,-a,-b,-c,-d,-e,-experimental-smctr,-experimental-smmpm,-experimental-smnpm,-experimental-ssctr,-experimental-ssnpm,-experimental-sspm,-experimental-supm,-experimental-zacas,-experimental-zalasr,-experimental-zicfilp,-experimental-zicfiss,-experimental-zvbc32e,-experimental-zvkgs,-f,-h,-m,-shcounterenw,-shgatpa,-shtvala,-shvsatpa,-shvstvala,-shvstvecd,-smaia,-smcdeleg,-smcsrind,-smepmp,-smstateen,-ssaia,-ssccfg,-ssccptr,-sscofpmf,-sscounterenw,-sscsrind,-ssqosid,-ssstateen,-ssstrict,-sstc,-sstvala,-sstvecd,-ssu64xl,-svade,-svadu,-svbare,-svinval,-svnapot,-svpbmt,-v,-xcvalu,-xcvbi,-xcvbitmanip,-xcvelw,-xcvmac,-xcvmem,-xcvsimd,-xsfcease,-xsfvcp,-xsfvfnrclipxfqf,-xsfvfwmaccqqq,-xsfvqmaccdod,-xsfvqmaccqoq,-xsifivecdiscarddlone,-xtheadba,-xtheadbb,-xtheadbs,-xtheadcmo,-xtheadcondmov,-xtheadfmemidx,-xtheadmac,-xtheadmemidx,-xtheadmempair,-xtheadsync,-xtheadvdot,-xventanacondops,-xwchc,-za128rs,-za64rs,-zaamo,-zabha,-zalrsc,-zama16b,-zawrs,-zba,-zbb,-zbc,-zbkb,-zbkc,-zbkx,-zbs,-zca,-zcb,-zcd,-zce,-zcf,-zcmop,-zcmp,-zcmt,-zdinx,-zfa,-zfbfmin,-zfh,-zfhmin,-zfinx,-zhinx,-zhinxmin,-zic64b,-zicbom,-zicbop,-zicboz,-ziccamoa,-ziccif,-zicclsm,-ziccrse,-zicntr,-zicond,-zifencei,-zihintntl,-zihintpause,-zihpm,-zimop,-zk,-zkn,-zknd,-zkne,-zknh,-zkr,-zks,-zksed,-zksh,-zkt,-zmmul,-ztso,-zvbb,-zvbc,-zve32f,-zve64d,-zve64f,-zvfbfmin,-zvfbfwma,-zvfh,-zvfhmin,-zvkb,-zvkg,-zvkn,-zvknc,-zvkned,-zvkng,-zvknha,-zvknhb,-zvks,-zvksc,-zvksed,-zvksg,-zvksh,-zvkt,-zvl16384b,-zvl2048b,-zvl32768b,-zvl4096b,-zvl65536b,-zvl8192b\" }\r\n```\r\nGodbolt: https://godbolt.org/z/Thhajqn9q\r\n\r\nCommand/backtrace:\r\n```\r\n> /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt --passes=slp-vectorizer -S reduced.ll\r\nopt: /scratch/tc-testing/tc-compiler-fuzz-trunk/llvm/llvm/include/llvm/ADT/SmallVector.h:317: const T& llvm::SmallVectorTemplateCommon<T, <template-parameter-1-2> >::front() const [with T = llvm::slpvectorizer::BoUpSLP::EdgeInfo; <template-parameter-1-2> = void; llvm::SmallVectorTemplateCommon<T, <template-parameter-1-2> >::const_reference = const llvm::slpvectorizer::BoUpSLP::EdgeInfo&]: Assertion `!empty()' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0. Program arguments: /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt --passes=slp-vectorizer -S reduced.ll\r\n1. Running pass \"function(slp-vectorizer)\" on module \"reduced.ll\"\r\n2. Running pass \"slp-vectorizer\" on function \"b\"\r\n #0 0x00005da37ad02b80 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x300eb80)\r\n #1 0x00005da37acfff9f llvm::sys::RunSignalHandlers() (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x300bf9f)\r\n #2 0x00005da37ad000f5 SignalHandler(int) Signals.cpp:0:0\r\n #3 0x0000733cc0242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #4 0x0000733cc02969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\r\n #5 0x0000733cc02969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10\r\n #6 0x0000733cc02969fc pthread_kill ./nptl/pthread_kill.c:89:10\r\n #7 0x0000733cc0242476 gsignal ./signal/../sysdeps/posix/raise.c:27:6\r\n #8 0x0000733cc02287f3 abort ./stdlib/abort.c:81:7\r\n #9 0x0000733cc022871b _nl_load_domain ./intl/loadmsgcat.c:1177:9\r\n#10 0x0000733cc0239e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n#11 0x00005da379da2beb llvm::slpvectorizer::BoUpSLP::vectorizeOperand(llvm::slpvectorizer::BoUpSLP::TreeEntry*, unsigned int, bool) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x20aebeb)\r\n#12 0x00005da379d9e086 llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::slpvectorizer::BoUpSLP::TreeEntry*, bool) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x20aa086)\r\n#13 0x00005da379da2372 llvm::slpvectorizer::BoUpSLP::vectorizeOperand(llvm::slpvectorizer::BoUpSLP::TreeEntry*, unsigned int, bool) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x20ae372)\r\n#14 0x00005da379d9db47 llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::slpvectorizer::BoUpSLP::TreeEntry*, bool) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x20a9b47)\r\n#15 0x00005da379d9c510 llvm::slpvectorizer::BoUpSLP::createBuildVector(llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::Type*) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x20a8510)\r\n#16 0x00005da379d9cf7b llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::slpvectorizer::BoUpSLP::TreeEntry*, bool) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x20a8f7b)\r\n#17 0x00005da379da62cf llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::MapVector<llvm::Value*, llvm::SmallVector<llvm::Instruction*, 2u>, llvm::DenseMap<llvm::Value*, unsigned int, llvm::DenseMapInfo<llvm::Value*, void>, llvm::detail::DenseMapPair<llvm::Value*, unsigned int>>, llvm::SmallVector<std::pair<llvm::Value*, llvm::SmallVector<llvm::Instruction*, 2u>>, 0u>> const&, llvm::SmallVectorImpl<std::pair<llvm::Value*, llvm::Value*>>&, llvm::Instruction*) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x20b22cf)\r\n#18 0x00005da379db2bd5 (anonymous namespace)::HorizontalReduction::tryToReduce(llvm::slpvectorizer::BoUpSLP&, llvm::DataLayout const&, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo const&) SLPVectorizer.cpp:0:0\r\n#19 0x00005da379db5599 llvm::SLPVectorizerPass::vectorizeHorReduction(llvm::PHINode*, llvm::Instruction*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&, llvm::TargetTransformInfo*, llvm::SmallVectorImpl<llvm::WeakTrackingVH>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x20c1599)\r\n#20 0x00005da379db9a68 llvm::SLPVectorizerPass::vectorizeRootInstruction(llvm::PHINode*, llvm::Instruction*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&, llvm::TargetTransformInfo*) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x20c5a68)\r\n#21 0x00005da379dbd75c llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x20c975c)\r\n#22 0x00005da379dc41b0 llvm::SLPVectorizerPass::runImpl(llvm::Function&, llvm::ScalarEvolution*, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo*, llvm::AAResults*, llvm::LoopInfo*, llvm::DominatorTree*, llvm::AssumptionCache*, llvm::DemandedBits*, llvm::OptimizationRemarkEmitter*) (.part.0) SLPVectorizer.cpp:0:0\r\n#23 0x00005da379dc4da2 llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x20d0da2)\r\n#24 0x00005da378b51cf6 llvm::detail::PassModel<llvm::Function, llvm::SLPVectorizerPass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xe5dcf6)\r\n#25 0x00005da37ab0e94f llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2e1a94f)\r\n#26 0x00005da378b544f6 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xe604f6)\r\n#27 0x00005da37ab0d6cb llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2e196cb)\r\n#28 0x00005da378b50796 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xe5c796)\r\n#29 0x00005da37ab0b70d llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2e1770d)\r\n#30 0x00005da37837ae56 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x686e56)\r\n#31 0x00005da37836cbe1 optMain (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x678be1)\r\n#32 0x0000733cc0229d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16\r\n#33 0x0000733cc0229e40 call_init ./csu/../csu/libc-start.c:128:20\r\n#34 0x0000733cc0229e40 __libc_start_main ./csu/../csu/libc-start.c:379:5\r\n#35 0x00005da378362f95 _start (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x66ef95)\r\nzsh: IOT instruction (core dumped) /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt\r\n```\r\n\r\nFound via fuzzer",
47
+ "author": "patrick-rivos",
48
+ "labels": [
49
+ "llvm:SLPVectorizer",
50
+ "crash"
51
+ ],
52
+ "comments": []
53
+ },
54
+ "verified": true
55
+ }
dataset/105988.json ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "105988",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/105988",
4
+ "bug_type": "miscompilation",
5
+ "base_commit": "4b0c0ec6b8065e611640f44adce94e2da12b3a3a",
6
+ "knowledge_cutoff": "2024-08-25T14:54:29Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/SLPVectorizer"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "e1d22512906e69846c8f6a2d29b30832b7c12b46",
12
+ "components": [
13
+ "SLPVectorizer"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
17
+ [
18
+ 15975,
19
+ 15980
20
+ ]
21
+ ]
22
+ },
23
+ "bug_location_funcname": {
24
+ "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
25
+ "BoUpSLP::computeMinimumValueSizes"
26
+ ]
27
+ }
28
+ },
29
+ "patch": "commit e1d22512906e69846c8f6a2d29b30832b7c12b46\nAuthor: Alexey Bataev <[email protected]>\nDate: Mon Aug 26 11:30:13 2024 -0700\n\n [SLP]Fix minbitwidth analysis for gather nodes with icmp users.\n \n If the node is not in MinBWs container and the user node is icmp node,\n the compiler should not check the type size of the user instruction, it\n is always 1 and is not good for actual bitwidth analysis.\n \n Fixes https://github.com/llvm/llvm-project/issues/105988\n\ndiff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\nindex def73e8d0c0d..ed47ed661ab9 100644\n--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n@@ -15975,6 +15975,10 @@ void BoUpSLP::computeMinimumValueSizes() {\n auto It = MinBWs.find(TE);\n if (It != MinBWs.end() && It->second.first > UserTESz)\n return true;\n+ // The size of icmp is always 1 and should not be\n+ // considered.\n+ if (TE->getOpcode() == Instruction::ICmp)\n+ return true;\n return DL->getTypeSizeInBits(U->getType()) > UserTESz;\n }));\n })) {\n",
30
+ "tests": [
31
+ {
32
+ "file": "llvm/test/Transforms/SLPVectorizer/X86/gather-with-cmp-user.ll",
33
+ "commands": [
34
+ "opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu < %s"
35
+ ],
36
+ "tests": [
37
+ {
38
+ "test_name": "test",
39
+ "test_body": "define i1 @test(i32 %g, i16 %d) {\nentry:\n %0 = and i16 %d, 1\n %xor.i.i = xor i32 %g, 1\n %conv1.i.i = trunc i32 %xor.i.i to i8\n %notsub.i = add i8 %conv1.i.i, -1\n %cmp.i.i = icmp sgt i8 %notsub.i, -3\n %conv3.i.i = zext i1 %cmp.i.i to i32\n %cmp4.i.i = icmp sgt i32 %xor.i.i, %conv3.i.i\n %conv1.1.i.i = trunc i32 %g to i8\n %notsub25.i = add i8 %conv1.1.i.i, -1\n %cmp.1.i.i = icmp sgt i8 %notsub25.i, -3\n %conv3.1.i.i = zext i1 %cmp.1.i.i to i32\n %cmp4.1.i.i = icmp sgt i32 %g, %conv3.1.i.i\n %notsub26.i = add i8 %conv1.1.i.i, -9\n %cmp.i17.i = icmp sgt i8 %notsub26.i, -3\n %conv3.i18.i = zext i1 %cmp.i17.i to i32\n %cmp4.i19.i = icmp sgt i32 %g, %conv3.i18.i\n %notsub27.i = add i8 %conv1.i.i, -9\n %cmp.1.i22.i = icmp sgt i8 %notsub27.i, -3\n %conv3.1.i23.i = zext i1 %cmp.1.i22.i to i32\n %cmp4.1.i24.i = icmp sgt i32 %xor.i.i, %conv3.1.i23.i\n %1 = and i1 %cmp4.i19.i, %cmp4.1.i24.i\n %2 = and i1 %cmp4.i.i, %1\n %3 = and i1 %cmp4.1.i.i, %2\n ret i1 %3\n}\n"
40
+ }
41
+ ]
42
+ }
43
+ ],
44
+ "issue": {
45
+ "title": "[SLPVectorizer] Miscompile at O3",
46
+ "body": "Reproducer: https://gist.github.com/dtcxzyw/117dc735db97658ea852d30fd896242a\r\n```console\r\n> bin/clang -O0 test.c -w -I/usr/include/csmith && ./a.out\r\nchecksum = BDCB7A78\r\n> bin/clang -O3 test.c -w -mllvm -inline-threshold=100000 -I/usr/include/csmith && ./a.out\r\nchecksum = 9198FC41\r\n```\r\n\r\nllvm version: 1193f7d6487d2d94009f8d8d27da3907136482b9\r\n",
47
+ "author": "dtcxzyw",
48
+ "labels": [
49
+ "miscompilation",
50
+ "llvm:SLPVectorizer"
51
+ ],
52
+ "comments": [
53
+ {
54
+ "author": "dtcxzyw",
55
+ "body": "Reproducer: https://alive2.llvm.org/ce/z/GCXoe9\r\n```\r\n; bin/opt -passes=slp-vectorizer test.ll -S\r\n\r\ntarget datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\r\ntarget triple = \"x86_64-unknown-linux-gnu\"\r\n\r\ndefine i1 @main(i32 %g.promoted.i.i, i16 %d.promoted.i.i) {\r\nentry:\r\n %0 = and i16 %d.promoted.i.i, 1\r\n %xor.i.i = xor i32 %g.promoted.i.i, 1\r\n %conv1.i.i = trunc i32 %xor.i.i to i8\r\n %notsub.i = add i8 %conv1.i.i, -1\r\n %cmp.i.i = icmp sgt i8 %notsub.i, -3\r\n %conv3.i.i = zext i1 %cmp.i.i to i32\r\n %cmp4.i.i = icmp sgt i32 %xor.i.i, %conv3.i.i\r\n %conv1.1.i.i = trunc i32 %g.promoted.i.i to i8\r\n %notsub25.i = add i8 %conv1.1.i.i, -1\r\n %cmp.1.i.i = icmp sgt i8 %notsub25.i, -3\r\n %conv3.1.i.i = zext i1 %cmp.1.i.i to i32\r\n %cmp4.1.i.i = icmp sgt i32 %g.promoted.i.i, %conv3.1.i.i\r\n %notsub26.i = add i8 %conv1.1.i.i, -9\r\n %cmp.i17.i = icmp sgt i8 %notsub26.i, -3\r\n %conv3.i18.i = zext i1 %cmp.i17.i to i32\r\n %cmp4.i19.i = icmp sgt i32 %g.promoted.i.i, %conv3.i18.i\r\n %notsub27.i = add i8 %conv1.i.i, -9\r\n %cmp.1.i22.i = icmp sgt i8 %notsub27.i, -3\r\n %conv3.1.i23.i = zext i1 %cmp.1.i22.i to i32\r\n %cmp4.1.i24.i = icmp sgt i32 %xor.i.i, %conv3.1.i23.i\r\n %1 = and i1 %cmp4.i19.i, %cmp4.1.i24.i\r\n %2 = and i1 %cmp4.i.i, %1\r\n %3 = and i1 %cmp4.1.i.i, %2\r\n ret i1 %3\r\n}\r\n```\r\nOutput:\r\n```\r\ndefine i1 @main(i32 %g.promoted.i.i, i16 %d.promoted.i.i) {\r\nentry:\r\n %0 = and i16 %d.promoted.i.i, 1\r\n %xor.i.i = xor i32 %g.promoted.i.i, 1\r\n %1 = trunc i32 %g.promoted.i.i to i8\r\n %2 = insertelement <2 x i8> poison, i8 %1, i32 0\r\n %3 = trunc i32 %xor.i.i to i8\r\n %4 = insertelement <2 x i8> %2, i8 %3, i32 1\r\n %5 = shufflevector <2 x i8> %4, <2 x i8> poison, <4 x i32> <i32 0, i32 1, i32 0, i32 1>\r\n %6 = add <4 x i8> %5, <i8 -9, i8 -9, i8 -1, i8 -1>\r\n %7 = icmp sgt <4 x i8> %6, <i8 -3, i8 -3, i8 -3, i8 -3>\r\n %8 = zext <4 x i1> %7 to <4 x i8>\r\n %9 = sext <2 x i8> %4 to <2 x i32>\r\n %10 = shufflevector <2 x i32> %9, <2 x i32> poison, <4 x i32> <i32 0, i32 1, i32 0, i32 1>\r\n %11 = zext <4 x i8> %8 to <4 x i32>\r\n %12 = icmp sgt <4 x i32> %10, %11\r\n %13 = call i1 @llvm.vector.reduce.and.v4i1(<4 x i1> %12)\r\n ret i1 %13\r\n}\r\n```\r\n\r\ncc @alexey-bataev "
56
+ }
57
+ ]
58
+ },
59
+ "verified": true
60
+ }
dataset/106083.json ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "106083",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/106083",
4
+ "bug_type": "crash",
5
+ "base_commit": "d075debc508898d5f365f8e909c54d6f4edada85",
6
+ "knowledge_cutoff": "2024-08-26T14:36:57Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/DFAJumpThreading"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "d4a38c8ff5c993e14c42895b51a47272fb03a857",
12
+ "components": [
13
+ "DFAJumpThreading"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": [
17
+ [
18
+ 194,
19
+ 200
20
+ ],
21
+ [
22
+ 202,
23
+ 207
24
+ ],
25
+ [
26
+ 223,
27
+ 254
28
+ ]
29
+ ]
30
+ },
31
+ "bug_location_funcname": {
32
+ "llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp": [
33
+ "unfold"
34
+ ]
35
+ }
36
+ },
37
+ "patch": "commit d4a38c8ff5c993e14c42895b51a47272fb03a857\nAuthor: Usman Nadeem <[email protected]>\nDate: Tue Sep 24 08:54:36 2024 -0700\n\n [DFAJumpThreading] Handle select unfolding when user phi is not a dir\u2026 (#109511)\n \n \u2026ect successor\n \n Previously the code assumed that the select instruction is defined in a\n block that is a direct predecessor of the block where the PHINode uses\n it. So, we were hitting an assertion when we tried to access the def\n block as an incoming block for the user phi node.\n \n This patch handles that case by using the correct end block and creating\n a new phi node that aggregates both the values of the select in that end\n block, and then using that new unfolded phi to overwrite the original\n user phi node.\n \n Fixes #106083\n \n Change-Id: Ie471994cca232318f74a6e6438efa21e561c2dc0\n\ndiff --git a/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp b/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp\nindex ef9c264482a6..0e2b5c925a6a 100644\n--- a/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp\n+++ b/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp\n@@ -194,7 +194,6 @@ void unfold(DomTreeUpdater *DTU, LoopInfo *LI, SelectInstToUnfold SIToUnfold,\n SelectInst *SI = SIToUnfold.getInst();\n PHINode *SIUse = SIToUnfold.getUse();\n BasicBlock *StartBlock = SI->getParent();\n- BasicBlock *EndBlock = SIUse->getParent();\n BranchInst *StartBlockTerm =\n dyn_cast<BranchInst>(StartBlock->getTerminator());\n \n@@ -202,6 +201,7 @@ void unfold(DomTreeUpdater *DTU, LoopInfo *LI, SelectInstToUnfold SIToUnfold,\n assert(SI->hasOneUse());\n \n if (StartBlockTerm->isUnconditional()) {\n+ BasicBlock *EndBlock = StartBlock->getUniqueSuccessor();\n // Arbitrarily choose the 'false' side for a new input value to the PHI.\n BasicBlock *NewBlock = BasicBlock::Create(\n SI->getContext(), Twine(SI->getName(), \".si.unfold.false\"),\n@@ -223,32 +223,44 @@ void unfold(DomTreeUpdater *DTU, LoopInfo *LI, SelectInstToUnfold SIToUnfold,\n NewBlock->getFirstInsertionPt());\n NewPhi->addIncoming(SIOp2, StartBlock);\n \n- if (auto *OpSi = dyn_cast<SelectInst>(SIOp1))\n- NewSIsToUnfold->push_back(SelectInstToUnfold(OpSi, SIUse));\n- if (auto *OpSi = dyn_cast<SelectInst>(SIOp2))\n- NewSIsToUnfold->push_back(SelectInstToUnfold(OpSi, NewPhi));\n-\n- // Update the phi node of SI.\n- for (unsigned Idx = 0; Idx < SIUse->getNumIncomingValues(); ++Idx) {\n- if (SIUse->getIncomingBlock(Idx) == StartBlock)\n- SIUse->setIncomingValue(Idx, SIOp1);\n+ // Update any other PHI nodes in EndBlock.\n+ for (PHINode &Phi : EndBlock->phis()) {\n+ if (SIUse == &Phi)\n+ continue;\n+ Phi.addIncoming(Phi.getIncomingValueForBlock(StartBlock), NewBlock);\n }\n- SIUse->addIncoming(NewPhi, NewBlock);\n \n- // Update any other PHI nodes in EndBlock.\n- for (auto II = EndBlock->begin(); PHINode *Phi = dyn_cast<PHINode>(II);\n- ++II) {\n- if (Phi != SIUse)\n- Phi->addIncoming(Phi->getIncomingValueForBlock(StartBlock), NewBlock);\n+ // Update the phi node of SI, which is its only use.\n+ if (EndBlock == SIUse->getParent()) {\n+ SIUse->addIncoming(NewPhi, NewBlock);\n+ SIUse->replaceUsesOfWith(SI, SIOp1);\n+ } else {\n+ PHINode *EndPhi = PHINode::Create(SIUse->getType(), pred_size(EndBlock),\n+ Twine(SI->getName(), \".si.unfold.phi\"),\n+ EndBlock->getFirstInsertionPt());\n+ for (BasicBlock *Pred : predecessors(EndBlock)) {\n+ if (Pred != StartBlock && Pred != NewBlock)\n+ EndPhi->addIncoming(EndPhi, Pred);\n+ }\n+\n+ EndPhi->addIncoming(SIOp1, StartBlock);\n+ EndPhi->addIncoming(NewPhi, NewBlock);\n+ SIUse->replaceUsesOfWith(SI, EndPhi);\n+ SIUse = EndPhi;\n }\n \n- StartBlockTerm->eraseFromParent();\n+ if (auto *OpSi = dyn_cast<SelectInst>(SIOp1))\n+ NewSIsToUnfold->push_back(SelectInstToUnfold(OpSi, SIUse));\n+ if (auto *OpSi = dyn_cast<SelectInst>(SIOp2))\n+ NewSIsToUnfold->push_back(SelectInstToUnfold(OpSi, NewPhi));\n \n // Insert the real conditional branch based on the original condition.\n+ StartBlockTerm->eraseFromParent();\n BranchInst::Create(EndBlock, NewBlock, SI->getCondition(), StartBlock);\n DTU->applyUpdates({{DominatorTree::Insert, StartBlock, EndBlock},\n {DominatorTree::Insert, StartBlock, NewBlock}});\n } else {\n+ BasicBlock *EndBlock = SIUse->getParent();\n BasicBlock *NewBlockT = BasicBlock::Create(\n SI->getContext(), Twine(SI->getName(), \".si.unfold.true\"),\n EndBlock->getParent(), EndBlock);\n",
38
+ "tests": [
39
+ {
40
+ "file": "llvm/test/Transforms/DFAJumpThreading/dfa-jump-threading-transform.ll",
41
+ "commands": [
42
+ "opt -S -passes=dfa-jump-threading %s"
43
+ ],
44
+ "tests": [
45
+ {
46
+ "test_name": "test2",
47
+ "test_body": "define i32 @test2(i32 %init) {\nentry:\n %cmp = icmp eq i32 %init, 0\n %sel = select i1 %cmp, i32 0, i32 2\n br label %loop.1\n\nloop.1: ; preds = %loop.1.backedge, %entry\n %state.1 = phi i32 [ %sel, %entry ], [ %state.1.be2, %loop.1.backedge ]\n br label %loop.2\n\nloop.2: ; preds = %loop.2.backedge, %loop.1\n %state.2 = phi i32 [ %state.1, %loop.1 ], [ %state.2.be, %loop.2.backedge ]\n br label %loop.3\n\nloop.3: ; preds = %case2, %loop.2\n %state = phi i32 [ %state.2, %loop.2 ], [ 3, %case2 ]\n switch i32 %state, label %infloop.i [\n i32 2, label %case2\n i32 3, label %case3\n i32 4, label %case4\n i32 0, label %case0\n i32 1, label %case1\n ]\n\ncase2: ; preds = %loop.3\n br i1 %cmp, label %loop.3, label %loop.1.backedge\n\ncase3: ; preds = %loop.3\n br i1 %cmp, label %loop.2.backedge, label %case4\n\ncase4: ; preds = %case3, %loop.3\n br i1 %cmp, label %loop.2.backedge, label %loop.1.backedge\n\nloop.1.backedge: ; preds = %case4, %case2\n %state.1.be = phi i32 [ 2, %case4 ], [ 4, %case2 ]\n %state.1.be2 = select i1 %cmp, i32 1, i32 %state.1.be\n br label %loop.1\n\nloop.2.backedge: ; preds = %case4, %case3\n %state.2.be = phi i32 [ 3, %case4 ], [ 0, %case3 ]\n br label %loop.2\n\ncase0: ; preds = %loop.3\n br label %exit\n\ncase1: ; preds = %loop.3\n br label %exit\n\ninfloop.i: ; preds = %infloop.i, %loop.3\n br label %infloop.i\n\nexit: ; preds = %case1, %case0\n ret i32 0\n}\n"
48
+ },
49
+ {
50
+ "test_name": "pr106083_select_dead_uses",
51
+ "test_body": "define void @pr106083_select_dead_uses(i1 %cmp1, i1 %not, ptr %p) {\nbb:\n %spec.select = select i1 %cmp1, i32 0, i32 1\n br label %.loopexit6\n\n.loopexit6: ; preds = %select.unfold, %bb\n br i1 %not, label %select.unfold, label %bb1\n\nbb1: ; preds = %.loopexit6\n %i = load i32, ptr %p, align 4\n %not2 = icmp eq i32 0, 0\n %spec.select7 = select i1 %not2, i32 %spec.select, i32 0\n br label %select.unfold\n\nselect.unfold: ; preds = %bb1, %.loopexit6\n %_2 = phi i32 [ 0, %.loopexit6 ], [ %spec.select7, %bb1 ]\n switch i32 %_2, label %bb2 [\n i32 0, label %.preheader.preheader\n i32 1, label %.loopexit6\n ]\n\n.preheader.preheader: ; preds = %select.unfold\n ret void\n\nbb2: ; preds = %select.unfold\n unreachable\n}\n"
52
+ },
53
+ {
54
+ "test_name": "test1",
55
+ "test_body": "define i32 @test1(i32 %num) {\nentry:\n br label %for.body\n\nfor.body: ; preds = %for.inc, %entry\n %count = phi i32 [ 0, %entry ], [ %inc, %for.inc ]\n %state = phi i32 [ 1, %entry ], [ %state.next, %for.inc ]\n switch i32 %state, label %for.inc [\n i32 1, label %case1\n i32 2, label %case2\n ]\n\ncase1: ; preds = %for.body\n br label %for.inc\n\ncase2: ; preds = %for.body\n %cmp = icmp eq i32 %count, 50\n %sel = select i1 %cmp, i32 1, i32 2\n br label %for.inc\n\nfor.inc: ; preds = %case2, %case1, %for.body\n %state.next = phi i32 [ %sel, %case2 ], [ 1, %for.body ], [ 2, %case1 ]\n %inc = add nsw i32 %count, 1\n %cmp.exit = icmp slt i32 %inc, %num\n br i1 %cmp.exit, label %for.body, label %for.end\n\nfor.end: ; preds = %for.inc\n ret i32 0\n}\n"
56
+ },
57
+ {
58
+ "test_name": "pr106083_invalidBBarg_fold",
59
+ "test_body": "define void @pr106083_invalidBBarg_fold(i1 %cmp1, i1 %cmp2, i1 %not, ptr %d) {\nbb:\n %sel = select i1 %cmp1, i32 0, i32 1\n br label %BB1\n\nBB1: ; preds = %BB1.backedge, %BB7, %bb\n %i = phi i16 [ 0, %BB1.backedge ], [ 0, %bb ], [ 1, %BB7 ]\n br i1 %not, label %BB7, label %BB2\n\nBB2: ; preds = %BB1\n store i16 0, ptr %d, align 2\n %spec.select = select i1 %cmp2, i32 %sel, i32 0\n br label %BB7\n\nBB7: ; preds = %BB2, %BB1\n %d.promoted4 = phi i16 [ 0, %BB1 ], [ 1, %BB2 ]\n %_3 = phi i32 [ 0, %BB1 ], [ %spec.select, %BB2 ]\n switch i32 %_3, label %BB1.backedge [\n i32 0, label %BB1\n i32 1, label %BB8\n ]\n\nBB1.backedge: ; preds = %BB7\n br label %BB1\n\nBB8: ; preds = %BB7\n ret void\n}\n"
60
+ },
61
+ {
62
+ "test_name": "pr78059_bitwidth",
63
+ "test_body": "define void @pr78059_bitwidth() {\n.split.preheader:\n br label %.split\n\n.split: ; preds = %.split, %.split.preheader\n %0 = phi i128 [ 0, %.split.preheader ], [ -1, %.split ]\n switch i128 %0, label %end [\n i128 -1, label %end\n i128 0, label %.split\n ]\n\nend: ; preds = %.split, %.split\n ret void\n}\n"
64
+ }
65
+ ]
66
+ }
67
+ ],
68
+ "issue": {
69
+ "title": "[DFAJumpThreading] crash since b167ada",
70
+ "body": "Seeing many assertions that go away if I revert b167ada \"[DFAJumpThreading] Rewrite the way paths are enumerated (#96127)\".\r\n\r\n```\r\nclang-20 -cc1 -triple s390x-unknown-linux-gnu -target-cpu z15 -O3 -w -mllvm -enable-dfa-jump-thread -o /dev/null -emit-llvm -x ir tc_dfa-jt_invalidbbarg.ll\r\n...\r\n10 0x000002aa0a73e544 (anonymous namespace)::DFAJumpThreading::run\r\n...\r\n```\r\n\r\n```\r\nclang-20 -cc1 -triple s390x-unknown-linux-gnu -target-cpu z16 -O3 -w -mllvm -enable-dfa-jump-thread -o /dev/null -emit-llvm -x ir tc_select_mustbedeadnow.ll\r\n...\r\n#10 0x000002aa1b0c0968 llvm::DFAJumpThreadingPass::run\r\n...\r\n\r\n```\r\n[tcs_dfa-jt.tar.gz](https://github.com/user-attachments/files/16750050/tcs_dfa-jt.tar.gz)\r\n",
71
+ "author": "JonPsson1",
72
+ "labels": [
73
+ "crash",
74
+ "llvm:transforms"
75
+ ],
76
+ "comments": [
77
+ {
78
+ "author": "mikaelholmen",
79
+ "body": "Perhaps the same assertion I reported here:\r\n https://github.com/llvm/llvm-project/pull/96127#issuecomment-2303862037\r\n?"
80
+ },
81
+ {
82
+ "author": "JonPsson1",
83
+ "body": "> Perhaps the same assertion I reported here: [#96127 (comment)](https://github.com/llvm/llvm-project/pull/96127#issuecomment-2303862037) ?\r\n\r\nYes, same assertion, and in addition my second test case above triggered another assertion."
84
+ }
85
+ ]
86
+ },
87
+ "verified": true
88
+ }
dataset/106239.json ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "106239",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/106239",
4
+ "bug_type": "crash",
5
+ "base_commit": "15405b32b1cdbefab9ce1b1f301a51ae25404037",
6
+ "knowledge_cutoff": "2024-08-27T15:51:29Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/IndVarSimplify"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "c9a5e1b665dbba898e9981fd7d48881947e6560e",
12
+ "components": [
13
+ "SimplifyIndVar"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": [
17
+ [
18
+ 1928,
19
+ 1945
20
+ ]
21
+ ]
22
+ },
23
+ "bug_location_funcname": {
24
+ "llvm/lib/Transforms/Utils/SimplifyIndVar.cpp": [
25
+ "WidenIV::widenIVUse"
26
+ ]
27
+ }
28
+ },
29
+ "patch": "commit c9a5e1b665dbba898e9981fd7d48881947e6560e\nAuthor: Nikita Popov <[email protected]>\nDate: Wed Aug 28 12:54:14 2024 +0200\n\n [IndVars] Check if WideInc available before trying to use it\n \n WideInc/WideIncExpr can be null. Previously this worked out\n because the comparison with WideIncExpr would fail. Now we have\n accesses to WideInc prior to that. Avoid the issue with an\n explicit check.\n \n Fixes https://github.com/llvm/llvm-project/issues/106239.\n\ndiff --git a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp\nindex 8e3a14bb4f6d..a950a4f57ef4 100644\n--- a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp\n+++ b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp\n@@ -1928,18 +1928,24 @@ Instruction *WidenIV::widenIVUse(WidenIV::NarrowIVDefUse DU,\n if (!WideAddRec.first)\n return nullptr;\n \n- // Reuse the IV increment that SCEVExpander created. Recompute flags, unless\n- // the flags for both increments agree and it is safe to use the ones from\n- // the original inc. In that case, the new use of the wide increment won't\n- // be more poisonous.\n- bool NeedToRecomputeFlags =\n- !SCEVExpander::canReuseFlagsFromOriginalIVInc(OrigPhi, WidePhi,\n- DU.NarrowUse, WideInc) ||\n- DU.NarrowUse->hasNoUnsignedWrap() != WideInc->hasNoUnsignedWrap() ||\n- DU.NarrowUse->hasNoSignedWrap() != WideInc->hasNoSignedWrap();\n+ auto CanUseWideInc = [&]() {\n+ if (!WideInc)\n+ return false;\n+ // Reuse the IV increment that SCEVExpander created. Recompute flags,\n+ // unless the flags for both increments agree and it is safe to use the\n+ // ones from the original inc. In that case, the new use of the wide\n+ // increment won't be more poisonous.\n+ bool NeedToRecomputeFlags =\n+ !SCEVExpander::canReuseFlagsFromOriginalIVInc(\n+ OrigPhi, WidePhi, DU.NarrowUse, WideInc) ||\n+ DU.NarrowUse->hasNoUnsignedWrap() != WideInc->hasNoUnsignedWrap() ||\n+ DU.NarrowUse->hasNoSignedWrap() != WideInc->hasNoSignedWrap();\n+ return WideAddRec.first == WideIncExpr &&\n+ Rewriter.hoistIVInc(WideInc, DU.NarrowUse, NeedToRecomputeFlags);\n+ };\n+\n Instruction *WideUse = nullptr;\n- if (WideAddRec.first == WideIncExpr &&\n- Rewriter.hoistIVInc(WideInc, DU.NarrowUse, NeedToRecomputeFlags))\n+ if (CanUseWideInc())\n WideUse = WideInc;\n else {\n WideUse = cloneIVUser(DU, WideAddRec.first);\n",
30
+ "tests": [
31
+ {
32
+ "file": "llvm/test/Transforms/IndVarSimplify/pr106239.ll",
33
+ "commands": [
34
+ "opt -S -passes=indvars < %s"
35
+ ],
36
+ "tests": [
37
+ {
38
+ "test_name": "m",
39
+ "test_body": "target datalayout = \"n8:16:32:64\"\n\ndefine i32 @m() {\nentry:\n %div.i4 = sdiv i32 1, 0\n br label %for.body.i6\n\nfor.body.i6: ; preds = %if.end.i, %entry\n %add57.i = phi i32 [ %add.i7, %if.end.i ], [ 0, %entry ]\n br i1 true, label %i.exit, label %if.end.i\n\nif.end.i: ; preds = %for.body.i6\n %add.i7 = add i32 %add57.i, %div.i4\n %conv.i = zext i32 %add57.i to i64\n store i64 %conv.i, ptr null, align 8\n br label %for.body.i6\n\ni.exit: ; preds = %for.body.i6\n ret i32 0\n}\n"
40
+ }
41
+ ]
42
+ }
43
+ ],
44
+ "issue": {
45
+ "title": "[clang] Crash with O2 optimization flag",
46
+ "body": "I compiled this code with -O2 flag and it crashed. The code is:\r\n\r\n```c\r\n#include <stdint.h>\r\nlong a, c;\r\nunsigned d;\r\nint32_t g;\r\nuint8_t h[];\r\nlong b(long p1, long k) {\r\n long e = k;\r\n int b = 0;\r\n while (e) {\r\n e /= 10;\r\n b++;\r\n }\r\n for (int f = 0; f < b; f++)\r\n p1 *= 10;\r\n a = p1 + k;\r\n return a;\r\n}\r\nlong i(int p1, int, int l) {\r\n int j = l / p1;\r\n for (int f = 0; f < p1; f++) {\r\n if (d > l)\r\n break;\r\n c = d += j;\r\n }\r\n}\r\nuint32_t m() {\r\n for (g = 8; b(35, 46) - 3546 + g >= 0; g--)\r\n ;\r\n h[i(g + 1, 0, -4294967221)];\r\n}\r\n```\r\n\r\nThe crash is: clang: /root/llvm-project/llvm/include/llvm/Support/Casting.h:662: decltype(auto) llvm::dyn_cast(From*) [with To = llvm::BinaryOperator; From = llvm::Instruction]: Assertion `detail::isPresent(Val) && \"dyn_cast on a non-existent value\"' failed.\r\n\r\n\r\nThe details can be found here: https://godbolt.org/z/37WsGxMcv",
47
+ "author": "cardigan1008",
48
+ "labels": [
49
+ "regression",
50
+ "release:backport",
51
+ "confirmed",
52
+ "crash",
53
+ "llvm:transforms"
54
+ ],
55
+ "comments": [
56
+ {
57
+ "author": "shafik",
58
+ "body": "Looks like a regression, does not crash in clang-18: https://godbolt.org/z/1zYqs3sbz"
59
+ },
60
+ {
61
+ "author": "dtcxzyw",
62
+ "body": "Reproducer: https://godbolt.org/z/bbdhPxx5E\r\n\r\n```\r\n; bin/opt -passes=indvars reduced.ll -S\r\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\r\n\r\ndefine i32 @m() {\r\nentry:\r\n %div.i4 = sdiv i32 1, 0\r\n br label %for.body.i6\r\n\r\nfor.body.i6: ; preds = %if.end.i, %entry\r\n %add57.i = phi i32 [ %add.i7, %if.end.i ], [ 0, %entry ]\r\n br i1 true, label %i.exit, label %if.end.i\r\n\r\nif.end.i: ; preds = %for.body.i6\r\n %add.i7 = add i32 %add57.i, %div.i4\r\n %conv.i = zext i32 %add57.i to i64\r\n store i64 %conv.i, ptr null, align 8\r\n br label %for.body.i6\r\n\r\ni.exit: ; preds = %for.body.i6\r\n ret i32 0\r\n}\r\n```\r\ncc @nikic"
63
+ },
64
+ {
65
+ "author": "DimitryAndric",
66
+ "body": "This regressed with `llvmorg-19-init-02822-g`4db93e5d564 (\"[IndVars] Recompute flags if needed in widenIVUse of IV increment. (#82352)\") by @fhahn."
67
+ }
68
+ ]
69
+ },
70
+ "verified": true
71
+ }
dataset/106248.json ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "106248",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/106248",
4
+ "bug_type": "crash",
5
+ "base_commit": "616f7d3d4f6d9bea6f776e357c938847e522a681",
6
+ "knowledge_cutoff": "2024-08-27T17:02:16Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/LoopVectorize"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "0a272d3a1703415abca42dc2e2cc2b57cb30734e",
12
+ "components": [
13
+ "LoopVectorize"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
17
+ [
18
+ 6529,
19
+ 6534
20
+ ]
21
+ ]
22
+ },
23
+ "bug_location_funcname": {
24
+ "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
25
+ "LoopVectorizationCostModel::getInstructionCost"
26
+ ]
27
+ }
28
+ },
29
+ "patch": "commit 0a272d3a1703415abca42dc2e2cc2b57cb30734e\nAuthor: Florian Hahn <[email protected]>\nDate: Thu Aug 29 12:08:27 2024 +0100\n\n [LV] Use SCEV to analyze second operand for cost query.\n \n Improve operand analysis using SCEV for cost purposes. This fixes a\n divergence between legacy and VPlan-based cost-modeling after\n 533e6bbd0d34.\n \n Fixes https://github.com/llvm/llvm-project/issues/106248.\n\ndiff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\nindex 56f51e14a6eb..4cc75e2e7546 100644\n--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\n+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\n@@ -6529,6 +6529,10 @@ LoopVectorizationCostModel::getInstructionCost(Instruction *I,\n // Certain instructions can be cheaper to vectorize if they have a constant\n // second vector operand. One example of this are shifts on x86.\n Value *Op2 = I->getOperand(1);\n+ if (!isa<Constant>(Op2) && PSE.getSE()->isSCEVable(Op2->getType()) &&\n+ isa<SCEVConstant>(PSE.getSCEV(Op2))) {\n+ Op2 = cast<SCEVConstant>(PSE.getSCEV(Op2))->getValue();\n+ }\n auto Op2Info = TTI.getOperandInfo(Op2);\n if (Op2Info.Kind == TargetTransformInfo::OK_AnyValue &&\n Legal->isInvariant(Op2))\n",
30
+ "tests": [
31
+ {
32
+ "file": "llvm/test/Transforms/LoopVectorize/X86/cost-constant-known-via-scev.ll",
33
+ "commands": [
34
+ "opt -p loop-vectorize -S %s"
35
+ ],
36
+ "tests": [
37
+ {
38
+ "test_name": "test_foldable_live_in_via_scev",
39
+ "test_body": "target datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine i64 @test_foldable_live_in_via_scev() {\nentry:\n %conv = zext i16 -6 to i64\n %add = add nsw i64 %conv, -65528\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i32 [ 1, %entry ], [ %iv.next, %loop ]\n %red = phi i64 [ 1, %entry ], [ %mul, %loop ]\n %mul = mul nsw i64 %red, %add\n %iv.next = add nsw i32 %iv, 1\n %ec = icmp eq i32 %iv.next, 100\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n %ret = phi i64 [ %mul, %loop ]\n ret i64 %ret\n}\n"
40
+ }
41
+ ]
42
+ }
43
+ ],
44
+ "issue": {
45
+ "title": "[clang] Assertion failed in Vectorize",
46
+ "body": "In #105722 , we resolved the assertion failure in vectorization. However, I met this crash again with the following case:\r\n\r\n```c\r\n#include <stdint.h>\r\nint a;\r\nlong b;\r\nstruct e {\r\n uint16_t f;\r\n uint64_t g;\r\n int32_t h\r\n} static i = {65530};\r\nvoid c(int d) {\r\n for (; a; a++)\r\n b *= d;\r\n}\r\nuint32_t j(struct e, uint16_t);\r\nuint64_t k() { j(i, 0); }\r\nuint32_t j(struct e, uint16_t) { c(i.f - 65528); }\r\n```\r\nI compiled it with -O2 flag and it crashed. But when I compiled with -O1/-O0, it worked.\r\n\r\nThe crash is: clang++: /root/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:7359: llvm::VectorizationFactor llvm::LoopVectorizationPlanner::computeBestVF(): Assertion `(BestFactor.Width == LegacyVF.Width || planContainsAdditionalSimplifications(getPlanFor(BestFactor.Width), BestFactor.Width, CostCtx, OrigLoop, CM)) && \" VPlan cost model and legacy cost model disagreed\"' failed.\r\n\r\nThe details can be found here: https://godbolt.org/z/8x48xsKs6",
47
+ "author": "cardigan1008",
48
+ "labels": [
49
+ "vectorizers",
50
+ "crash"
51
+ ],
52
+ "comments": [
53
+ {
54
+ "author": "fhahn",
55
+ "body": "Thanks for the report @cardigan1008, should be fixed now"
56
+ }
57
+ ]
58
+ },
59
+ "verified": true
60
+ }
dataset/106257.json ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "106257",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/106257",
4
+ "bug_type": "crash",
5
+ "base_commit": "a4989cd603b8e8185e35e3c2b7b48b422d4898be",
6
+ "knowledge_cutoff": "2024-08-27T17:46:38Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/LoopVectorize"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "4b84288f00f3e112045bbc4be4f1539147574ead",
12
+ "components": [
13
+ "LoopVectorize"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
17
+ [
18
+ 8648,
19
+ 8653
20
+ ]
21
+ ]
22
+ },
23
+ "bug_location_funcname": {
24
+ "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
25
+ "addUsersInExitBlock"
26
+ ]
27
+ }
28
+ },
29
+ "patch": "commit 4b84288f00f3e112045bbc4be4f1539147574ead\nAuthor: Florian Hahn <[email protected]>\nDate: Wed Aug 28 19:12:04 2024 +0100\n\n [VPlan] Pass live-ins used as exit values straight to live-out.\n \n Live-ins that are used as exit values don't need to be extracted, they\n can be passed through directly. This fixes a crash when trying to\n extract from a live-in.\n \n Fixes https://github.com/llvm/llvm-project/issues/106257.\n\ndiff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\nindex 4c68a95b9c26..cb104c4ed2d0 100644\n--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\n+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\n@@ -8648,6 +8648,11 @@ addUsersInExitBlock(VPlan &Plan,\n \n // Introduce VPUsers modeling the exit values.\n for (const auto &[ExitPhi, V] : ExitingValuesToFix) {\n+ // Pass live-in values used by exit phis directly through to the live-out.\n+ if (V->isLiveIn()) {\n+ Plan.addLiveOut(ExitPhi, V);\n+ continue;\n+ }\n VPValue *Ext = B.createNaryOp(\n VPInstruction::ExtractFromEnd,\n {V, Plan.getOrAddLiveIn(ConstantInt::get(\n",
30
+ "tests": [
31
+ {
32
+ "file": "llvm/test/Transforms/LoopVectorize/extract-from-end-vector-constant.ll",
33
+ "commands": [
34
+ "opt -p loop-vectorize -force-vector-width=4 -S %s"
35
+ ],
36
+ "tests": [
37
+ {
38
+ "test_name": "exit_value_vector_live_in",
39
+ "test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\n\ndefine <2 x i64> @exit_value_vector_live_in(ptr %dst) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next.1, %loop ]\n %gep = getelementptr i16, ptr %dst, i64 %iv\n store i16 0, ptr %gep, align 2\n %iv.next.1 = add i64 %iv, 1\n %ec = icmp ult i64 %iv, 1000\n br i1 %ec, label %loop, label %exit\n\nexit: ; preds = %loop\n %res = phi <2 x i64> [ zeroinitializer, %loop ]\n ret <2 x i64> %res\n}\n"
40
+ },
41
+ {
42
+ "test_name": "exit_value_scalar_live_in",
43
+ "test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\n\ndefine i64 @exit_value_scalar_live_in(ptr %dst, i64 %in) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next.1, %loop ]\n %gep = getelementptr i16, ptr %dst, i64 %iv\n store i16 0, ptr %gep, align 2\n %iv.next.1 = add i64 %iv, 1\n %ec = icmp ult i64 %iv, 1000\n br i1 %ec, label %loop, label %exit\n\nexit: ; preds = %loop\n %res = phi i64 [ %in, %loop ]\n ret i64 %res\n}\n"
44
+ }
45
+ ]
46
+ }
47
+ ],
48
+ "issue": {
49
+ "title": "[LoopVectorize] Assertion `(GeneratedValue->getType()->isVectorTy() == !GeneratesPerFirstLaneOnly || State.VF.isScalar()) && \"scalar value but not only first lane defined\"' failed.",
50
+ "body": "Testcase:\r\n```llvm ir\r\n; ModuleID = 'reduced.bc'\r\ntarget datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\r\ntarget triple = \"riscv64-unknown-linux-gnu\"\r\n\r\ndefine fastcc void @g() #0 {\r\nfor.cond1.preheader.us.preheader:\r\n br label %for.cond.cleanup20.us.us.1\r\n\r\nfor.cond.cleanup20.us.us.1: ; preds = %for.cond.cleanup20.us.us.1, %for.cond1.preheader.us.preheader\r\n %indvars.iv.1 = phi i64 [ 0, %for.cond1.preheader.us.preheader ], [ %indvars.iv.next.1, %for.cond.cleanup20.us.us.1 ]\r\n %arrayidx.us.us.1 = getelementptr [0 x i16], ptr null, i64 0, i64 %indvars.iv.1\r\n store i16 0, ptr %arrayidx.us.us.1, align 2\r\n %indvars.iv.next.1 = add i64 %indvars.iv.1, 1\r\n %cmp12.us.us.1 = icmp ult i64 %indvars.iv.1, 1\r\n br i1 %cmp12.us.us.1, label %for.cond.cleanup20.us.us.1, label %for.cond.cleanup14.us.us.1\r\n\r\nfor.cond.cleanup14.us.us.1: ; preds = %for.cond.cleanup20.us.us.1\r\n %.lcssa.1 = phi <2 x i64> [ zeroinitializer, %for.cond.cleanup20.us.us.1 ]\r\n ret void\r\n}\r\n\r\nattributes #0 = { \"target-features\"=\"+64bit,+a,+c,+d,+f,+m,+relax,+v,+zicsr,+zifencei,+zmmul,+zve32f,+zve32x,+zve64d,+zve64f,+zve64x,+zvl128b,+zvl32b,+zvl64b,-b,-e,-experimental-smctr,-experimental-smmpm,-experimental-smnpm,-experimental-ssctr,-experimental-ssnpm,-experimental-sspm,-experimental-supm,-experimental-zacas,-experimental-zalasr,-experimental-zicfilp,-experimental-zicfiss,-experimental-zvbc32e,-experimental-zvkgs,-h,-shcounterenw,-shgatpa,-shtvala,-shvsatpa,-shvstvala,-shvstvecd,-smaia,-smcdeleg,-smcsrind,-smepmp,-smstateen,-ssaia,-ssccfg,-ssccptr,-sscofpmf,-sscounterenw,-sscsrind,-ssqosid,-ssstateen,-ssstrict,-sstc,-sstvala,-sstvecd,-ssu64xl,-svade,-svadu,-svbare,-svinval,-svnapot,-svpbmt,-xcvalu,-xcvbi,-xcvbitmanip,-xcvelw,-xcvmac,-xcvmem,-xcvsimd,-xsfcease,-xsfvcp,-xsfvfnrclipxfqf,-xsfvfwmaccqqq,-xsfvqmaccdod,-xsfvqmaccqoq,-xsifivecdiscarddlone,-xsifivecflushdlone,-xtheadba,-xtheadbb,-xtheadbs,-xtheadcmo,-xtheadcondmov,-xtheadfmemidx,-xtheadmac,-xtheadmemidx,-xtheadmempair,-xtheadsync,-xtheadvdot,-xventanacondops,-xwchc,-za128rs,-za64rs,-zaamo,-zabha,-zalrsc,-zama16b,-zawrs,-zba,-zbb,-zbc,-zbkb,-zbkc,-zbkx,-zbs,-zca,-zcb,-zcd,-zce,-zcf,-zcmop,-zcmp,-zcmt,-zdinx,-zfa,-zfbfmin,-zfh,-zfhmin,-zfinx,-zhinx,-zhinxmin,-zic64b,-zicbom,-zicbop,-zicboz,-ziccamoa,-ziccif,-zicclsm,-ziccrse,-zicntr,-zicond,-zihintntl,-zihintpause,-zihpm,-zimop,-zk,-zkn,-zknd,-zkne,-zknh,-zkr,-zks,-zksed,-zksh,-zkt,-ztso,-zvbb,-zvbc,-zvfbfmin,-zvfbfwma,-zvfh,-zvfhmin,-zvkb,-zvkg,-zvkn,-zvknc,-zvkned,-zvkng,-zvknha,-zvknhb,-zvks,-zvksc,-zvksed,-zvksg,-zvksh,-zvkt,-zvl1024b,-zvl16384b,-zvl2048b,-zvl256b,-zvl32768b,-zvl4096b,-zvl512b,-zvl65536b,-zvl8192b\" }\r\n```\r\nhttps://godbolt.org/z/aoe8vdc1f\r\n\r\nCommand/backtrace:\r\n```\r\n> /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt -passes=loop-vectorize -S reduced.ll\r\nopt: /scratch/tc-testing/tc-compiler-fuzz-trunk/llvm/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp:732: virtual void llvm::VPInstruction::execute(llvm::VPTransformState&): Assertion `(GeneratedValue->getType()->isVectorTy() == !GeneratesPerFirstLaneOnly || State.VF.isScalar()) && \"scalar value but not only first lane defined\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0. Program arguments: /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt -passes=loop-vectorize -S reduced.ll\r\n1. Running pass \"function(loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>)\" on module \"reduced.ll\"\r\n2. Running pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"g\"\r\n #0 0x0000644a7eb61500 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x300e500)\r\n #1 0x0000644a7eb5e91f llvm::sys::RunSignalHandlers() (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x300b91f)\r\n #2 0x0000644a7eb5ea75 SignalHandler(int) Signals.cpp:0:0\r\n #3 0x0000790e6c842520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #4 0x0000790e6c8969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\r\n #5 0x0000790e6c8969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10\r\n #6 0x0000790e6c8969fc pthread_kill ./nptl/pthread_kill.c:89:10\r\n #7 0x0000790e6c842476 gsignal ./signal/../sysdeps/posix/raise.c:27:6\r\n #8 0x0000790e6c8287f3 abort ./stdlib/abort.c:81:7\r\n #9 0x0000790e6c82871b _nl_load_domain ./intl/loadmsgcat.c:1177:9\r\n#10 0x0000790e6c839e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n#11 0x0000644a7dc8e57a llvm::VPInstruction::execute(llvm::VPTransformState&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x213b57a)\r\n#12 0x0000644a7dc4f617 llvm::VPBasicBlock::executeRecipes(llvm::VPTransformState*, llvm::BasicBlock*) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x20fc617)\r\n#13 0x0000644a7dc4f910 llvm::VPIRBasicBlock::execute(llvm::VPTransformState*) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x20fc910)\r\n#14 0x0000644a7dc51c2d llvm::VPlan::execute(llvm::VPTransformState*) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x20fec2d)\r\n#15 0x0000644a7db37af9 llvm::LoopVectorizationPlanner::executePlan(llvm::ElementCount, unsigned int, llvm::VPlan&, llvm::InnerLoopVectorizer&, llvm::DominatorTree*, bool, llvm::DenseMap<llvm::SCEV const*, llvm::Value*, llvm::DenseMapInfo<llvm::SCEV const*, void>, llvm::detail::DenseMapPair<llvm::SCEV const*, llvm::Value*>> const*) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1fe4af9)\r\n#16 0x0000644a7db4afce llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1ff7fce)\r\n#17 0x0000644a7db4d101 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1ffa101)\r\n#18 0x0000644a7db4d777 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1ffa777)\r\n#19 0x0000644a7c9b0a46 llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xe5da46)\r\n#20 0x0000644a7e96c95f llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2e1995f)\r\n#21 0x0000644a7c9b3bd6 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xe60bd6)\r\n#22 0x0000644a7e96b6db llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2e186db)\r\n#23 0x0000644a7c9afe76 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xe5ce76)\r\n#24 0x0000644a7e96971d llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2e1671d)\r\n#25 0x0000644a7c1d9e36 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x686e36)\r\n#26 0x0000644a7c1cbbc1 optMain (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x678bc1)\r\n#27 0x0000790e6c829d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16\r\n#28 0x0000790e6c829e40 call_init ./csu/../csu/libc-start.c:128:20\r\n#29 0x0000790e6c829e40 __libc_start_main ./csu/../csu/libc-start.c:379:5\r\n#30 0x0000644a7c1c1f75 _start (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x66ef75)\r\nzsh: IOT instruction (core dumped) /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt\r\n```\r\n\r\nFound via fuzzer",
51
+ "author": "patrick-rivos",
52
+ "labels": [
53
+ "vectorizers",
54
+ "crash"
55
+ ],
56
+ "comments": []
57
+ },
58
+ "verified": true
59
+ }
dataset/106417.json ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "106417",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/106417",
4
+ "bug_type": "crash",
5
+ "base_commit": "66927fb95abef9327b453d7213c5df7d641269be",
6
+ "knowledge_cutoff": "2024-08-28T16:21:38Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/LoopVectorize"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "c4906588ce47de33d59bcd95f3e82ce2c3e61c23",
12
+ "components": [
13
+ "LoopVectorize"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
17
+ [
18
+ 7113,
19
+ 7119
20
+ ],
21
+ [
22
+ 7121,
23
+ 7126
24
+ ]
25
+ ]
26
+ },
27
+ "bug_location_funcname": {
28
+ "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
29
+ "LoopVectorizationPlanner::precomputeCosts"
30
+ ]
31
+ }
32
+ },
33
+ "patch": "commit c4906588ce47de33d59bcd95f3e82ce2c3e61c23\nAuthor: Florian Hahn <[email protected]>\nDate: Thu Aug 29 21:19:59 2024 +0100\n\n [VPlan] Use skipCostComputation when pre-computing induction costs.\n \n This ensures we skip any instructions identified to be ignored by the\n legacy cost model as well. Fixes a divergence between legacy and\n VPlan-based cost model.\n \n Fixes https://github.com/llvm/llvm-project/issues/106417.\n\ndiff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\nindex 4cc75e2e7546..6babfd1eee91 100644\n--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\n+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\n@@ -7113,7 +7113,7 @@ LoopVectorizationPlanner::precomputeCosts(VPlan &Plan, ElementCount VF,\n IVInsts.push_back(CI);\n }\n for (Instruction *IVInst : IVInsts) {\n- if (!CostCtx.SkipCostComputation.insert(IVInst).second)\n+ if (CostCtx.skipCostComputation(IVInst, VF.isVector()))\n continue;\n InstructionCost InductionCost = CostCtx.getLegacyCost(IVInst, VF);\n LLVM_DEBUG({\n@@ -7121,6 +7121,7 @@ LoopVectorizationPlanner::precomputeCosts(VPlan &Plan, ElementCount VF,\n << \": induction instruction \" << *IVInst << \"\\n\";\n });\n Cost += InductionCost;\n+ CostCtx.SkipCostComputation.insert(IVInst);\n }\n }\n \n",
34
+ "tests": [
35
+ {
36
+ "file": "llvm/test/Transforms/LoopVectorize/RISCV/induction-costs.ll",
37
+ "commands": [
38
+ "opt -p loop-vectorize -S %s"
39
+ ],
40
+ "tests": [
41
+ {
42
+ "test_name": "skip_free_iv_truncate",
43
+ "test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\ndefine void @skip_free_iv_truncate(i16 %x, ptr %A) #0 {\nentry:\n %x.i32 = sext i16 %x to i32\n %x.i64 = sext i16 %x to i64\n %invariant.gep = getelementptr i8, ptr %A, i64 -8\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ %x.i64, %entry ], [ %iv.next, %loop ]\n %iv.conv = phi i32 [ %x.i32, %entry ], [ %3, %loop ]\n %gep.i64 = getelementptr i64, ptr %A, i64 %iv\n %0 = load i64, ptr %gep.i64, align 8\n %1 = sext i32 %iv.conv to i64\n %gep.conv = getelementptr i64, ptr %invariant.gep, i64 %1\n %2 = load i64, ptr %gep.conv, align 8\n %gep.i16 = getelementptr i16, ptr %A, i64 %iv\n store i16 0, ptr %gep.i16, align 2\n %iv.next = add i64 %iv, 3\n %3 = trunc i64 %iv.next to i32\n %c = icmp slt i64 %iv, 99\n br i1 %c, label %loop, label %exit\n\nexit: ; preds = %loop\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+64bit,+v,+zvl256b\" }\n"
44
+ }
45
+ ]
46
+ }
47
+ ],
48
+ "issue": {
49
+ "title": "[VPlan] Assertion \" VPlan cost model and legacy cost model disagreed\"' failed.",
50
+ "body": "Tested using 190449a5d2a9ddfc2180dce11714a4443f0f29f0\r\n\r\nTestcase:\r\n```c\r\nchar a;\r\nextern short b[][6][6];\r\nshort c;\r\nlong d;\r\nlong *e, *f;\r\nvoid g(char h[][6]) {\r\n for (short i = d + 9; i < 4; i += 3) {\r\n a = ({ f[i]; }) < f[i - 1];\r\n for (int j = c; j; j = ({ h[5][i + 2]; }) ? e[i - 1] : 0)\r\n ;\r\n b[i][i][i] = 0;\r\n }\r\n}\r\n```\r\nhttps://godbolt.org/z/EGdEPbKad\r\n\r\nIR testcase:\r\n```llvm ir\r\n; ModuleID = 'reduced.bc'\r\ntarget datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\r\ntarget triple = \"riscv64-unknown-linux-gnu\"\r\n\r\ndefine void @g(i16 %0, i64 %indvars.iv52) #0 {\r\nentry:\r\n %conv146 = sext i16 %0 to i32\r\n %1 = sext i16 %0 to i64\r\n %invariant.gep = getelementptr i8, ptr null, i64 -8\r\n br label %for.body.us\r\n\r\nfor.body.us: ; preds = %for.body.us, %entry\r\n %indvars.iv521 = phi i64 [ %1, %entry ], [ %indvars.iv.next53, %for.body.us ]\r\n %conv149.us = phi i32 [ %conv146, %entry ], [ %5, %for.body.us ]\r\n %arrayidx.us = getelementptr i64, ptr null, i64 %indvars.iv521\r\n %2 = load i64, ptr %arrayidx.us, align 8\r\n %3 = sext i32 %conv149.us to i64\r\n %gep = getelementptr i64, ptr %invariant.gep, i64 %3\r\n %4 = load i64, ptr %gep, align 8\r\n %arrayidx31.us = getelementptr [0 x [6 x [6 x i16]]], ptr null, i64 0, i64 %indvars.iv521, i64 %indvars.iv52, i64 %indvars.iv52\r\n store i16 0, ptr %arrayidx31.us, align 2\r\n %indvars.iv.next53 = add i64 %indvars.iv521, 3\r\n %5 = trunc i64 %indvars.iv.next53 to i32\r\n %cmp.us = icmp slt i64 %indvars.iv521, 0\r\n br i1 %cmp.us, label %for.body.us, label %for.cond.for.cond.cleanup_crit_edge.split.us\r\n\r\nfor.cond.for.cond.cleanup_crit_edge.split.us: ; preds = %for.body.us\r\n ret void\r\n}\r\n\r\nattributes #0 = { \"target-features\"=\"+64bit,+a,+c,+d,+f,+m,+relax,+v,+zicsr,+zifencei,+zmmul,+zve32f,+zve32x,+zve64d,+zve64f,+zve64x,+zvl128b,+zvl256b,+zvl32b,+zvl64b,-b,-e,-experimental-smctr,-experimental-smmpm,-experimental-smnpm,-experimental-ssctr,-experimental-ssnpm,-experimental-sspm,-experimental-supm,-experimental-zacas,-experimental-zalasr,-experimental-zicfilp,-experimental-zicfiss,-experimental-zvbc32e,-experimental-zvkgs,-h,-shcounterenw,-shgatpa,-shtvala,-shvsatpa,-shvstvala,-shvstvecd,-smaia,-smcdeleg,-smcsrind,-smepmp,-smstateen,-ssaia,-ssccfg,-ssccptr,-sscofpmf,-sscounterenw,-sscsrind,-ssqosid,-ssstateen,-ssstrict,-sstc,-sstvala,-sstvecd,-ssu64xl,-svade,-svadu,-svbare,-svinval,-svnapot,-svpbmt,-xcvalu,-xcvbi,-xcvbitmanip,-xcvelw,-xcvmac,-xcvmem,-xcvsimd,-xsfcease,-xsfvcp,-xsfvfnrclipxfqf,-xsfvfwmaccqqq,-xsfvqmaccdod,-xsfvqmaccqoq,-xsifivecdiscarddlone,-xsifivecflushdlone,-xtheadba,-xtheadbb,-xtheadbs,-xtheadcmo,-xtheadcondmov,-xtheadfmemidx,-xtheadmac,-xtheadmemidx,-xtheadmempair,-xtheadsync,-xtheadvdot,-xventanacondops,-xwchc,-za128rs,-za64rs,-zaamo,-zabha,-zalrsc,-zama16b,-zawrs,-zba,-zbb,-zbc,-zbkb,-zbkc,-zbkx,-zbs,-zca,-zcb,-zcd,-zce,-zcf,-zcmop,-zcmp,-zcmt,-zdinx,-zfa,-zfbfmin,-zfh,-zfhmin,-zfinx,-zhinx,-zhinxmin,-zic64b,-zicbom,-zicbop,-zicboz,-ziccamoa,-ziccif,-zicclsm,-ziccrse,-zicntr,-zicond,-zihintntl,-zihintpause,-zihpm,-zimop,-zk,-zkn,-zknd,-zkne,-zknh,-zkr,-zks,-zksed,-zksh,-zkt,-ztso,-zvbb,-zvbc,-zvfbfmin,-zvfbfwma,-zvfh,-zvfhmin,-zvkb,-zvkg,-zvkn,-zvknc,-zvkned,-zvkng,-zvknha,-zvknhb,-zvks,-zvksc,-zvksed,-zvksg,-zvksh,-zvkt,-zvl1024b,-zvl16384b,-zvl2048b,-zvl32768b,-zvl4096b,-zvl512b,-zvl65536b,-zvl8192b\" }\r\n```\r\n\r\nCommand/backtrace:\r\n```\r\n> /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt -passes=loop-vectorize -S reduced.ll\r\nopt: /scratch/tc-testing/tc-compiler-fuzz-trunk/llvm/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:7359: llvm::VectorizationFactor llvm::LoopVectorizationPlanner::computeBestVF(): Assertion `(BestFactor.Width == LegacyVF.Width || planContainsAdditionalSimplifications(getPlanFor(BestFactor.Width), BestFactor.Width, CostCtx, OrigLoop, CM)) && \" VPlan cost model and legacy cost model disagreed\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0. Program arguments: /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt -passes=loop-vectorize -S reduced.ll\r\n1. Running pass \"function(loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>)\" on module \"reduced.ll\"\r\n2. Running pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"g\"\r\n #0 0x0000640a195798f0 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x30178f0)\r\n #1 0x0000640a19576d0f llvm::sys::RunSignalHandlers() (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x3014d0f)\r\n #2 0x0000640a19576e65 SignalHandler(int) Signals.cpp:0:0\r\n #3 0x00007aac19442520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #4 0x00007aac194969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\r\n #5 0x00007aac194969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10\r\n #6 0x00007aac194969fc pthread_kill ./nptl/pthread_kill.c:89:10\r\n #7 0x00007aac19442476 gsignal ./signal/../sysdeps/posix/raise.c:27:6\r\n #8 0x00007aac194287f3 abort ./stdlib/abort.c:81:7\r\n #9 0x00007aac1942871b _nl_load_domain ./intl/loadmsgcat.c:1177:9\r\n#10 0x00007aac19439e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n#11 0x0000640a18546ac9 llvm::LoopVectorizationPlanner::computeBestVF() (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1fe4ac9)\r\n#12 0x0000640a1855cedb llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1ffaedb)\r\n#13 0x0000640a1855fef1 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1ffdef1)\r\n#14 0x0000640a18560567 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1ffe567)\r\n#15 0x0000640a173c0a96 llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xe5ea96)\r\n#16 0x0000640a19384d4f llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2e22d4f)\r\n#17 0x0000640a173c3c26 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xe61c26)\r\n#18 0x0000640a19383acb llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2e21acb)\r\n#19 0x0000640a173bfec6 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xe5dec6)\r\n#20 0x0000640a19381b0d llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2e1fb0d)\r\n#21 0x0000640a16be9da6 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x687da6)\r\n#22 0x0000640a16bdbb31 optMain (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x679b31)\r\n#23 0x00007aac19429d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16\r\n#24 0x00007aac19429e40 call_init ./csu/../csu/libc-start.c:128:20\r\n#25 0x00007aac19429e40 __libc_start_main ./csu/../csu/libc-start.c:379:5\r\n#26 0x0000640a16bd1ee5 _start (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x66fee5)\r\nzsh: IOT instruction (core dumped) /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt\r\n```\r\nhttps://godbolt.org/z/W3KqbcKrb\r\n\r\nFound via fuzzer\r\nRelated/prior issue: #104714\r\n\r\ncc @fhahn ",
51
+ "author": "patrick-rivos",
52
+ "labels": [
53
+ "vectorizers",
54
+ "crash"
55
+ ],
56
+ "comments": []
57
+ },
58
+ "verified": true
59
+ }
dataset/106523.json ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "106523",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/106523",
4
+ "bug_type": "crash",
5
+ "base_commit": "2002533802dbe74c82476e30d093baf6d4cdee50",
6
+ "knowledge_cutoff": "2024-08-29T10:12:29Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/LoopVectorize"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "2dfb1c664c0a0afc512b900c45989e247406e523",
12
+ "components": [
13
+ "LoopVectorize"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": [
17
+ [
18
+ 772,
19
+ 777
20
+ ],
21
+ [
22
+ 795,
23
+ 801
24
+ ]
25
+ ],
26
+ "llvm/lib/Transforms/Vectorize/VPlanTransforms.h": [
27
+ [
28
+ 36,
29
+ 46
30
+ ]
31
+ ]
32
+ },
33
+ "bug_location_funcname": {
34
+ "llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp": [
35
+ "VPlanTransforms::adjustFixedOrderRecurrences",
36
+ "sinkRecurrenceUsersAfterPrevious"
37
+ ]
38
+ }
39
+ },
40
+ "patch": "commit 2dfb1c664c0a0afc512b900c45989e247406e523\nAuthor: Florian Hahn <[email protected]>\nDate: Wed Oct 23 13:12:03 2024 -0700\n\n [VPlan] Try to hoist Previous (and operands), if sinking fails for FORs. (#108945)\n \n In some cases, Previous (and its operands) can be hoisted. This allows\n supporting additional cases where sinking of all users of to FOR fails,\n e.g. due having to sink recipes with side-effects.\n \n This fixes a crash where we fail to create a scalar VPlan for a\n first-order recurrence, but can create a vector VPlan, because the trunc\n instruction of an IV which generates the previous value of the\n recurrence has been optimized to a truncated induction recipe, thus\n hoisting it to the beginning.\n \n Fixes https://github.com/llvm/llvm-project/issues/106523.\n \n PR: https://github.com/llvm/llvm-project/pull/108945\n\ndiff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp\nindex d50f3c0c3f3e..c6e09c4f2e6e 100644\n--- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp\n+++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp\n@@ -772,6 +772,105 @@ sinkRecurrenceUsersAfterPrevious(VPFirstOrderRecurrencePHIRecipe *FOR,\n return true;\n }\n \n+/// Try to hoist \\p Previous and its operands before all users of \\p FOR.\n+static bool hoistPreviousBeforeFORUsers(VPFirstOrderRecurrencePHIRecipe *FOR,\n+ VPRecipeBase *Previous,\n+ VPDominatorTree &VPDT) {\n+ if (Previous->mayHaveSideEffects() || Previous->mayReadFromMemory())\n+ return false;\n+\n+ // Collect recipes that need hoisting.\n+ SmallVector<VPRecipeBase *> HoistCandidates;\n+ SmallPtrSet<VPRecipeBase *, 8> Visited;\n+ VPRecipeBase *HoistPoint = nullptr;\n+ // Find the closest hoist point by looking at all users of FOR and selecting\n+ // the recipe dominating all other users.\n+ for (VPUser *U : FOR->users()) {\n+ auto *R = dyn_cast<VPRecipeBase>(U);\n+ if (!R)\n+ continue;\n+ if (!HoistPoint || VPDT.properlyDominates(R, HoistPoint))\n+ HoistPoint = R;\n+ }\n+ assert(all_of(FOR->users(),\n+ [&VPDT, HoistPoint](VPUser *U) {\n+ auto *R = dyn_cast<VPRecipeBase>(U);\n+ return !R || HoistPoint == R ||\n+ VPDT.properlyDominates(HoistPoint, R);\n+ }) &&\n+ \"HoistPoint must dominate all users of FOR\");\n+\n+ auto NeedsHoisting = [HoistPoint, &VPDT,\n+ &Visited](VPValue *HoistCandidateV) -> VPRecipeBase * {\n+ VPRecipeBase *HoistCandidate = HoistCandidateV->getDefiningRecipe();\n+ if (!HoistCandidate)\n+ return nullptr;\n+ VPRegionBlock *EnclosingLoopRegion =\n+ HoistCandidate->getParent()->getEnclosingLoopRegion();\n+ assert((!HoistCandidate->getParent()->getParent() ||\n+ HoistCandidate->getParent()->getParent() == EnclosingLoopRegion) &&\n+ \"CFG in VPlan should still be flat, without replicate regions\");\n+ // Hoist candidate was already visited, no need to hoist.\n+ if (!Visited.insert(HoistCandidate).second)\n+ return nullptr;\n+\n+ // Candidate is outside loop region or a header phi, dominates FOR users w/o\n+ // hoisting.\n+ if (!EnclosingLoopRegion || isa<VPHeaderPHIRecipe>(HoistCandidate))\n+ return nullptr;\n+\n+ // If we reached a recipe that dominates HoistPoint, we don't need to\n+ // hoist the recipe.\n+ if (VPDT.properlyDominates(HoistCandidate, HoistPoint))\n+ return nullptr;\n+ return HoistCandidate;\n+ };\n+ auto CanHoist = [&](VPRecipeBase *HoistCandidate) {\n+ // Avoid hoisting candidates with side-effects, as we do not yet analyze\n+ // associated dependencies.\n+ return !HoistCandidate->mayHaveSideEffects();\n+ };\n+\n+ if (!NeedsHoisting(Previous->getVPSingleValue()))\n+ return true;\n+\n+ // Recursively try to hoist Previous and its operands before all users of FOR.\n+ HoistCandidates.push_back(Previous);\n+\n+ for (unsigned I = 0; I != HoistCandidates.size(); ++I) {\n+ VPRecipeBase *Current = HoistCandidates[I];\n+ assert(Current->getNumDefinedValues() == 1 &&\n+ \"only recipes with a single defined value expected\");\n+ if (!CanHoist(Current))\n+ return false;\n+\n+ for (VPValue *Op : Current->operands()) {\n+ // If we reach FOR, it means the original Previous depends on some other\n+ // recurrence that in turn depends on FOR. If that is the case, we would\n+ // also need to hoist recipes involving the other FOR, which may break\n+ // dependencies.\n+ if (Op == FOR)\n+ return false;\n+\n+ if (auto *R = NeedsHoisting(Op))\n+ HoistCandidates.push_back(R);\n+ }\n+ }\n+\n+ // Order recipes to hoist by dominance so earlier instructions are processed\n+ // first.\n+ sort(HoistCandidates, [&VPDT](const VPRecipeBase *A, const VPRecipeBase *B) {\n+ return VPDT.properlyDominates(A, B);\n+ });\n+\n+ for (VPRecipeBase *HoistCandidate : HoistCandidates) {\n+ HoistCandidate->moveBefore(*HoistPoint->getParent(),\n+ HoistPoint->getIterator());\n+ }\n+\n+ return true;\n+}\n+\n bool VPlanTransforms::adjustFixedOrderRecurrences(VPlan &Plan,\n VPBuilder &LoopBuilder) {\n VPDominatorTree VPDT;\n@@ -795,7 +894,8 @@ bool VPlanTransforms::adjustFixedOrderRecurrences(VPlan &Plan,\n Previous = PrevPhi->getBackedgeValue()->getDefiningRecipe();\n }\n \n- if (!sinkRecurrenceUsersAfterPrevious(FOR, Previous, VPDT))\n+ if (!sinkRecurrenceUsersAfterPrevious(FOR, Previous, VPDT) &&\n+ !hoistPreviousBeforeFORUsers(FOR, Previous, VPDT))\n return false;\n \n // Introduce a recipe to combine the incoming and previous values of a\ndiff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.h b/llvm/lib/Transforms/Vectorize/VPlanTransforms.h\nindex 60a44bfb0dca..11e094db6294 100644\n--- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.h\n+++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.h\n@@ -36,11 +36,11 @@ struct VPlanTransforms {\n GetIntOrFpInductionDescriptor,\n ScalarEvolution &SE, const TargetLibraryInfo &TLI);\n \n- /// Sink users of fixed-order recurrences after the recipe defining their\n- /// previous value. Then introduce FirstOrderRecurrenceSplice VPInstructions\n- /// to combine the value from the recurrence phis and previous values. The\n- /// current implementation assumes all users can be sunk after the previous\n- /// value, which is enforced by earlier legality checks.\n+ /// Try to have all users of fixed-order recurrences appear after the recipe\n+ /// defining their previous value, by either sinking users or hoisting recipes\n+ /// defining their previous value (and its operands). Then introduce\n+ /// FirstOrderRecurrenceSplice VPInstructions to combine the value from the\n+ /// recurrence phis and previous values.\n /// \\returns true if all users of fixed-order recurrences could be re-arranged\n /// as needed or false if it is not possible. In the latter case, \\p Plan is\n /// not valid.\n",
41
+ "tests": [
42
+ {
43
+ "file": "llvm/test/Transforms/LoopVectorize/X86/fixed-order-recurrence.ll",
44
+ "commands": [
45
+ "opt -passes=loop-vectorize -S -o - %s"
46
+ ],
47
+ "tests": [
48
+ {
49
+ "test_name": "test_pr62954_scalar_epilogue_required",
50
+ "test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-pc_linux\"\n\ndefine i64 @test_pr62954_scalar_epilogue_required(ptr %A, ptr noalias %B, ptr %C) {\nentry:\n %gep = getelementptr i8, ptr %A, i64 872\n %rec.start = load i64, ptr %gep, align 8\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 1, %entry ], [ %iv.next, %loop ]\n %for = phi i64 [ %rec.start, %entry ], [ %neg.iv, %loop ]\n %gep.B = getelementptr double, ptr %B, i64 %iv\n %l.B = load double, ptr %gep.B, align 8\n %neg.iv = sub nsw i64 0, %iv\n store i64 %neg.iv, ptr %gep, align 8\n %iv.next = add nuw nsw i64 %iv, 2\n %ec = icmp ugt i64 %iv, 74\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n %.in.lcssa = phi i64 [ %for, %loop ]\n %.lcssa = phi double [ %l.B, %loop ]\n store double %.lcssa, ptr %C, align 8\n ret i64 %.in.lcssa\n}\n"
51
+ },
52
+ {
53
+ "test_name": "thirdorderrec",
54
+ "test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-pc_linux\"\n\ndefine void @thirdorderrec(ptr nocapture noundef readonly %x, ptr noalias nocapture noundef writeonly %y, i32 noundef %n) {\nentry:\n %cmp38 = icmp sgt i32 %n, 3\n br i1 %cmp38, label %for.body.preheader, label %for.cond.cleanup\n\nfor.body.preheader: ; preds = %entry\n %wide.trip.count = zext i32 %n to i64\n %.pre = load i8, ptr %x, align 1\n %arrayidx5.phi.trans.insert = getelementptr inbounds i8, ptr %x, i64 1\n %.pre44 = load i8, ptr %arrayidx5.phi.trans.insert, align 1\n %arrayidx12.phi.trans.insert = getelementptr inbounds i8, ptr %x, i64 2\n %.pre45 = load i8, ptr %arrayidx12.phi.trans.insert, align 1\n br label %for.body\n\nfor.cond.cleanup: ; preds = %for.body, %entry\n ret void\n\nfor.body: ; preds = %for.body, %for.body.preheader\n %0 = phi i8 [ %.pre45, %for.body.preheader ], [ %3, %for.body ]\n %1 = phi i8 [ %.pre44, %for.body.preheader ], [ %0, %for.body ]\n %2 = phi i8 [ %.pre, %for.body.preheader ], [ %1, %for.body ]\n %indvars.iv = phi i64 [ 3, %for.body.preheader ], [ %indvars.iv.next, %for.body ]\n %add8 = add i8 %1, %2\n %add15 = add i8 %add8, %0\n %arrayidx18 = getelementptr inbounds i8, ptr %x, i64 %indvars.iv\n %3 = load i8, ptr %arrayidx18, align 1\n %add21 = add i8 %add15, %3\n %arrayidx24 = getelementptr inbounds i8, ptr %y, i64 %indvars.iv\n store i8 %add21, ptr %arrayidx24, align 1\n %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1\n %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count\n br i1 %exitcond.not, label %for.cond.cleanup, label %for.body\n}\n"
55
+ },
56
+ {
57
+ "test_name": "for_iv_trunc_optimized",
58
+ "test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-pc_linux\"\n\ndefine void @for_iv_trunc_optimized(ptr %dst) {\nbb:\n br label %loop\n\nloop: ; preds = %loop, %bb\n %iv = phi i64 [ 1, %bb ], [ %add, %loop ]\n %for.1 = phi i32 [ 1, %bb ], [ %trunc, %loop ]\n %for.2 = phi i32 [ 0, %bb ], [ %or, %loop ]\n %or = or i32 %for.1, 3\n %add = add i64 %iv, 1\n store i32 %for.2, ptr %dst, align 4\n %icmp = icmp ult i64 %iv, 337\n %trunc = trunc i64 %iv to i32\n br i1 %icmp, label %loop, label %exit\n\nexit: ; preds = %loop\n ret void\n}\n"
59
+ },
60
+ {
61
+ "test_name": "firstorderrec",
62
+ "test_body": "target datalayout = \"e-m:e-i64:64-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-pc_linux\"\n\ndefine void @firstorderrec(ptr nocapture noundef readonly %x, ptr noalias nocapture noundef writeonly %y, i32 noundef %n) {\nentry:\n %cmp18 = icmp sgt i32 %n, 1\n br i1 %cmp18, label %for.body.preheader, label %for.cond.cleanup\n\nfor.body.preheader: ; preds = %entry\n %wide.trip.count = zext i32 %n to i64\n %.pre = load i8, ptr %x, align 1\n br label %for.body\n\nfor.cond.cleanup: ; preds = %for.body, %entry\n ret void\n\nfor.body: ; preds = %for.body, %for.body.preheader\n %0 = phi i8 [ %.pre, %for.body.preheader ], [ %1, %for.body ]\n %indvars.iv = phi i64 [ 1, %for.body.preheader ], [ %indvars.iv.next, %for.body ]\n %arrayidx4 = getelementptr inbounds i8, ptr %x, i64 %indvars.iv\n %1 = load i8, ptr %arrayidx4, align 1\n %add7 = add i8 %1, %0\n %arrayidx10 = getelementptr inbounds i8, ptr %y, i64 %indvars.iv\n store i8 %add7, ptr %arrayidx10, align 1\n %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1\n %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count\n br i1 %exitcond.not, label %for.cond.cleanup, label %for.body\n}\n"
63
+ }
64
+ ]
65
+ },
66
+ {
67
+ "file": "llvm/test/Transforms/LoopVectorize/first-order-recurrence-chains-vplan.ll",
68
+ "commands": [
69
+ "opt -passes=loop-vectorize -force-vector-width=4 -force-vector-interleave=1 -debug-only=loop-vectorize -disable-output -S %s 2>&1"
70
+ ],
71
+ "tests": [
72
+ {
73
+ "test_name": "test_chained_first_order_recurrences_4",
74
+ "test_body": "define i32 @test_chained_first_order_recurrences_4(ptr %base, i64 %x) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ %iv.next, %loop ], [ 0, %entry ]\n %for.x = phi i64 [ %for.x.next, %loop ], [ 0, %entry ]\n %for.y = phi i32 [ %for.x.prev, %loop ], [ 0, %entry ]\n %iv.next = add i64 %iv, 1\n %gep = getelementptr i64, ptr %base, i64 %iv\n %for.x.prev = trunc i64 %for.x to i32\n %for.y.i64 = sext i32 %for.y to i64\n store i64 %for.y.i64, ptr %gep, align 4\n %for.x.next = mul i64 %x, 2\n %icmp = icmp ugt i64 %iv, 4096\n br i1 %icmp, label %ret, label %loop\n\nret: ; preds = %loop\n ret i32 0\n}\n"
75
+ },
76
+ {
77
+ "test_name": "test_chained_first_order_recurrences_3",
78
+ "test_body": "define void @test_chained_first_order_recurrences_3(ptr %ptr) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %for.1 = phi i16 [ 22, %entry ], [ %for.1.next, %loop ]\n %for.2 = phi i16 [ 33, %entry ], [ %for.1, %loop ]\n %for.3 = phi i16 [ 33, %entry ], [ %for.2, %loop ]\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %iv.next = add nuw nsw i64 %iv, 1\n %gep.ptr = getelementptr inbounds i16, ptr %ptr, i64 %iv\n %for.1.next = load i16, ptr %gep.ptr, align 2\n %add.1 = add i16 %for.1, %for.2\n %add.2 = add i16 %add.1, %for.3\n store i16 %add.2, ptr %gep.ptr, align 2\n %exitcond.not = icmp eq i64 %iv.next, 1000\n br i1 %exitcond.not, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n"
79
+ },
80
+ {
81
+ "test_name": "test_chained_first_order_recurrences_1",
82
+ "test_body": "define void @test_chained_first_order_recurrences_1(ptr %ptr) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %for.1 = phi i16 [ 22, %entry ], [ %for.1.next, %loop ]\n %for.2 = phi i16 [ 33, %entry ], [ %for.1, %loop ]\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %iv.next = add nuw nsw i64 %iv, 1\n %gep.ptr = getelementptr inbounds i16, ptr %ptr, i64 %iv\n %for.1.next = load i16, ptr %gep.ptr, align 2\n %add = add i16 %for.1, %for.2\n store i16 %add, ptr %gep.ptr, align 2\n %exitcond.not = icmp eq i64 %iv.next, 1000\n br i1 %exitcond.not, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n"
83
+ },
84
+ {
85
+ "test_name": "test_chained_first_order_recurrences_5_hoist_to_load",
86
+ "test_body": "define i32 @test_chained_first_order_recurrences_5_hoist_to_load(ptr %base) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ %iv.next, %loop ], [ 0, %entry ]\n %for.x = phi i64 [ %for.x.next, %loop ], [ 0, %entry ]\n %for.y = phi i32 [ %for.x.prev, %loop ], [ 0, %entry ]\n %iv.next = add i64 %iv, 1\n %gep = getelementptr i64, ptr %base, i64 %iv\n %l = load i64, ptr %gep, align 4\n %for.x.prev = trunc i64 %for.x to i32\n %for.y.i64 = sext i32 %for.y to i64\n store i64 %for.y.i64, ptr %gep, align 4\n %for.x.next = mul i64 %l, 2\n %icmp = icmp ugt i64 %iv, 4096\n br i1 %icmp, label %ret, label %loop\n\nret: ; preds = %loop\n ret i32 0\n}\n"
87
+ }
88
+ ]
89
+ },
90
+ {
91
+ "file": "llvm/test/Transforms/LoopVectorize/first-order-recurrence-multiply-recurrences.ll",
92
+ "commands": [],
93
+ "tests": [
94
+ {
95
+ "test_name": "test_pr54223_sink_after_insertion_order",
96
+ "test_body": "define void @test_pr54223_sink_after_insertion_order(ptr noalias %a, ptr noalias %b, ptr noalias %dst) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %for.1 = phi float [ 0.000000e+00, %entry ], [ %for.1.next, %loop ]\n %for.2 = phi float [ 0.000000e+00, %entry ], [ %for.2.next, %loop ]\n %neg = fneg float %for.2\n %muladd = call float @llvm.fmuladd.f32(float %for.1, float %neg, float 0.000000e+00)\n %dst.gep = getelementptr inbounds float, ptr %dst, i64 %iv\n %iv.next = add nuw nsw i64 %iv, 1\n %for.1.next = load float, ptr %a, align 4\n %for.2.next = load float, ptr %b, align 4\n store float %muladd, ptr %dst.gep, align 4\n %exitcond.not = icmp eq i64 %iv.next, 10000\n br i1 %exitcond.not, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare float @llvm.fmuladd.f32(float, float, float) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"
97
+ },
98
+ {
99
+ "test_name": "test_pr54233_for_depend_on_each_other",
100
+ "test_body": "define void @test_pr54233_for_depend_on_each_other(ptr noalias %a, ptr noalias %b) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %for.1 = phi i32 [ 0, %entry ], [ %for.1.next, %loop ]\n %for.2 = phi i32 [ 0, %entry ], [ %for.2.next, %loop ]\n %or = or i32 %for.2, 10\n %shl = shl i32 %for.2, %for.1\n %xor = xor i32 %shl, 255\n %and = and i32 %xor, %or\n %for.1.next = xor i32 12, %for.2\n %for.2.next = load i32, ptr %b, align 4\n %a.gep = getelementptr inbounds i32, ptr %a, i64 %iv\n store i32 %and, ptr %a.gep, align 4\n %iv.next = add nuw i64 %iv, 1\n %exitcond = icmp eq i64 %iv, 1000\n br i1 %exitcond, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n"
101
+ }
102
+ ]
103
+ }
104
+ ],
105
+ "issue": {
106
+ "title": "Assertion `hasPlanWithVF(ScalarVF) && \"More than a single plan/VF w/o any plan having scalar VF\"' failed.",
107
+ "body": "To reproduce run the following test with -passes=loop-vectorize\r\n```\r\n; ModuleID = './reduced.ll'\r\nsource_filename = \"./reduced.ll\"\r\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128-ni:1-p2:32:8:8:32-ni:2\"\r\ntarget triple = \"x86_64-unknown-linux-gnu\"\r\n\r\ndefine void @wombat() gc \"statepoint-example\" {\r\nbb:\r\n br label %bb1\r\n\r\nbb1: ; preds = %bb1, %bb\r\n %phi = phi i64 [ %add, %bb1 ], [ 1, %bb ]\r\n %phi2 = phi i32 [ %trunc, %bb1 ], [ 1, %bb ]\r\n %phi3 = phi i32 [ %or, %bb1 ], [ 0, %bb ]\r\n %or = or i32 %phi2, 0\r\n %add = add i64 %phi, 1\r\n store i32 %phi3, ptr addrspace(1) null, align 4\r\n %icmp = icmp ult i64 %phi, 337\r\n %trunc = trunc i64 %phi to i32\r\n br i1 %icmp, label %bb1, label %bb4\r\n\r\nbb4: ; preds = %bb1\r\n ret void\r\n}\r\n```\r\n\r\nReproducer: https://godbolt.org/z/e14eWvxMb\r\n\r\nStack dump:\r\n```\r\nopt: /root/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:7304: llvm::VectorizationFactor llvm::LoopVectorizationPlanner::computeBestVF(): Assertion `hasPlanWithVF(ScalarVF) && \"More than a single plan/VF w/o any plan having scalar VF\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=loop-vectorize <source>\r\n1.\tRunning pass \"function(loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>)\" on module \"<source>\"\r\n2.\tRunning pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"wombat\"\r\n #0 0x0000000004fa4138 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4fa4138)\r\n #1 0x0000000004fa18ac SignalHandler(int) Signals.cpp:0:0\r\n #2 0x000073e073a42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #3 0x000073e073a969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\r\n #4 0x000073e073a42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\r\n #5 0x000073e073a287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\r\n #6 0x000073e073a2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\r\n #7 0x000073e073a39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n #8 0x0000000003fe5276 llvm::LoopVectorizationPlanner::computeBestVF() (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3fe5276)\r\n #9 0x0000000004001214 llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4001214)\r\n#10 0x0000000004003eb9 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4003eb9)\r\n#11 0x0000000004004543 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4004543)\r\n#12 0x0000000002ec85ae llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2ec85ae)\r\n#13 0x0000000004da08f8 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4da08f8)\r\n#14 0x0000000000df11be llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xdf11be)\r\n#15 0x0000000004d9f2fe llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4d9f2fe)\r\n#16 0x0000000000df0aae llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xdf0aae)\r\n#17 0x0000000004d9d490 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4d9d490)\r\n#18 0x00000000008e8002 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8e8002)\r\n#19 0x00000000008daedc optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8daedc)\r\n#20 0x000073e073a29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\r\n#21 0x000073e073a29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\r\n#22 0x00000000008d296e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8d296e)\r\nProgram terminated with signal: SIGSEGV\r\nCompiler returned: 139",
108
+ "author": "TatyanaDoubts",
109
+ "labels": [
110
+ "vectorizers",
111
+ "crash-on-valid"
112
+ ],
113
+ "comments": [
114
+ {
115
+ "author": "fhahn",
116
+ "body": "Very interesting issue thanks! Proposed fix https://github.com/llvm/llvm-project/issues/106523"
117
+ }
118
+ ]
119
+ },
120
+ "verified": true
121
+ }
dataset/106626.json ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "106626",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/106626",
4
+ "bug_type": "crash",
5
+ "base_commit": "e51fc36c385d756ccbc2be8c47c52af207c3aead",
6
+ "knowledge_cutoff": "2024-08-29T20:51:42Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/SLPVectorizer"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "cc943a67d114e28c28f561c3b1a48ff2003264ce",
12
+ "components": [
13
+ "SLPVectorizer"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
17
+ [
18
+ 3237,
19
+ 3251
20
+ ]
21
+ ]
22
+ },
23
+ "bug_location_funcname": {
24
+ "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
25
+ "findLaneForValue"
26
+ ]
27
+ }
28
+ },
29
+ "patch": "commit cc943a67d114e28c28f561c3b1a48ff2003264ce\nAuthor: Alexey Bataev <[email protected]>\nDate: Thu Aug 29 15:05:09 2024 -0700\n\n [SLP]Fix PR106626: trye several attempts for lookup values, if not found.\n \n If the value is used in Scalar several times, the first attempt to find\n its position in the node (if ReuseShuffleIndices and ReorderIndices not\n empty) may fail. In this case need to find another copy of the same\n value and try again.\n Fixes https://github.com/llvm/llvm-project/issues/106626\n\ndiff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\nindex 775fa9ba75cf..edb2567fa057 100644\n--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n@@ -3237,15 +3237,25 @@ private:\n /// When ReuseReorderShuffleIndices is empty it just returns position of \\p\n /// V within vector of Scalars. Otherwise, try to remap on its reuse index.\n int findLaneForValue(Value *V) const {\n- unsigned FoundLane = std::distance(Scalars.begin(), find(Scalars, V));\n- assert(FoundLane < Scalars.size() && \"Couldn't find extract lane\");\n- if (!ReorderIndices.empty())\n- FoundLane = ReorderIndices[FoundLane];\n- assert(FoundLane < Scalars.size() && \"Couldn't find extract lane\");\n- if (!ReuseShuffleIndices.empty()) {\n- FoundLane = std::distance(ReuseShuffleIndices.begin(),\n- find(ReuseShuffleIndices, FoundLane));\n+ unsigned FoundLane = getVectorFactor();\n+ for (auto *It = find(Scalars, V), *End = Scalars.end(); It != End;\n+ std::advance(It, 1)) {\n+ if (*It != V)\n+ continue;\n+ FoundLane = std::distance(Scalars.begin(), It);\n+ assert(FoundLane < Scalars.size() && \"Couldn't find extract lane\");\n+ if (!ReorderIndices.empty())\n+ FoundLane = ReorderIndices[FoundLane];\n+ assert(FoundLane < Scalars.size() && \"Couldn't find extract lane\");\n+ if (ReuseShuffleIndices.empty())\n+ break;\n+ if (auto *RIt = find(ReuseShuffleIndices, FoundLane);\n+ RIt != ReuseShuffleIndices.end()) {\n+ FoundLane = std::distance(ReuseShuffleIndices.begin(), RIt);\n+ break;\n+ }\n }\n+ assert(FoundLane < getVectorFactor() && \"Unable to find given value.\");\n return FoundLane;\n }\n \n",
30
+ "tests": [
31
+ {
32
+ "file": "llvm/test/Transforms/SLPVectorizer/AArch64/reused-scalar-repeated-in-node.ll",
33
+ "commands": [
34
+ "opt -S --passes=slp-vectorizer -mtriple=aarch64-unknown-linux-gnu < %s"
35
+ ],
36
+ "tests": [
37
+ {
38
+ "test_name": "test",
39
+ "test_body": "define void @test() {\nentry:\n br label %bb61\n\nbb61: ; preds = %entry\n br label %bb64\n\nbb62: ; No predecessors!\n br i1 poison, label %bb63, label %bb64\n\nbb63: ; preds = %bb62\n br label %bb64\n\nbb64: ; preds = %bb63, %bb62, %bb61\n %i = phi nsz float [ poison, %bb61 ], [ poison, %bb63 ], [ poison, %bb62 ]\n %i65 = phi nsz float [ poison, %bb61 ], [ poison, %bb63 ], [ poison, %bb62 ]\n %i66 = load float, ptr poison, align 16\n %i67 = load float, ptr poison, align 4\n %i68 = load float, ptr poison, align 8\n %i69 = load float, ptr poison, align 4\n %i70 = load float, ptr poison, align 4\n %i71 = load float, ptr poison, align 16\n %i72 = load float, ptr poison, align 4\n %i73 = load float, ptr poison, align 8\n %i74 = load float, ptr poison, align 4\n %i75 = load float, ptr poison, align 16\n %i76 = load float, ptr poison, align 4\n br i1 poison, label %bb167, label %bb77\n\nbb77: ; preds = %bb64\n br label %bb78\n\nbb78: ; preds = %bb78, %bb77\n %i79 = phi nsz float [ %i66, %bb77 ], [ %i103, %bb78 ]\n %i80 = phi nsz float [ %i67, %bb77 ], [ %i104, %bb78 ]\n %i81 = phi nsz float [ %i68, %bb77 ], [ %i105, %bb78 ]\n %i82 = phi nsz float [ poison, %bb77 ], [ %i106, %bb78 ]\n %i83 = phi nsz float [ poison, %bb77 ], [ %i123, %bb78 ]\n %i84 = phi nsz float [ %i69, %bb77 ], [ %i124, %bb78 ]\n %i85 = phi nsz float [ poison, %bb77 ], [ %i125, %bb78 ]\n %i86 = phi nsz float [ %i70, %bb77 ], [ %i126, %bb78 ]\n %i87 = fmul fast float %i79, poison\n %i88 = fmul fast float %i80, poison\n %i89 = fmul fast float %i81, poison\n %i90 = fmul fast float %i82, poison\n %i91 = fmul fast float %i83, poison\n %i92 = fadd fast float %i91, %i87\n %i93 = fmul fast float %i84, poison\n %i94 = fadd fast float %i93, %i88\n %i95 = fmul fast float %i85, poison\n %i96 = fadd fast float %i95, %i89\n %i97 = fmul fast float %i86, poison\n %i98 = fadd fast float %i97, %i90\n %i99 = fadd fast float %i92, poison\n %i100 = fadd fast float %i94, poison\n %i101 = fadd fast float %i96, poison\n %i102 = fadd fast float %i98, poison\n %i103 = fadd fast float %i99, poison\n %i104 = fadd fast float %i100, poison\n %i105 = fadd fast float %i101, poison\n %i106 = fadd fast float %i102, poison\n %i107 = fmul fast float %i79, poison\n %i108 = fmul fast float %i80, poison\n %i109 = fmul fast float %i81, poison\n %i110 = fmul fast float %i82, poison\n %i111 = fmul fast float %i83, poison\n %i112 = fadd fast float %i111, %i107\n %i113 = fmul fast float %i84, poison\n %i114 = fadd fast float %i113, %i108\n %i115 = fmul fast float %i85, poison\n %i116 = fadd fast float %i115, %i109\n %i117 = fmul fast float %i86, poison\n %i118 = fadd fast float %i117, %i110\n %i119 = fadd fast float %i112, poison\n %i120 = fadd fast float %i114, poison\n %i121 = fadd fast float %i116, poison\n %i122 = fadd fast float %i118, poison\n %i123 = fadd fast float %i119, poison\n %i124 = fadd fast float %i120, poison\n %i125 = fadd fast float %i121, poison\n %i126 = fadd fast float %i122, poison\n %i127 = fmul fast float %i79, %i\n %i128 = fmul fast float %i80, %i\n %i129 = fmul fast float %i81, %i\n %i130 = fmul fast float %i82, %i\n %i131 = fmul fast float %i83, %i65\n %i132 = fadd fast float %i131, %i127\n %i133 = fmul fast float %i84, %i65\n %i134 = fadd fast float %i133, %i128\n %i135 = fmul fast float %i85, %i65\n %i136 = fadd fast float %i135, %i129\n %i137 = fmul fast float %i86, %i65\n %i138 = fadd fast float %i137, %i130\n %i139 = fadd fast float %i132, poison\n %i140 = fadd fast float %i134, poison\n %i141 = fadd fast float %i136, poison\n %i142 = fadd fast float %i138, poison\n %i143 = fadd fast float %i139, poison\n %i144 = fadd fast float %i140, poison\n %i145 = fadd fast float %i141, poison\n %i146 = fadd fast float %i142, poison\n %i147 = fmul fast float %i79, poison\n %i148 = fmul fast float %i80, poison\n %i149 = fmul fast float %i81, poison\n %i150 = fmul fast float %i82, poison\n %i151 = fmul fast float %i83, poison\n %i152 = fadd fast float %i151, %i147\n %i153 = fmul fast float %i84, poison\n %i154 = fadd fast float %i153, %i148\n %i155 = fmul fast float %i85, poison\n %i156 = fadd fast float %i155, %i149\n %i157 = fmul fast float %i86, poison\n %i158 = fadd fast float %i157, %i150\n %i159 = fadd fast float %i152, poison\n %i160 = fadd fast float %i154, poison\n %i161 = fadd fast float %i156, poison\n %i162 = fadd fast float %i158, poison\n %i163 = fadd fast float %i159, poison\n %i164 = fadd fast float %i160, poison\n %i165 = fadd fast float %i161, poison\n %i166 = fadd fast float %i162, poison\n br i1 poison, label %bb78, label %bb167\n\nbb167: ; preds = %bb78, %bb64\n %i168 = phi nsz float [ %i76, %bb64 ], [ %i166, %bb78 ]\n %i169 = phi nsz float [ poison, %bb64 ], [ %i165, %bb78 ]\n %i170 = phi nsz float [ poison, %bb64 ], [ %i164, %bb78 ]\n %i171 = phi nsz float [ %i75, %bb64 ], [ %i163, %bb78 ]\n %i172 = phi nsz float [ %i74, %bb64 ], [ %i146, %bb78 ]\n %i173 = phi nsz float [ %i73, %bb64 ], [ %i145, %bb78 ]\n %i174 = phi nsz float [ %i72, %bb64 ], [ %i144, %bb78 ]\n %i175 = phi nsz float [ %i71, %bb64 ], [ %i143, %bb78 ]\n %i176 = phi nsz float [ %i70, %bb64 ], [ %i126, %bb78 ]\n %i177 = phi nsz float [ poison, %bb64 ], [ %i125, %bb78 ]\n %i178 = phi nsz float [ %i69, %bb64 ], [ %i124, %bb78 ]\n %i179 = phi nsz float [ poison, %bb64 ], [ %i123, %bb78 ]\n %i180 = phi nsz float [ poison, %bb64 ], [ %i106, %bb78 ]\n %i181 = phi nsz float [ %i68, %bb64 ], [ %i105, %bb78 ]\n %i182 = phi nsz float [ %i67, %bb64 ], [ %i104, %bb78 ]\n %i183 = phi nsz float [ %i66, %bb64 ], [ %i103, %bb78 ]\n store float %i182, ptr poison, align 1\n store float %i174, ptr poison, align 1\n br i1 poison, label %bb186, label %bb184\n\nbb184: ; preds = %bb167\n br label %bb185\n\nbb185: ; preds = %bb185, %bb184\n br i1 poison, label %bb185, label %bb186\n\nbb186: ; preds = %bb185, %bb167\n %i187 = phi nsz float [ %i178, %bb167 ], [ poison, %bb185 ]\n ret void\n}\n"
40
+ }
41
+ ]
42
+ }
43
+ ],
44
+ "issue": {
45
+ "title": "[SLP] Assertion \"All elements in mask must be less than CommonVF.\" failed",
46
+ "body": "[PR77529](https://github.com/llvm/llvm-project/pull/77529) trigger assertion on \"All elements in mask must be less than CommonVF.\" failed.\r\n\r\n@alexey-bataev \r\n\r\nTo reproduce, run with: opt -S -passes=slp-vectorizer t.ll -o o.ll\r\nUsing reduced t.ll below\r\n```\r\ntarget datalayout = \"e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32\"\r\ntarget triple = \"aarch64-unknown-linux-gnu\"\r\n\r\ndefine void @test() {\r\nentry:\r\n br label %bb61\r\n\r\nbb61:\r\n br label %bb64\r\n\r\nbb62:\r\n br i1 poison, label %bb63, label %bb64\r\n\r\nbb63:\r\n br label %bb64\r\n\r\nbb64:\r\n %i = phi nsz float [ poison, %bb61 ], [ poison, %bb63 ], [ poison, %bb62 ]\r\n %i65 = phi nsz float [ poison, %bb61 ], [ poison, %bb63 ], [ poison, %bb62 ]\r\n %i66 = load float, ptr poison, align 16\r\n %i67 = load float, ptr poison, align 4\r\n %i68 = load float, ptr poison, align 8\r\n %i69 = load float, ptr poison, align 4\r\n %i70 = load float, ptr poison, align 4\r\n %i71 = load float, ptr poison, align 16\r\n %i72 = load float, ptr poison, align 4\r\n %i73 = load float, ptr poison, align 8\r\n %i74 = load float, ptr poison, align 4\r\n %i75 = load float, ptr poison, align 16\r\n %i76 = load float, ptr poison, align 4\r\n br i1 poison, label %bb167, label %bb77\r\n\r\nbb77: ; preds = %bb64\r\n br label %bb78\r\n\r\nbb78: ; preds = %bb78, %bb77\r\n %i79 = phi nsz float [ %i66, %bb77 ], [ %i103, %bb78 ]\r\n %i80 = phi nsz float [ %i67, %bb77 ], [ %i104, %bb78 ]\r\n %i81 = phi nsz float [ %i68, %bb77 ], [ %i105, %bb78 ]\r\n %i82 = phi nsz float [ poison, %bb77 ], [ %i106, %bb78 ]\r\n %i83 = phi nsz float [ poison, %bb77 ], [ %i123, %bb78 ]\r\n %i84 = phi nsz float [ %i69, %bb77 ], [ %i124, %bb78 ]\r\n %i85 = phi nsz float [ poison, %bb77 ], [ %i125, %bb78 ]\r\n %i86 = phi nsz float [ %i70, %bb77 ], [ %i126, %bb78 ]\r\n %i87 = fmul fast float %i79, poison\r\n %i88 = fmul fast float %i80, poison\r\n %i89 = fmul fast float %i81, poison\r\n %i90 = fmul fast float %i82, poison\r\n %i91 = fmul fast float %i83, poison\r\n %i92 = fadd fast float %i91, %i87\r\n %i93 = fmul fast float %i84, poison\r\n %i94 = fadd fast float %i93, %i88\r\n %i95 = fmul fast float %i85, poison\r\n %i96 = fadd fast float %i95, %i89\r\n %i97 = fmul fast float %i86, poison\r\n %i98 = fadd fast float %i97, %i90\r\n %i99 = fadd fast float %i92, poison\r\n %i100 = fadd fast float %i94, poison\r\n %i101 = fadd fast float %i96, poison\r\n %i102 = fadd fast float %i98, poison\r\n %i103 = fadd fast float %i99, poison\r\n %i104 = fadd fast float %i100, poison\r\n %i105 = fadd fast float %i101, poison\r\n %i106 = fadd fast float %i102, poison\r\n %i107 = fmul fast float %i79, poison\r\n %i108 = fmul fast float %i80, poison\r\n %i109 = fmul fast float %i81, poison\r\n %i110 = fmul fast float %i82, poison\r\n %i111 = fmul fast float %i83, poison\r\n %i112 = fadd fast float %i111, %i107\r\n %i113 = fmul fast float %i84, poison\r\n %i114 = fadd fast float %i113, %i108\r\n %i115 = fmul fast float %i85, poison\r\n %i116 = fadd fast float %i115, %i109\r\n %i117 = fmul fast float %i86, poison\r\n %i118 = fadd fast float %i117, %i110\r\n %i119 = fadd fast float %i112, poison\r\n %i120 = fadd fast float %i114, poison\r\n %i121 = fadd fast float %i116, poison\r\n %i122 = fadd fast float %i118, poison\r\n %i123 = fadd fast float %i119, poison\r\n %i124 = fadd fast float %i120, poison\r\n %i125 = fadd fast float %i121, poison\r\n %i126 = fadd fast float %i122, poison\r\n %i127 = fmul fast float %i79, %i\r\n %i128 = fmul fast float %i80, %i\r\n %i129 = fmul fast float %i81, %i\r\n %i130 = fmul fast float %i82, %i\r\n %i131 = fmul fast float %i83, %i65\r\n %i132 = fadd fast float %i131, %i127\r\n %i133 = fmul fast float %i84, %i65\r\n %i134 = fadd fast float %i133, %i128\r\n %i135 = fmul fast float %i85, %i65\r\n %i136 = fadd fast float %i135, %i129\r\n %i137 = fmul fast float %i86, %i65\r\n %i138 = fadd fast float %i137, %i130\r\n %i139 = fadd fast float %i132, poison\r\n %i140 = fadd fast float %i134, poison\r\n %i141 = fadd fast float %i136, poison\r\n %i142 = fadd fast float %i138, poison\r\n %i143 = fadd fast float %i139, poison\r\n %i144 = fadd fast float %i140, poison\r\n %i145 = fadd fast float %i141, poison\r\n %i146 = fadd fast float %i142, poison\r\n %i147 = fmul fast float %i79, poison\r\n %i148 = fmul fast float %i80, poison\r\n %i149 = fmul fast float %i81, poison\r\n %i150 = fmul fast float %i82, poison\r\n %i151 = fmul fast float %i83, poison\r\n %i152 = fadd fast float %i151, %i147\r\n %i153 = fmul fast float %i84, poison\r\n %i154 = fadd fast float %i153, %i148\r\n %i155 = fmul fast float %i85, poison\r\n %i156 = fadd fast float %i155, %i149\r\n %i157 = fmul fast float %i86, poison\r\n %i158 = fadd fast float %i157, %i150\r\n %i159 = fadd fast float %i152, poison\r\n %i160 = fadd fast float %i154, poison\r\n %i161 = fadd fast float %i156, poison\r\n %i162 = fadd fast float %i158, poison\r\n %i163 = fadd fast float %i159, poison\r\n %i164 = fadd fast float %i160, poison\r\n %i165 = fadd fast float %i161, poison\r\n %i166 = fadd fast float %i162, poison\r\n br i1 poison, label %bb78, label %bb167\r\n\r\nbb167: ; preds = %bb78, %bb64\r\n %i168 = phi nsz float [ %i76, %bb64 ], [ %i166, %bb78 ]\r\n %i169 = phi nsz float [ poison, %bb64 ], [ %i165, %bb78 ]\r\n %i170 = phi nsz float [ poison, %bb64 ], [ %i164, %bb78 ]\r\n %i171 = phi nsz float [ %i75, %bb64 ], [ %i163, %bb78 ]\r\n %i172 = phi nsz float [ %i74, %bb64 ], [ %i146, %bb78 ]\r\n %i173 = phi nsz float [ %i73, %bb64 ], [ %i145, %bb78 ]\r\n %i174 = phi nsz float [ %i72, %bb64 ], [ %i144, %bb78 ]\r\n %i175 = phi nsz float [ %i71, %bb64 ], [ %i143, %bb78 ]\r\n %i176 = phi nsz float [ %i70, %bb64 ], [ %i126, %bb78 ]\r\n %i177 = phi nsz float [ poison, %bb64 ], [ %i125, %bb78 ]\r\n %i178 = phi nsz float [ %i69, %bb64 ], [ %i124, %bb78 ]\r\n %i179 = phi nsz float [ poison, %bb64 ], [ %i123, %bb78 ]\r\n %i180 = phi nsz float [ poison, %bb64 ], [ %i106, %bb78 ]\r\n %i181 = phi nsz float [ %i68, %bb64 ], [ %i105, %bb78 ]\r\n %i182 = phi nsz float [ %i67, %bb64 ], [ %i104, %bb78 ]\r\n %i183 = phi nsz float [ %i66, %bb64 ], [ %i103, %bb78 ]\r\n store float %i182, ptr poison, align 1\r\n store float %i174, ptr poison, align 1\r\n br i1 poison, label %bb186, label %bb184\r\n\r\nbb184: ; preds = %bb167\r\n br label %bb185\r\n\r\nbb185: ; preds = %bb185, %bb184\r\n br i1 poison, label %bb185, label %bb186\r\n\r\nbb186: ; preds = %bb185, %bb167\r\n %i187 = phi nsz float [ %i178, %bb167 ], [ poison, %bb185 ]\r\n ret void\r\n}\r\n```",
47
+ "author": "huihzhang",
48
+ "labels": [
49
+ "llvm:SLPVectorizer",
50
+ "crash"
51
+ ],
52
+ "comments": []
53
+ },
54
+ "verified": true
55
+ }
dataset/106641.json ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "106641",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/106641",
4
+ "bug_type": "crash",
5
+ "base_commit": "c8568f09577e9332d15edf98beb5376dc8d0672e",
6
+ "knowledge_cutoff": "2024-08-29T23:08:58Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/LoopVectorize"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "f0e34f381866b82a26241f7e9aa5964f0dd11ebd",
12
+ "components": [
13
+ "LoopVectorize"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
17
+ [
18
+ 7147,
19
+ 7153
20
+ ],
21
+ [
22
+ 7250,
23
+ 7259
24
+ ],
25
+ [
26
+ 7284,
27
+ 7299
28
+ ],
29
+ [
30
+ 7364,
31
+ 7371
32
+ ]
33
+ ]
34
+ },
35
+ "bug_location_funcname": {
36
+ "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
37
+ "LoopVectorizationPlanner::computeBestVF",
38
+ "LoopVectorizationPlanner::precomputeCosts",
39
+ "planContainsAdditionalSimplifications"
40
+ ]
41
+ }
42
+ },
43
+ "patch": "commit f0e34f381866b82a26241f7e9aa5964f0dd11ebd\nAuthor: Florian Hahn <[email protected]>\nDate: Fri Aug 30 11:29:29 2024 +0100\n\n [VPlan] Don't skip optimizable truncs in planContainsAdditionalSimps.\n \n A optimizable cast can also be removed by VPlan simplifications. Remove\n the restriction from planContainsAdditionalSimplifications, as this\n causes it to miss relevant simplifications, triggering false positives\n for the cost decision verification.\n \n Also adds debug output for printing additional cost-precomputations.\n \n Fixes https://github.com/llvm/llvm-project/issues/106641.\n\ndiff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\nindex 6babfd1eee91..fa05b8dd2242 100644\n--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\n+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\n@@ -7147,7 +7147,12 @@ LoopVectorizationPlanner::precomputeCosts(VPlan &Plan, ElementCount VF,\n if (!OrigLoop->contains(CondI) ||\n !CostCtx.SkipCostComputation.insert(CondI).second)\n continue;\n- Cost += CostCtx.getLegacyCost(CondI, VF);\n+ InstructionCost CondICost = CostCtx.getLegacyCost(CondI, VF);\n+ LLVM_DEBUG({\n+ dbgs() << \"Cost of \" << CondICost << \" for VF \" << VF\n+ << \": exit condition instruction \" << *CondI << \"\\n\";\n+ });\n+ Cost += CondICost;\n for (Value *Op : CondI->operands()) {\n auto *OpI = dyn_cast<Instruction>(Op);\n if (!OpI || any_of(OpI->users(), [&ExitInstrs, this](User *U) {\n@@ -7250,10 +7255,9 @@ InstructionCost LoopVectorizationPlanner::cost(VPlan &Plan,\n /// not have corresponding recipes in \\p Plan and are not marked to be ignored\n /// in \\p CostCtx. This means the VPlan contains simplification that the legacy\n /// cost-model did not account for.\n-static bool\n-planContainsAdditionalSimplifications(VPlan &Plan, ElementCount VF,\n- VPCostContext &CostCtx, Loop *TheLoop,\n- LoopVectorizationCostModel &CM) {\n+static bool planContainsAdditionalSimplifications(VPlan &Plan,\n+ VPCostContext &CostCtx,\n+ Loop *TheLoop) {\n // First collect all instructions for the recipes in Plan.\n auto GetInstructionForCost = [](const VPRecipeBase *R) -> Instruction * {\n if (auto *S = dyn_cast<VPSingleDefRecipe>(R))\n@@ -7284,16 +7288,13 @@ planContainsAdditionalSimplifications(VPlan &Plan, ElementCount VF,\n // Return true if the loop contains any instructions that are not also part of\n // the VPlan or are skipped for VPlan-based cost computations. This indicates\n // that the VPlan contains extra simplifications.\n- return any_of(\n- TheLoop->blocks(), [&SeenInstrs, VF, &CostCtx, &CM](BasicBlock *BB) {\n- return any_of(*BB, [&SeenInstrs, VF, &CostCtx, &CM](Instruction &I) {\n- if (isa<PHINode>(&I))\n- return false;\n- return !SeenInstrs.contains(&I) &&\n- !CostCtx.skipCostComputation(&I, true) &&\n- !CM.canTruncateToMinimalBitwidth(&I, VF);\n- });\n- });\n+ return any_of(TheLoop->blocks(), [&SeenInstrs, &CostCtx](BasicBlock *BB) {\n+ return any_of(*BB, [&SeenInstrs, &CostCtx](Instruction &I) {\n+ if (isa<PHINode>(&I))\n+ return false;\n+ return !SeenInstrs.contains(&I) && !CostCtx.skipCostComputation(&I, true);\n+ });\n+ });\n }\n #endif\n \n@@ -7364,8 +7365,7 @@ VectorizationFactor LoopVectorizationPlanner::computeBestVF() {\n precomputeCosts(BestPlan, BestFactor.Width, CostCtx);\n assert((BestFactor.Width == LegacyVF.Width ||\n planContainsAdditionalSimplifications(getPlanFor(BestFactor.Width),\n- BestFactor.Width, CostCtx,\n- OrigLoop, CM)) &&\n+ CostCtx, OrigLoop)) &&\n \" VPlan cost model and legacy cost model disagreed\");\n assert((BestFactor.Width.isScalar() || BestFactor.ScalarCost > 0) &&\n \"when vectorizing, the scalar cost must be computed.\");\n",
44
+ "tests": [
45
+ {
46
+ "file": "llvm/test/Transforms/LoopVectorize/RISCV/truncate-to-minimal-bitwidth-cost.ll",
47
+ "commands": [
48
+ "opt -p loop-vectorize -mattr=+v -S %s"
49
+ ],
50
+ "tests": [
51
+ {
52
+ "test_name": "truncate_to_i1_used_by_branch",
53
+ "test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\ndefine void @truncate_to_i1_used_by_branch(i8 %x, ptr %dst) #0 {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %f.039 = phi i8 [ 0, %entry ], [ %add, %loop.latch ]\n %0 = or i8 23, %x\n %extract.t = trunc i8 %0 to i1\n br i1 %extract.t, label %then, label %loop.latch\n\nthen: ; preds = %loop.header\n store i8 0, ptr %dst, align 1\n br label %loop.latch\n\nloop.latch: ; preds = %then, %loop.header\n %add = add i8 %f.039, 1\n %conv = sext i8 %f.039 to i32\n %cmp = icmp slt i32 %conv, 1\n br i1 %cmp, label %loop.header, label %exit\n\nexit: ; preds = %loop.latch\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+64bit,+v,+zvl256b\" }\n"
54
+ },
55
+ {
56
+ "test_name": "test_pr98413_sext_removed",
57
+ "test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\ndefine void @test_pr98413_sext_removed(ptr %src, ptr noalias %dst, i64 %x) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %gep.src = getelementptr inbounds i16, ptr %src, i64 %iv\n %l = load i16, ptr %gep.src, align 8\n %ext.l = sext i16 %l to i64\n %and = and i64 %x, %ext.l\n %trunc.and = trunc i64 %and to i8\n %gep.dst = getelementptr inbounds i8, ptr %dst, i64 %iv\n store i8 %trunc.and, ptr %gep.dst, align 1\n %iv.next = add i64 %iv, 1\n %exitcond.not = icmp eq i64 %iv, 96\n br i1 %exitcond.not, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n"
58
+ },
59
+ {
60
+ "test_name": "test_pr98413_zext_removed",
61
+ "test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\ndefine void @test_pr98413_zext_removed(ptr %src, ptr noalias %dst, i64 %x) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %gep.src = getelementptr inbounds i16, ptr %src, i64 %iv\n %l = load i16, ptr %gep.src, align 8\n %ext.l = zext i16 %l to i64\n %and = and i64 %x, %ext.l\n %trunc.and = trunc i64 %and to i8\n %gep.dst = getelementptr inbounds i8, ptr %dst, i64 %iv\n store i8 %trunc.and, ptr %gep.dst, align 1\n %iv.next = add i64 %iv, 1\n %exitcond.not = icmp eq i64 %iv, 96\n br i1 %exitcond.not, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n"
62
+ }
63
+ ]
64
+ }
65
+ ],
66
+ "issue": {
67
+ "title": "[VPlan] Assertion \" VPlan cost model and legacy cost model disagreed\"' failed.",
68
+ "body": "Tested using c4906588ce47de33d59bcd95f3e82ce2c3e61c23\r\n\r\nTestcase:\r\n```c\r\n_Bool a;\r\nchar b;\r\nunsigned char c;\r\nvoid d(_Bool e[][6]) {\r\n for (signed char f = 0; f < c; f += 3)\r\n for (_Bool g = ({\r\n __typeof__(0) h = e[1][2];\r\n e[f][f] > h ?: h;\r\n });\r\n g; g = b)\r\n for (_Bool i = 0; i < (0 >= 0); i = 1)\r\n a = 0;\r\n}\r\n```\r\nhttps://godbolt.org/z/Eab8s5e1K\r\n\r\nReduced LLVM IR Testcase:\r\n```llvm ir\r\n; ModuleID = 'reduced.bc'\r\ntarget datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\r\ntarget triple = \"riscv64-unknown-linux-gnu\"\r\n\r\ndefine void @d() #0 {\r\nentry:\r\n br label %for.body\r\n\r\nfor.cond.cleanup.loopexit: ; preds = %for.cond.cleanup14\r\n ret void\r\n\r\nfor.body: ; preds = %for.cond.cleanup14, %entry\r\n %f.039 = phi i8 [ %add, %for.cond.cleanup14 ], [ 0, %entry ]\r\n %0 = or i8 0, 0\r\n %extract.t = trunc i8 %0 to i1\r\n br i1 %extract.t, label %for.body22.lr.ph, label %for.cond.cleanup14\r\n\r\nfor.body22.lr.ph: ; preds = %for.body\r\n store i8 0, ptr null, align 1\r\n br label %for.cond.cleanup14\r\n\r\nfor.cond.cleanup14: ; preds = %for.body22.lr.ph, %for.body\r\n %add = add i8 %f.039, 1\r\n %conv = sext i8 %f.039 to i32\r\n %cmp = icmp slt i32 %conv, 1\r\n br i1 %cmp, label %for.body, label %for.cond.cleanup.loopexit\r\n}\r\n\r\nattributes #0 = { \"target-features\"=\"+64bit,+a,+c,+d,+f,+m,+relax,+v,+zicsr,+zifencei,+zmmul,+zve32f,+zve32x,+zve64d,+zve64f,+zve64x,+zvl128b,+zvl256b,+zvl32b,+zvl64b,-b,-e,-experimental-smctr,-experimental-smmpm,-experimental-smnpm,-experimental-ssctr,-experimental-ssnpm,-experimental-sspm,-experimental-supm,-experimental-zacas,-experimental-zalasr,-experimental-zicfilp,-experimental-zicfiss,-experimental-zvbc32e,-experimental-zvkgs,-h,-shcounterenw,-shgatpa,-shtvala,-shvsatpa,-shvstvala,-shvstvecd,-smaia,-smcdeleg,-smcsrind,-smepmp,-smstateen,-ssaia,-ssccfg,-ssccptr,-sscofpmf,-sscounterenw,-sscsrind,-ssqosid,-ssstateen,-ssstrict,-sstc,-sstvala,-sstvecd,-ssu64xl,-svade,-svadu,-svbare,-svinval,-svnapot,-svpbmt,-xcvalu,-xcvbi,-xcvbitmanip,-xcvelw,-xcvmac,-xcvmem,-xcvsimd,-xsfcease,-xsfvcp,-xsfvfnrclipxfqf,-xsfvfwmaccqqq,-xsfvqmaccdod,-xsfvqmaccqoq,-xsifivecdiscarddlone,-xsifivecflushdlone,-xtheadba,-xtheadbb,-xtheadbs,-xtheadcmo,-xtheadcondmov,-xtheadfmemidx,-xtheadmac,-xtheadmemidx,-xtheadmempair,-xtheadsync,-xtheadvdot,-xventanacondops,-xwchc,-za128rs,-za64rs,-zaamo,-zabha,-zalrsc,-zama16b,-zawrs,-zba,-zbb,-zbc,-zbkb,-zbkc,-zbkx,-zbs,-zca,-zcb,-zcd,-zce,-zcf,-zcmop,-zcmp,-zcmt,-zdinx,-zfa,-zfbfmin,-zfh,-zfhmin,-zfinx,-zhinx,-zhinxmin,-zic64b,-zicbom,-zicbop,-zicboz,-ziccamoa,-ziccif,-zicclsm,-ziccrse,-zicntr,-zicond,-zihintntl,-zihintpause,-zihpm,-zimop,-zk,-zkn,-zknd,-zkne,-zknh,-zkr,-zks,-zksed,-zksh,-zkt,-ztso,-zvbb,-zvbc,-zvfbfmin,-zvfbfwma,-zvfh,-zvfhmin,-zvkb,-zvkg,-zvkn,-zvknc,-zvkned,-zvkng,-zvknha,-zvknhb,-zvks,-zvksc,-zvksed,-zvksg,-zvksh,-zvkt,-zvl1024b,-zvl16384b,-zvl2048b,-zvl32768b,-zvl4096b,-zvl512b,-zvl65536b,-zvl8192b\" }\r\n```\r\n\r\nCommand/backtrace:\r\n```\r\n> /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt -passes=loop-vectorize reduced.ll -S\r\nopt: /scratch/tc-testing/tc-compiler-fuzz-trunk/llvm/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:7365: llvm::VectorizationFactor llvm::LoopVectorizationPlanner::computeBestVF(): Assertion `(BestFactor.Width == LegacyVF.Width || planContainsAdditionalSimplifications(getPlanFor(BestFactor.Width), BestFactor.Width, CostCtx, OrigLoop, CM)) && \" VPlan cost model and legacy cost model disagreed\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0. Program arguments: /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt -passes=loop-vectorize reduced.ll -S\r\n1. Running pass \"function(loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>)\" on module \"reduced.ll\"\r\n2. Running pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"d\"\r\n #0 0x000064cd5b412560 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x301e560)\r\n #1 0x000064cd5b40f96f llvm::sys::RunSignalHandlers() (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x301b96f)\r\n #2 0x000064cd5b40fac5 SignalHandler(int) Signals.cpp:0:0\r\n #3 0x000072ec5a042520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #4 0x000072ec5a0969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\r\n #5 0x000072ec5a0969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10\r\n #6 0x000072ec5a0969fc pthread_kill ./nptl/pthread_kill.c:89:10\r\n #7 0x000072ec5a042476 gsignal ./signal/../sysdeps/posix/raise.c:27:6\r\n #8 0x000072ec5a0287f3 abort ./stdlib/abort.c:81:7\r\n #9 0x000072ec5a02871b _nl_load_domain ./intl/loadmsgcat.c:1177:9\r\n#10 0x000072ec5a039e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n#11 0x000064cd5a3dd109 llvm::LoopVectorizationPlanner::computeBestVF() (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1fe9109)\r\n#12 0x000064cd5a3f3ccb llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1fffccb)\r\n#13 0x000064cd5a3f6ce1 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2002ce1)\r\n#14 0x000064cd5a3f7357 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2003357)\r\n#15 0x000064cd592541b6 llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xe601b6)\r\n#16 0x000064cd5b21d41f llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2e2941f)\r\n#17 0x000064cd59257346 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xe63346)\r\n#18 0x000064cd5b21c19b llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2e2819b)\r\n#19 0x000064cd592535e6 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xe5f5e6)\r\n#20 0x000064cd5b21a1dd llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2e261dd)\r\n#21 0x000064cd58a7c106 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x688106)\r\n#22 0x000064cd58a6de91 optMain (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x679e91)\r\n#23 0x000072ec5a029d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16\r\n#24 0x000072ec5a029e40 call_init ./csu/../csu/libc-start.c:128:20\r\n#25 0x000072ec5a029e40 __libc_start_main ./csu/../csu/libc-start.c:379:5\r\n#26 0x000064cd58a64245 _start (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x670245)\r\nzsh: IOT instruction (core dumped) /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt\r\n```\r\nhttps://godbolt.org/z/EzdEYKW7c\r\n\r\nFound via fuzzer\r\n\r\nRelated/prior issue: #106417\r\n\r\ncc @fhahn",
69
+ "author": "patrick-rivos",
70
+ "labels": [
71
+ "vectorizers",
72
+ "crash"
73
+ ],
74
+ "comments": []
75
+ },
76
+ "verified": true
77
+ }
dataset/106655.json ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "106655",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/106655",
4
+ "bug_type": "crash",
5
+ "base_commit": "2d5613afec0f4afeeb03cfd4edac556a65ad0eaf",
6
+ "knowledge_cutoff": "2024-08-30T03:04:59Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/SLPVectorizer"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "87a988e881ac92e3d87aae01dc632f33c1fb36aa",
12
+ "components": [
13
+ "SLPVectorizer"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
17
+ [
18
+ 13137,
19
+ 13143
20
+ ],
21
+ [
22
+ 13197,
23
+ 13203
24
+ ],
25
+ [
26
+ 13249,
27
+ 13255
28
+ ],
29
+ [
30
+ 13259,
31
+ 13265
32
+ ],
33
+ [
34
+ 13474,
35
+ 13480
36
+ ],
37
+ [
38
+ 13518,
39
+ 13524
40
+ ],
41
+ [
42
+ 13571,
43
+ 13577
44
+ ],
45
+ [
46
+ 13593,
47
+ 13599
48
+ ],
49
+ [
50
+ 13611,
51
+ 13617
52
+ ],
53
+ [
54
+ 13655,
55
+ 13661
56
+ ],
57
+ [
58
+ 13688,
59
+ 13694
60
+ ],
61
+ [
62
+ 13780,
63
+ 13786
64
+ ],
65
+ [
66
+ 13794,
67
+ 13800
68
+ ],
69
+ [
70
+ 13859,
71
+ 13865
72
+ ],
73
+ [
74
+ 13941,
75
+ 13947
76
+ ],
77
+ [
78
+ 14039,
79
+ 14044
80
+ ]
81
+ ]
82
+ },
83
+ "bug_location_funcname": {
84
+ "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
85
+ "BoUpSLP::vectorizeTree"
86
+ ]
87
+ }
88
+ },
89
+ "patch": "commit 87a988e881ac92e3d87aae01dc632f33c1fb36aa\nAuthor: Alexey Bataev <[email protected]>\nDate: Fri Aug 30 05:16:57 2024 -0700\n\n [SLP]Fix PR106655: Use FinalShuffle for alternate cast nodes.\n \n Need to use FinalShuffle function for all vectorized results to\n correctly produce vectorized value.\n \n Fixes https://github.com/llvm/llvm-project/issues/106655\n\ndiff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\nindex edb2567fa057..345b01b82c6a 100644\n--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n@@ -13137,7 +13137,7 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E, bool PostponedPHIs) {\n }\n \n bool IsReverseOrder = isReverseOrder(E->ReorderIndices);\n- auto FinalShuffle = [&](Value *V, const TreeEntry *E, VectorType *VecTy) {\n+ auto FinalShuffle = [&](Value *V, const TreeEntry *E) {\n ShuffleInstructionBuilder ShuffleBuilder(ScalarTy, Builder, *this);\n if (E->getOpcode() == Instruction::Store &&\n E->State == TreeEntry::Vectorize) {\n@@ -13197,7 +13197,7 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E, bool PostponedPHIs) {\n PH->getParent()->getFirstInsertionPt());\n Builder.SetCurrentDebugLocation(PH->getDebugLoc());\n \n- V = FinalShuffle(V, E, VecTy);\n+ V = FinalShuffle(V, E);\n \n E->VectorizedValue = V;\n if (PostponedPHIs)\n@@ -13249,7 +13249,7 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E, bool PostponedPHIs) {\n if (const TreeEntry *TE = getTreeEntry(V))\n V = TE->VectorizedValue;\n setInsertPointAfterBundle(E);\n- V = FinalShuffle(V, E, VecTy);\n+ V = FinalShuffle(V, E);\n E->VectorizedValue = V;\n return V;\n }\n@@ -13259,7 +13259,7 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E, bool PostponedPHIs) {\n Value *Ptr = LI->getPointerOperand();\n LoadInst *V = Builder.CreateAlignedLoad(VecTy, Ptr, LI->getAlign());\n Value *NewV = propagateMetadata(V, E->Scalars);\n- NewV = FinalShuffle(NewV, E, VecTy);\n+ NewV = FinalShuffle(NewV, E);\n E->VectorizedValue = NewV;\n return NewV;\n }\n@@ -13474,7 +13474,7 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E, bool PostponedPHIs) {\n Value *V = (VecOpcode != ShuffleOrOp && VecOpcode == Instruction::BitCast)\n ? InVec\n : Builder.CreateCast(VecOpcode, InVec, VecTy);\n- V = FinalShuffle(V, E, VecTy);\n+ V = FinalShuffle(V, E);\n \n E->VectorizedValue = V;\n ++NumVectorInstructions;\n@@ -13518,7 +13518,7 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E, bool PostponedPHIs) {\n propagateIRFlags(V, E->Scalars, VL0);\n // Do not cast for cmps.\n VecTy = cast<FixedVectorType>(V->getType());\n- V = FinalShuffle(V, E, VecTy);\n+ V = FinalShuffle(V, E);\n \n E->VectorizedValue = V;\n ++NumVectorInstructions;\n@@ -13571,7 +13571,7 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E, bool PostponedPHIs) {\n assert(getNumElements(Cond->getType()) == TrueNumElements &&\n \"Cannot vectorize Instruction::Select\");\n Value *V = Builder.CreateSelect(Cond, True, False);\n- V = FinalShuffle(V, E, VecTy);\n+ V = FinalShuffle(V, E);\n \n E->VectorizedValue = V;\n ++NumVectorInstructions;\n@@ -13593,7 +13593,7 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E, bool PostponedPHIs) {\n if (auto *I = dyn_cast<Instruction>(V))\n V = propagateMetadata(I, E->Scalars);\n \n- V = FinalShuffle(V, E, VecTy);\n+ V = FinalShuffle(V, E);\n \n E->VectorizedValue = V;\n ++NumVectorInstructions;\n@@ -13611,7 +13611,7 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E, bool PostponedPHIs) {\n }\n \n Value *V = Builder.CreateFreeze(Op);\n- V = FinalShuffle(V, E, VecTy);\n+ V = FinalShuffle(V, E);\n \n E->VectorizedValue = V;\n ++NumVectorInstructions;\n@@ -13655,7 +13655,7 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E, bool PostponedPHIs) {\n auto *CI = dyn_cast<ConstantInt>(Op);\n return CI && CI->getValue().countr_one() >= It->second.first;\n })) {\n- V = FinalShuffle(I == 0 ? RHS : LHS, E, VecTy);\n+ V = FinalShuffle(I == 0 ? RHS : LHS, E);\n E->VectorizedValue = V;\n ++NumVectorInstructions;\n return V;\n@@ -13688,7 +13688,7 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E, bool PostponedPHIs) {\n I->setHasNoUnsignedWrap(/*b=*/false);\n }\n \n- V = FinalShuffle(V, E, VecTy);\n+ V = FinalShuffle(V, E);\n \n E->VectorizedValue = V;\n ++NumVectorInstructions;\n@@ -13780,7 +13780,7 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E, bool PostponedPHIs) {\n }\n Value *V = propagateMetadata(NewLI, E->Scalars);\n \n- V = FinalShuffle(V, E, VecTy);\n+ V = FinalShuffle(V, E);\n E->VectorizedValue = V;\n ++NumVectorInstructions;\n return V;\n@@ -13794,7 +13794,7 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E, bool PostponedPHIs) {\n if (VecValue->getType() != VecTy)\n VecValue =\n Builder.CreateIntCast(VecValue, VecTy, GetOperandSignedness(0));\n- VecValue = FinalShuffle(VecValue, E, VecTy);\n+ VecValue = FinalShuffle(VecValue, E);\n \n Value *Ptr = SI->getPointerOperand();\n Instruction *ST;\n@@ -13859,7 +13859,7 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E, bool PostponedPHIs) {\n V = propagateMetadata(I, GEPs);\n }\n \n- V = FinalShuffle(V, E, VecTy);\n+ V = FinalShuffle(V, E);\n \n E->VectorizedValue = V;\n ++NumVectorInstructions;\n@@ -13941,7 +13941,7 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E, bool PostponedPHIs) {\n Value *V = Builder.CreateCall(CF, OpVecs, OpBundles);\n \n propagateIRFlags(V, E->Scalars, VL0);\n- V = FinalShuffle(V, E, VecTy);\n+ V = FinalShuffle(V, E);\n \n E->VectorizedValue = V;\n ++NumVectorInstructions;\n@@ -14039,6 +14039,7 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E, bool PostponedPHIs) {\n \"Expected same type as operand.\");\n if (auto *I = dyn_cast<Instruction>(LHS))\n LHS = propagateMetadata(I, E->Scalars);\n+ LHS = FinalShuffle(LHS, E);\n E->VectorizedValue = LHS;\n ++NumVectorInstructions;\n return LHS;\n",
90
+ "tests": [
91
+ {
92
+ "file": "llvm/test/Transforms/SLPVectorizer/resized-alt-shuffle-after-minbw.ll",
93
+ "commands": [
94
+ "opt -S --passes=slp-vectorizer -slp-vectorize-hor=false < %s"
95
+ ],
96
+ "tests": [
97
+ {
98
+ "test_name": "func",
99
+ "test_body": "define void @func(i32 %0) {\n %2 = shl i32 %0, 0\n %3 = sext i32 %2 to i64\n %4 = shl i32 0, 0\n %5 = sext i32 %4 to i64\n %6 = or i32 0, 0\n %7 = or i32 0, 0\n %8 = zext i32 %6 to i64\n %9 = zext i32 %7 to i64\n %10 = zext i32 0 to i64\n %11 = zext i32 0 to i64\n %12 = zext i32 0 to i64\n %13 = zext i32 0 to i64\n %14 = zext i32 0 to i64\n %15 = zext i32 0 to i64\n %16 = zext i32 0 to i64\n %17 = zext i32 0 to i64\n %18 = zext i32 0 to i64\n %19 = zext i32 0 to i64\n %20 = zext i32 0 to i64\n %21 = zext i32 0 to i64\n %22 = zext i32 0 to i64\n %23 = zext i32 0 to i64\n %24 = zext i32 0 to i64\n %25 = zext i32 0 to i64\n %26 = zext i32 0 to i64\n %27 = or i64 %3, 0\n %28 = or i64 %3, %8\n %29 = or i64 %3, %9\n %30 = or i64 %3, %10\n %31 = or i64 %3, %11\n %32 = or i64 %3, %12\n %33 = or i64 %3, %13\n %34 = or i64 %3, %14\n %35 = or i64 %3, %15\n %36 = or i64 %3, %16\n %37 = or i64 %3, %17\n %38 = or i64 %3, %18\n %39 = or i64 %3, %19\n %40 = or i64 %3, %20\n %41 = or i64 %3, %21\n %42 = or i64 %3, %22\n %43 = or i64 %3, %23\n %44 = or i64 %3, %24\n %45 = or i64 %3, %25\n %46 = or i64 %3, 0\n %47 = or i64 %3, 0\n %48 = or i64 %3, 0\n %49 = or i64 %3, 0\n %50 = or i64 %3, 0\n %51 = or i64 %3, 0\n %52 = or i64 %3, 0\n %53 = or i64 %3, 0\n %54 = or i64 %3, 0\n %55 = or i64 %3, 0\n %56 = or i64 %3, 0\n %57 = or i64 %3, 0\n %58 = or i64 %3, 0\n %59 = icmp slt i64 %28, 0\n %60 = icmp slt i64 %29, 0\n %61 = icmp slt i64 %30, 0\n %62 = icmp slt i64 %31, 0\n %63 = icmp slt i64 %32, 0\n %64 = icmp slt i64 %33, 0\n %65 = icmp slt i64 %34, 0\n %66 = icmp slt i64 %35, 0\n %67 = icmp slt i64 %36, 0\n %68 = icmp slt i64 %37, 0\n %69 = icmp slt i64 %38, 0\n %70 = icmp slt i64 %39, 0\n %71 = icmp slt i64 %40, 0\n %72 = icmp slt i64 %41, 0\n %73 = icmp slt i64 %42, 0\n %74 = icmp slt i64 %43, 0\n %75 = icmp slt i64 %44, 0\n %76 = icmp slt i64 %45, 0\n %77 = icmp slt i64 %46, 0\n %78 = icmp slt i64 %47, 0\n %79 = icmp slt i64 %48, 0\n %80 = icmp slt i64 %49, 0\n %81 = icmp slt i64 %50, 0\n %82 = icmp slt i64 %51, 0\n %83 = icmp slt i64 %52, 0\n %84 = icmp slt i64 %53, 0\n %85 = icmp slt i64 %54, 0\n %86 = icmp slt i64 %55, 0\n %87 = icmp slt i64 %56, 0\n %88 = icmp slt i64 %57, 0\n %89 = icmp slt i64 %58, 0\n %90 = and i1 false, %59\n %91 = and i1 false, %60\n %92 = and i1 false, %61\n %93 = and i1 false, %62\n %94 = and i1 false, %63\n %95 = and i1 false, %64\n %96 = and i1 false, %65\n %97 = and i1 false, %66\n %98 = and i1 false, %67\n %99 = and i1 false, %68\n %100 = and i1 false, %69\n %101 = and i1 false, %70\n %102 = and i1 false, %71\n %103 = and i1 false, %72\n %104 = and i1 false, %73\n %105 = and i1 false, %74\n %106 = and i1 false, %75\n %107 = and i1 false, %76\n %108 = icmp eq i32 %2, 0\n %109 = and i1 false, %77\n %110 = and i1 false, %78\n %111 = and i1 false, %79\n %112 = and i1 false, %80\n %113 = and i1 false, %81\n %114 = and i1 false, %82\n %115 = and i1 false, %83\n %116 = and i1 false, %84\n %117 = and i1 false, %85\n %118 = and i1 false, %86\n %119 = or i64 %5, %26\n %120 = getelementptr float, ptr addrspace(1) null, i64 %119\n %121 = icmp slt i64 %119, 0\n ret void\n}\n"
100
+ }
101
+ ]
102
+ }
103
+ ],
104
+ "issue": {
105
+ "title": "[SLP] Assertion `I >= 0 && I < (NumOpElts * 2) && \"Out-of-bounds shuffle mask element\"' failed.",
106
+ "body": "Live link: https://godbolt.org/z/nePMscjGr\r\n\r\nTest case:\r\n\r\n```ll\r\ndefine void @func(i32 %0) {\r\n %2 = shl i32 %0, 0\r\n %3 = sext i32 %2 to i64\r\n %4 = shl i32 0, 0\r\n %5 = sext i32 %4 to i64\r\n %6 = or i32 0, 0\r\n %7 = or i32 0, 0\r\n %8 = zext i32 %6 to i64\r\n %9 = zext i32 %7 to i64\r\n %10 = zext i32 0 to i64\r\n %11 = zext i32 0 to i64\r\n %12 = zext i32 0 to i64\r\n %13 = zext i32 0 to i64\r\n %14 = zext i32 0 to i64\r\n %15 = zext i32 0 to i64\r\n %16 = zext i32 0 to i64\r\n %17 = zext i32 0 to i64\r\n %18 = zext i32 0 to i64\r\n %19 = zext i32 0 to i64\r\n %20 = zext i32 0 to i64\r\n %21 = zext i32 0 to i64\r\n %22 = zext i32 0 to i64\r\n %23 = zext i32 0 to i64\r\n %24 = zext i32 0 to i64\r\n %25 = zext i32 0 to i64\r\n %26 = zext i32 0 to i64\r\n %27 = or i64 %3, 0\r\n %28 = or i64 %3, %8\r\n %29 = or i64 %3, %9\r\n %30 = or i64 %3, %10\r\n %31 = or i64 %3, %11\r\n %32 = or i64 %3, %12\r\n %33 = or i64 %3, %13\r\n %34 = or i64 %3, %14\r\n %35 = or i64 %3, %15\r\n %36 = or i64 %3, %16\r\n %37 = or i64 %3, %17\r\n %38 = or i64 %3, %18\r\n %39 = or i64 %3, %19\r\n %40 = or i64 %3, %20\r\n %41 = or i64 %3, %21\r\n %42 = or i64 %3, %22\r\n %43 = or i64 %3, %23\r\n %44 = or i64 %3, %24\r\n %45 = or i64 %3, %25\r\n %46 = or i64 %3, 0\r\n %47 = or i64 %3, 0\r\n %48 = or i64 %3, 0\r\n %49 = or i64 %3, 0\r\n %50 = or i64 %3, 0\r\n %51 = or i64 %3, 0\r\n %52 = or i64 %3, 0\r\n %53 = or i64 %3, 0\r\n %54 = or i64 %3, 0\r\n %55 = or i64 %3, 0\r\n %56 = or i64 %3, 0\r\n %57 = or i64 %3, 0\r\n %58 = or i64 %3, 0\r\n %59 = icmp slt i64 %28, 0\r\n %60 = icmp slt i64 %29, 0\r\n %61 = icmp slt i64 %30, 0\r\n %62 = icmp slt i64 %31, 0\r\n %63 = icmp slt i64 %32, 0\r\n %64 = icmp slt i64 %33, 0\r\n %65 = icmp slt i64 %34, 0\r\n %66 = icmp slt i64 %35, 0\r\n %67 = icmp slt i64 %36, 0\r\n %68 = icmp slt i64 %37, 0\r\n %69 = icmp slt i64 %38, 0\r\n %70 = icmp slt i64 %39, 0\r\n %71 = icmp slt i64 %40, 0\r\n %72 = icmp slt i64 %41, 0\r\n %73 = icmp slt i64 %42, 0\r\n %74 = icmp slt i64 %43, 0\r\n %75 = icmp slt i64 %44, 0\r\n %76 = icmp slt i64 %45, 0\r\n %77 = icmp slt i64 %46, 0\r\n %78 = icmp slt i64 %47, 0\r\n %79 = icmp slt i64 %48, 0\r\n %80 = icmp slt i64 %49, 0\r\n %81 = icmp slt i64 %50, 0\r\n %82 = icmp slt i64 %51, 0\r\n %83 = icmp slt i64 %52, 0\r\n %84 = icmp slt i64 %53, 0\r\n %85 = icmp slt i64 %54, 0\r\n %86 = icmp slt i64 %55, 0\r\n %87 = icmp slt i64 %56, 0\r\n %88 = icmp slt i64 %57, 0\r\n %89 = icmp slt i64 %58, 0\r\n %90 = and i1 false, %59\r\n %91 = and i1 false, %60\r\n %92 = and i1 false, %61\r\n %93 = and i1 false, %62\r\n %94 = and i1 false, %63\r\n %95 = and i1 false, %64\r\n %96 = and i1 false, %65\r\n %97 = and i1 false, %66\r\n %98 = and i1 false, %67\r\n %99 = and i1 false, %68\r\n %100 = and i1 false, %69\r\n %101 = and i1 false, %70\r\n %102 = and i1 false, %71\r\n %103 = and i1 false, %72\r\n %104 = and i1 false, %73\r\n %105 = and i1 false, %74\r\n %106 = and i1 false, %75\r\n %107 = and i1 false, %76\r\n %108 = icmp eq i32 %2, 0\r\n %109 = and i1 false, %77\r\n %110 = and i1 false, %78\r\n %111 = and i1 false, %79\r\n %112 = and i1 false, %80\r\n %113 = and i1 false, %81\r\n %114 = and i1 false, %82\r\n %115 = and i1 false, %83\r\n %116 = and i1 false, %84\r\n %117 = and i1 false, %85\r\n %118 = and i1 false, %86\r\n %119 = or i64 %5, %26\r\n %120 = getelementptr float, ptr addrspace(1) null, i64 %119\r\n %121 = icmp slt i64 %119, 0\r\n ret void\r\n}\r\n```\r\n\r\nRunning via `opt --passes=slp-vectorizer -slp-vectorize-hor=false`:\r\n\r\n```sh\r\nopt: /root/llvm-project/llvm/lib/IR/Instructions.cpp:1853: bool isSingleSourceMaskImpl(llvm::ArrayRef<int>, int): Assertion `I >= 0 && I < (NumOpElts * 2) && \"Out-of-bounds shuffle mask element\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S --passes=slp-vectorizer -slp-vectorize-hor=false <source>\r\n1.\tRunning pass \"function(slp-vectorizer)\" on module \"<source>\"\r\n2.\tRunning pass \"slp-vectorizer\" on function \"func\"\r\n #0 0x0000000004fa4138 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4fa4138)\r\n #1 0x0000000004fa18ac SignalHandler(int) Signals.cpp:0:0\r\n #2 0x000073f701e42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #3 0x000073f701e969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\r\n #4 0x000073f701e42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\r\n #5 0x000073f701e287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\r\n #6 0x000073f701e2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\r\n #7 0x000073f701e39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n #8 0x0000000004d097f6 isSingleSourceMaskImpl(llvm::ArrayRef<int>, int) Instructions.cpp:0:0\r\n #9 0x0000000004d1097a llvm::ShuffleVectorInst::isExtractSubvectorMask(llvm::ArrayRef<int>, int, int&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4d1097a)\r\n#10 0x000000000400fc53 (anonymous namespace)::BaseShuffleAnalysis::isIdentityMask(llvm::ArrayRef<int>, llvm::FixedVectorType const*, bool) SLPVectorizer.cpp:0:0\r\n#11 0x0000000004043781 (anonymous namespace)::BaseShuffleAnalysis::peekThroughShuffles(llvm::Value*&, llvm::SmallVectorImpl<int>&, bool) SLPVectorizer.cpp:0:0\r\n#12 0x000000000405bd21 llvm::Value* (anonymous namespace)::BaseShuffleAnalysis::createShuffle<llvm::Value*, llvm::slpvectorizer::BoUpSLP::ShuffleInstructionBuilder::ShuffleIRBuilder>(llvm::Value*, llvm::Value*, llvm::ArrayRef<int>, llvm::slpvectorizer::BoUpSLP::ShuffleInstructionBuilder::ShuffleIRBuilder&) SLPVectorizer.cpp:0:0\r\n#13 0x000000000405c50a llvm::slpvectorizer::BoUpSLP::ShuffleInstructionBuilder::createShuffle(llvm::Value*, llvm::Value*, llvm::ArrayRef<int>) (.isra.0) SLPVectorizer.cpp:0:0\r\n#14 0x000000000405ce73 llvm::slpvectorizer::BoUpSLP::ShuffleInstructionBuilder::finalize(llvm::ArrayRef<int>, llvm::ArrayRef<std::pair<llvm::slpvectorizer::BoUpSLP::TreeEntry const*, unsigned int>>, unsigned int, llvm::function_ref<void (llvm::Value*&, llvm::SmallVectorImpl<int>&)>) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x405ce73)\r\n#15 0x000000000405d3d9 llvm::slpvectorizer::BoUpSLP::vectorizeOperand(llvm::slpvectorizer::BoUpSLP::TreeEntry*, unsigned int, bool)::'lambda1'(llvm::Value*, llvm::ArrayRef<int>)::operator()(llvm::Value*, llvm::ArrayRef<int>) const SLPVectorizer.cpp:0:0\r\n#16 0x0000000004095c0a llvm::slpvectorizer::BoUpSLP::vectorizeOperand(llvm::slpvectorizer::BoUpSLP::TreeEntry*, unsigned int, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4095c0a)\r\n#17 0x0000000004097032 llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::slpvectorizer::BoUpSLP::TreeEntry*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4097032)\r\n#18 0x0000000004095aa8 llvm::slpvectorizer::BoUpSLP::vectorizeOperand(llvm::slpvectorizer::BoUpSLP::TreeEntry*, unsigned int, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4095aa8)\r\n#19 0x0000000004097294 llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::slpvectorizer::BoUpSLP::TreeEntry*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4097294)\r\n#20 0x00000000040b31cc llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::MapVector<llvm::Value*, llvm::SmallVector<llvm::Instruction*, 2u>, llvm::DenseMap<llvm::Value*, unsigned int, llvm::DenseMapInfo<llvm::Value*, void>, llvm::detail::DenseMapPair<llvm::Value*, unsigned int>>, llvm::SmallVector<std::pair<llvm::Value*, llvm::SmallVector<llvm::Instruction*, 2u>>, 0u>> const&, llvm::SmallVectorImpl<std::pair<llvm::Value*, llvm::Value*>>&, llvm::Instruction*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x40b31cc)\r\n#21 0x00000000040b6d45 llvm::slpvectorizer::BoUpSLP::vectorizeTree() (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x40b6d45)\r\n#22 0x00000000040c3b2a llvm::SLPVectorizerPass::tryToVectorizeList(llvm::ArrayRef<llvm::Value*>, llvm::slpvectorizer::BoUpSLP&, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x40c3b2a)\r\n#23 0x00000000040c78a7 bool llvm::SLPVectorizerPass::vectorizeCmpInsts<std::reverse_iterator<llvm::CmpInst* const*>>(llvm::iterator_range<std::reverse_iterator<llvm::CmpInst* const*>>, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x40c78a7)\r\n#24 0x00000000040cb5d0 llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x40cb5d0)\r\n#25 0x00000000040d1d49 llvm::SLPVectorizerPass::runImpl(llvm::Function&, llvm::ScalarEvolution*, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo*, llvm::AAResults*, llvm::LoopInfo*, llvm::DominatorTree*, llvm::AssumptionCache*, llvm::DemandedBits*, llvm::OptimizationRemarkEmitter*) (.part.0) SLPVectorizer.cpp:0:0\r\n#26 0x00000000040d29fb llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x40d29fb)\r\n...\r\n```\r\n\r\nBisected to f3d2609af3031ddb54030548e86335f295cf49ca / https://github.com/llvm/llvm-project/pull/104144",
107
+ "author": "rupprecht",
108
+ "labels": [
109
+ "llvm:SLPVectorizer",
110
+ "crash-on-valid"
111
+ ],
112
+ "comments": [
113
+ {
114
+ "author": "dklimkin",
115
+ "body": "Confirmed this resolved the issue. Thanks!"
116
+ }
117
+ ]
118
+ },
119
+ "verified": true
120
+ }
dataset/106667.json ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "106667",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/106667",
4
+ "bug_type": "crash",
5
+ "base_commit": "5500e21942f7047344b6fee62d3e08c0ba2f9182",
6
+ "knowledge_cutoff": "2024-08-30T05:59:16Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/SLPVectorizer"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "a4aa6bc8fc2130761b8db5db4748059127662785",
12
+ "components": [
13
+ "SLPVectorizer"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
17
+ [
18
+ 2864,
19
+ 2869
20
+ ],
21
+ [
22
+ 6964,
23
+ 6969
24
+ ],
25
+ [
26
+ 7095,
27
+ 7149
28
+ ],
29
+ [
30
+ 9362,
31
+ 9383
32
+ ],
33
+ [
34
+ 12521,
35
+ 12530
36
+ ],
37
+ [
38
+ 12532,
39
+ 12640
40
+ ]
41
+ ]
42
+ },
43
+ "bug_location_funcname": {
44
+ "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
45
+ "BoUpSLP::buildTree_rec",
46
+ "BoUpSLP::getOperandEntry",
47
+ "BoUpSLP::vectorizeOperand"
48
+ ]
49
+ }
50
+ },
51
+ "patch": "commit a4aa6bc8fc2130761b8db5db4748059127662785\nAuthor: Alexey Bataev <[email protected]>\nDate: Fri Aug 30 10:17:31 2024 -0700\n\n [SLP]Fix PR106667: carefully look for operand nodes.\n \n If the operand node has the same scalars as one of the vectorized nodes,\n the compiler could miss this and incorrectly request minbitwidth data\n for the wrong node. It may lead to a compiler crash, because the\n vectorized node might have different minbw result.\n \n Fixes https://github.com/llvm/llvm-project/issues/106667\n\ndiff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\nindex 4c0a1c4c094b..e9785ef9ded2 100644\n--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n@@ -2864,6 +2864,12 @@ private:\n /// avoid issues with def-use order.\n Value *vectorizeTree(TreeEntry *E, bool PostponedPHIs);\n \n+ TreeEntry *getMatchedVectorizedOperand(const TreeEntry *E, unsigned NodeIdx);\n+ const TreeEntry *getMatchedVectorizedOperand(const TreeEntry *E,\n+ unsigned NodeIdx) const {\n+ return const_cast<BoUpSLP *>(this)->getMatchedVectorizedOperand(E, NodeIdx);\n+ }\n+\n /// Vectorize a single entry in the tree, the \\p Idx-th operand of the entry\n /// \\p E.\n /// \\param PostponedPHIs true, if need to postpone emission of phi nodes to\n@@ -6964,6 +6970,55 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth,\n }\n }\n \n+ // Check if this is a duplicate of another entry.\n+ if (TreeEntry *E = getTreeEntry(S.OpValue)) {\n+ LLVM_DEBUG(dbgs() << \"SLP: \\tChecking bundle: \" << *S.OpValue << \".\\n\");\n+ if (!E->isSame(VL)) {\n+ auto It = MultiNodeScalars.find(S.OpValue);\n+ if (It != MultiNodeScalars.end()) {\n+ auto *TEIt = find_if(It->getSecond(),\n+ [&](TreeEntry *ME) { return ME->isSame(VL); });\n+ if (TEIt != It->getSecond().end())\n+ E = *TEIt;\n+ else\n+ E = nullptr;\n+ } else {\n+ E = nullptr;\n+ }\n+ }\n+ if (!E) {\n+ if (!doesNotNeedToBeScheduled(S.OpValue)) {\n+ LLVM_DEBUG(dbgs() << \"SLP: Gathering due to partial overlap.\\n\");\n+ if (TryToFindDuplicates(S))\n+ newTreeEntry(VL, std::nullopt /*not vectorized*/, S, UserTreeIdx,\n+ ReuseShuffleIndices);\n+ return;\n+ }\n+ SmallPtrSet<const TreeEntry *, 4> Nodes;\n+ Nodes.insert(getTreeEntry(S.OpValue));\n+ for (const TreeEntry *E : MultiNodeScalars.lookup(S.OpValue))\n+ Nodes.insert(E);\n+ SmallPtrSet<Value *, 8> Values(VL.begin(), VL.end());\n+ if (any_of(Nodes, [&](const TreeEntry *E) {\n+ return all_of(E->Scalars,\n+ [&](Value *V) { return Values.contains(V); });\n+ })) {\n+ LLVM_DEBUG(dbgs() << \"SLP: Gathering due to full overlap.\\n\");\n+ if (TryToFindDuplicates(S))\n+ newTreeEntry(VL, std::nullopt /*not vectorized*/, S, UserTreeIdx,\n+ ReuseShuffleIndices);\n+ return;\n+ }\n+ } else {\n+ // Record the reuse of the tree node. FIXME, currently this is only used\n+ // to properly draw the graph rather than for the actual vectorization.\n+ E->UserTreeIndices.push_back(UserTreeIdx);\n+ LLVM_DEBUG(dbgs() << \"SLP: Perfect diamond merge at \" << *S.OpValue\n+ << \".\\n\");\n+ return;\n+ }\n+ }\n+\n // Gather if we hit the RecursionMaxDepth, unless this is a load (or z/sext of\n // a load), in which case peek through to include it in the tree, without\n // ballooning over-budget.\n@@ -7095,55 +7150,6 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth,\n // We now know that this is a vector of instructions of the same type from\n // the same block.\n \n- // Check if this is a duplicate of another entry.\n- if (TreeEntry *E = getTreeEntry(S.OpValue)) {\n- LLVM_DEBUG(dbgs() << \"SLP: \\tChecking bundle: \" << *S.OpValue << \".\\n\");\n- if (!E->isSame(VL)) {\n- auto It = MultiNodeScalars.find(S.OpValue);\n- if (It != MultiNodeScalars.end()) {\n- auto *TEIt = find_if(It->getSecond(),\n- [&](TreeEntry *ME) { return ME->isSame(VL); });\n- if (TEIt != It->getSecond().end())\n- E = *TEIt;\n- else\n- E = nullptr;\n- } else {\n- E = nullptr;\n- }\n- }\n- if (!E) {\n- if (!doesNotNeedToBeScheduled(S.OpValue)) {\n- LLVM_DEBUG(dbgs() << \"SLP: Gathering due to partial overlap.\\n\");\n- if (TryToFindDuplicates(S))\n- newTreeEntry(VL, std::nullopt /*not vectorized*/, S, UserTreeIdx,\n- ReuseShuffleIndices);\n- return;\n- }\n- SmallPtrSet<const TreeEntry *, 4> Nodes;\n- Nodes.insert(getTreeEntry(S.OpValue));\n- for (const TreeEntry *E : MultiNodeScalars.lookup(S.OpValue))\n- Nodes.insert(E);\n- SmallPtrSet<Value *, 8> Values(VL.begin(), VL.end());\n- if (any_of(Nodes, [&](const TreeEntry *E) {\n- return all_of(E->Scalars,\n- [&](Value *V) { return Values.contains(V); });\n- })) {\n- LLVM_DEBUG(dbgs() << \"SLP: Gathering due to full overlap.\\n\");\n- if (TryToFindDuplicates(S))\n- newTreeEntry(VL, std::nullopt /*not vectorized*/, S, UserTreeIdx,\n- ReuseShuffleIndices);\n- return;\n- }\n- } else {\n- // Record the reuse of the tree node. FIXME, currently this is only used\n- // to properly draw the graph rather than for the actual vectorization.\n- E->UserTreeIndices.push_back(UserTreeIdx);\n- LLVM_DEBUG(dbgs() << \"SLP: Perfect diamond merge at \" << *S.OpValue\n- << \".\\n\");\n- return;\n- }\n- }\n-\n // Check that none of the instructions in the bundle are already in the tree.\n for (Value *V : VL) {\n if ((!IsScatterVectorizeUserTE && !isa<Instruction>(V)) ||\n@@ -9362,22 +9368,8 @@ public:\n \n const BoUpSLP::TreeEntry *BoUpSLP::getOperandEntry(const TreeEntry *E,\n unsigned Idx) const {\n- Value *Op = E->getOperand(Idx).front();\n- if (const TreeEntry *TE = getTreeEntry(Op)) {\n- if (find_if(TE->UserTreeIndices, [&](const EdgeInfo &EI) {\n- return EI.EdgeIdx == Idx && EI.UserTE == E;\n- }) != TE->UserTreeIndices.end())\n- return TE;\n- auto MIt = MultiNodeScalars.find(Op);\n- if (MIt != MultiNodeScalars.end()) {\n- for (const TreeEntry *TE : MIt->second) {\n- if (find_if(TE->UserTreeIndices, [&](const EdgeInfo &EI) {\n- return EI.EdgeIdx == Idx && EI.UserTE == E;\n- }) != TE->UserTreeIndices.end())\n- return TE;\n- }\n- }\n- }\n+ if (const TreeEntry *VE = getMatchedVectorizedOperand(E, Idx))\n+ return VE;\n const auto *It =\n find_if(VectorizableTree, [&](const std::unique_ptr<TreeEntry> &TE) {\n return TE->isGather() &&\n@@ -12521,10 +12513,9 @@ public:\n }\n };\n \n-Value *BoUpSLP::vectorizeOperand(TreeEntry *E, unsigned NodeIdx,\n- bool PostponedPHIs) {\n- ValueList &VL = E->getOperand(NodeIdx);\n- const unsigned VF = VL.size();\n+BoUpSLP::TreeEntry *BoUpSLP::getMatchedVectorizedOperand(const TreeEntry *E,\n+ unsigned NodeIdx) {\n+ ArrayRef<Value *> VL = E->getOperand(NodeIdx);\n InstructionsState S = getSameOpcode(VL, *TLI);\n // Special processing for GEPs bundle, which may include non-gep values.\n if (!S.getOpcode() && VL.front()->getType()->isPointerTy()) {\n@@ -12532,109 +12523,113 @@ Value *BoUpSLP::vectorizeOperand(TreeEntry *E, unsigned NodeIdx,\n if (It != VL.end())\n S = getSameOpcode(*It, *TLI);\n }\n- if (S.getOpcode()) {\n- auto CheckSameVE = [&](const TreeEntry *VE) {\n- return VE->isSame(VL) &&\n- (any_of(VE->UserTreeIndices,\n- [E, NodeIdx](const EdgeInfo &EI) {\n- return EI.UserTE == E && EI.EdgeIdx == NodeIdx;\n- }) ||\n- any_of(VectorizableTree,\n- [E, NodeIdx, VE](const std::unique_ptr<TreeEntry> &TE) {\n- return TE->isOperandGatherNode({E, NodeIdx}) &&\n- VE->isSame(TE->Scalars);\n- }));\n+ if (!S.getOpcode())\n+ return nullptr;\n+ auto CheckSameVE = [&](const TreeEntry *VE) {\n+ return VE->isSame(VL) &&\n+ (any_of(VE->UserTreeIndices,\n+ [E, NodeIdx](const EdgeInfo &EI) {\n+ return EI.UserTE == E && EI.EdgeIdx == NodeIdx;\n+ }) ||\n+ any_of(VectorizableTree,\n+ [E, NodeIdx, VE](const std::unique_ptr<TreeEntry> &TE) {\n+ return TE->isOperandGatherNode(\n+ {const_cast<TreeEntry *>(E), NodeIdx}) &&\n+ VE->isSame(TE->Scalars);\n+ }));\n+ };\n+ TreeEntry *VE = getTreeEntry(S.OpValue);\n+ if (VE && CheckSameVE(VE))\n+ return VE;\n+ auto It = MultiNodeScalars.find(S.OpValue);\n+ if (It != MultiNodeScalars.end()) {\n+ auto *I = find_if(It->getSecond(), [&](const TreeEntry *TE) {\n+ return TE != VE && CheckSameVE(TE);\n+ });\n+ if (I != It->getSecond().end())\n+ return *I;\n+ }\n+ return nullptr;\n+}\n+\n+Value *BoUpSLP::vectorizeOperand(TreeEntry *E, unsigned NodeIdx,\n+ bool PostponedPHIs) {\n+ ValueList &VL = E->getOperand(NodeIdx);\n+ const unsigned VF = VL.size();\n+ if (TreeEntry *VE = getMatchedVectorizedOperand(E, NodeIdx)) {\n+ auto FinalShuffle = [&](Value *V, ArrayRef<int> Mask) {\n+ // V may be affected by MinBWs.\n+ // We want ShuffleInstructionBuilder to correctly support REVEC. The key\n+ // factor is the number of elements, not their type.\n+ Type *ScalarTy = cast<VectorType>(V->getType())->getElementType();\n+ unsigned NumElements = getNumElements(VL.front()->getType());\n+ ShuffleInstructionBuilder ShuffleBuilder(\n+ NumElements != 1 ? FixedVectorType::get(ScalarTy, NumElements)\n+ : ScalarTy,\n+ Builder, *this);\n+ ShuffleBuilder.add(V, Mask);\n+ SmallVector<std::pair<const TreeEntry *, unsigned>> SubVectors(\n+ E->CombinedEntriesWithIndices.size());\n+ transform(E->CombinedEntriesWithIndices, SubVectors.begin(),\n+ [&](const auto &P) {\n+ return std::make_pair(VectorizableTree[P.first].get(),\n+ P.second);\n+ });\n+ return ShuffleBuilder.finalize(std::nullopt, SubVectors);\n };\n- TreeEntry *VE = getTreeEntry(S.OpValue);\n- bool IsSameVE = VE && CheckSameVE(VE);\n- if (!IsSameVE) {\n- auto It = MultiNodeScalars.find(S.OpValue);\n- if (It != MultiNodeScalars.end()) {\n- auto *I = find_if(It->getSecond(), [&](const TreeEntry *TE) {\n- return TE != VE && CheckSameVE(TE);\n- });\n- if (I != It->getSecond().end()) {\n- VE = *I;\n- IsSameVE = true;\n- }\n- }\n- }\n- if (IsSameVE) {\n- auto FinalShuffle = [&](Value *V, ArrayRef<int> Mask) {\n- // V may be affected by MinBWs.\n- // We want ShuffleInstructionBuilder to correctly support REVEC. The key\n- // factor is the number of elements, not their type.\n- Type *ScalarTy = cast<VectorType>(V->getType())->getElementType();\n- unsigned NumElements = getNumElements(VL.front()->getType());\n- ShuffleInstructionBuilder ShuffleBuilder(\n- NumElements != 1 ? FixedVectorType::get(ScalarTy, NumElements)\n- : ScalarTy,\n- Builder, *this);\n- ShuffleBuilder.add(V, Mask);\n- SmallVector<std::pair<const TreeEntry *, unsigned>> SubVectors(\n- E->CombinedEntriesWithIndices.size());\n- transform(E->CombinedEntriesWithIndices, SubVectors.begin(),\n- [&](const auto &P) {\n- return std::make_pair(VectorizableTree[P.first].get(),\n- P.second);\n- });\n- return ShuffleBuilder.finalize(std::nullopt, SubVectors);\n- };\n- Value *V = vectorizeTree(VE, PostponedPHIs);\n- if (VF * getNumElements(VL[0]->getType()) !=\n- cast<FixedVectorType>(V->getType())->getNumElements()) {\n- if (!VE->ReuseShuffleIndices.empty()) {\n- // Reshuffle to get only unique values.\n- // If some of the scalars are duplicated in the vectorization\n- // tree entry, we do not vectorize them but instead generate a\n- // mask for the reuses. But if there are several users of the\n- // same entry, they may have different vectorization factors.\n- // This is especially important for PHI nodes. In this case, we\n- // need to adapt the resulting instruction for the user\n- // vectorization factor and have to reshuffle it again to take\n- // only unique elements of the vector. Without this code the\n- // function incorrectly returns reduced vector instruction with\n- // the same elements, not with the unique ones.\n-\n- // block:\n- // %phi = phi <2 x > { .., %entry} {%shuffle, %block}\n- // %2 = shuffle <2 x > %phi, poison, <4 x > <1, 1, 0, 0>\n- // ... (use %2)\n- // %shuffle = shuffle <2 x> %2, poison, <2 x> {2, 0}\n- // br %block\n- SmallVector<int> Mask(VF, PoisonMaskElem);\n- for (auto [I, V] : enumerate(VL)) {\n- if (isa<PoisonValue>(V))\n- continue;\n- Mask[I] = VE->findLaneForValue(V);\n- }\n- V = FinalShuffle(V, Mask);\n- } else {\n- assert(VF < cast<FixedVectorType>(V->getType())->getNumElements() &&\n- \"Expected vectorization factor less \"\n- \"than original vector size.\");\n- SmallVector<int> UniformMask(VF, 0);\n- std::iota(UniformMask.begin(), UniformMask.end(), 0);\n- V = FinalShuffle(V, UniformMask);\n+ Value *V = vectorizeTree(VE, PostponedPHIs);\n+ if (VF * getNumElements(VL[0]->getType()) !=\n+ cast<FixedVectorType>(V->getType())->getNumElements()) {\n+ if (!VE->ReuseShuffleIndices.empty()) {\n+ // Reshuffle to get only unique values.\n+ // If some of the scalars are duplicated in the vectorization\n+ // tree entry, we do not vectorize them but instead generate a\n+ // mask for the reuses. But if there are several users of the\n+ // same entry, they may have different vectorization factors.\n+ // This is especially important for PHI nodes. In this case, we\n+ // need to adapt the resulting instruction for the user\n+ // vectorization factor and have to reshuffle it again to take\n+ // only unique elements of the vector. Without this code the\n+ // function incorrectly returns reduced vector instruction with\n+ // the same elements, not with the unique ones.\n+\n+ // block:\n+ // %phi = phi <2 x > { .., %entry} {%shuffle, %block}\n+ // %2 = shuffle <2 x > %phi, poison, <4 x > <1, 1, 0, 0>\n+ // ... (use %2)\n+ // %shuffle = shuffle <2 x> %2, poison, <2 x> {2, 0}\n+ // br %block\n+ SmallVector<int> Mask(VF, PoisonMaskElem);\n+ for (auto [I, V] : enumerate(VL)) {\n+ if (isa<PoisonValue>(V))\n+ continue;\n+ Mask[I] = VE->findLaneForValue(V);\n }\n- }\n- // Need to update the operand gather node, if actually the operand is not a\n- // vectorized node, but the buildvector/gather node, which matches one of\n- // the vectorized nodes.\n- if (find_if(VE->UserTreeIndices, [&](const EdgeInfo &EI) {\n- return EI.UserTE == E && EI.EdgeIdx == NodeIdx;\n- }) == VE->UserTreeIndices.end()) {\n- auto *It = find_if(\n- VectorizableTree, [&](const std::unique_ptr<TreeEntry> &TE) {\n- return TE->isGather() &&\n- TE->UserTreeIndices.front().UserTE == E &&\n- TE->UserTreeIndices.front().EdgeIdx == NodeIdx;\n- });\n- assert(It != VectorizableTree.end() && \"Expected gather node operand.\");\n- (*It)->VectorizedValue = V;\n- }\n- return V;\n+ V = FinalShuffle(V, Mask);\n+ } else {\n+ assert(VF < cast<FixedVectorType>(V->getType())->getNumElements() &&\n+ \"Expected vectorization factor less \"\n+ \"than original vector size.\");\n+ SmallVector<int> UniformMask(VF, 0);\n+ std::iota(UniformMask.begin(), UniformMask.end(), 0);\n+ V = FinalShuffle(V, UniformMask);\n+ }\n+ }\n+ // Need to update the operand gather node, if actually the operand is not a\n+ // vectorized node, but the buildvector/gather node, which matches one of\n+ // the vectorized nodes.\n+ if (find_if(VE->UserTreeIndices, [&](const EdgeInfo &EI) {\n+ return EI.UserTE == E && EI.EdgeIdx == NodeIdx;\n+ }) == VE->UserTreeIndices.end()) {\n+ auto *It =\n+ find_if(VectorizableTree, [&](const std::unique_ptr<TreeEntry> &TE) {\n+ return TE->isGather() && TE->UserTreeIndices.front().UserTE == E &&\n+ TE->UserTreeIndices.front().EdgeIdx == NodeIdx;\n+ });\n+ assert(It != VectorizableTree.end() && \"Expected gather node operand.\");\n+ (*It)->VectorizedValue = V;\n }\n+ return V;\n }\n \n // Find the corresponding gather entry and vectorize it.\n",
52
+ "tests": [
53
+ {
54
+ "file": "llvm/test/Transforms/SLPVectorizer/X86/multi-nodes-bv-vectorized.ll",
55
+ "commands": [
56
+ "opt -passes=slp-vectorizer -S -mtriple=x86_64-unknown-linux-gnu < %s"
57
+ ],
58
+ "tests": [
59
+ {
60
+ "test_name": "test",
61
+ "test_body": "define void @test(ptr %p) {\nentry:\n %conv548.2.i.13 = zext i32 0 to i64\n %and551.2.i.13 = and i64 0, %conv548.2.i.13\n %conv548.3.i.13 = zext i32 0 to i64\n %and551.3.i.13 = and i64 0, %conv548.3.i.13\n %0 = trunc i64 %and551.2.i.13 to i32\n %conv54.2.i.14 = and i32 %0, 0\n %conv548.2.i.14 = zext i32 %conv54.2.i.14 to i64\n %and551.2.i.14 = and i64 %and551.2.i.13, %conv548.2.i.14\n %1 = trunc i64 %and551.3.i.13 to i32\n %conv54.3.i.14 = and i32 %1, 0\n %conv548.3.i.14 = zext i32 %conv54.3.i.14 to i64\n %and551.3.i.14 = and i64 %and551.3.i.13, %conv548.3.i.14\n %and551.2.i.15 = and i64 %and551.2.i.14, 0\n %and551.3.i.15 = and i64 %and551.3.i.14, 0\n %and551.2.i.16 = and i64 %and551.2.i.15, 0\n %and551.3.i.16 = and i64 %and551.3.i.15, 0\n %and551.2.i.17 = and i64 %and551.2.i.16, 0\n %and551.3.i.17 = and i64 %and551.3.i.16, 0\n %and551.2.i.18 = and i64 %and551.2.i.17, 0\n %and551.3.i.18 = and i64 %and551.3.i.17, 0\n %and551.2.i.19 = and i64 %and551.2.i.18, 0\n %and551.3.i.19 = and i64 %and551.3.i.18, 0\n %and551.2.i.20 = and i64 %and551.2.i.19, 0\n %and551.3.i.20 = and i64 %and551.3.i.19, 0\n %and551.2.i.21 = and i64 %and551.2.i.20, 0\n %and551.3.i.21 = and i64 %and551.3.i.20, 0\n %gep1 = getelementptr inbounds i8, ptr %p, i64 16\n %gep2 = getelementptr inbounds i8, ptr %p, i64 24\n store i64 %and551.2.i.21, ptr %gep1, align 16\n store i64 %and551.3.i.21, ptr %gep2, align 8\n ret void\n}\n"
62
+ }
63
+ ]
64
+ }
65
+ ],
66
+ "issue": {
67
+ "title": "[SLPVectorizer] Assertion `CastInst::castIsValid(opc, C, Ty) && \"Invalid constantexpr cast!\"' failed.",
68
+ "body": "Reproducer: https://godbolt.org/z/PeoMv3Tsn\r\n```\r\n; bin/opt -passes=slp-vectorizer reduced.ll -S\r\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\r\ntarget triple = \"x86_64-unknown-linux-gnu\"\r\n\r\ndefine void @main(ptr %p) {\r\nentry:\r\n %conv548.2.i.13 = zext i32 0 to i64\r\n %and551.2.i.13 = and i64 0, %conv548.2.i.13\r\n %conv548.3.i.13 = zext i32 0 to i64\r\n %and551.3.i.13 = and i64 0, %conv548.3.i.13\r\n %0 = trunc i64 %and551.2.i.13 to i32\r\n %conv54.2.i.14 = and i32 %0, 0\r\n %conv548.2.i.14 = zext i32 %conv54.2.i.14 to i64\r\n %and551.2.i.14 = and i64 %and551.2.i.13, %conv548.2.i.14\r\n %1 = trunc i64 %and551.3.i.13 to i32\r\n %conv54.3.i.14 = and i32 %1, 0\r\n %conv548.3.i.14 = zext i32 %conv54.3.i.14 to i64\r\n %and551.3.i.14 = and i64 %and551.3.i.13, %conv548.3.i.14\r\n %and551.2.i.15 = and i64 %and551.2.i.14, 0\r\n %and551.3.i.15 = and i64 %and551.3.i.14, 0\r\n %and551.2.i.16 = and i64 %and551.2.i.15, 0\r\n %and551.3.i.16 = and i64 %and551.3.i.15, 0\r\n %and551.2.i.17 = and i64 %and551.2.i.16, 0\r\n %and551.3.i.17 = and i64 %and551.3.i.16, 0\r\n %and551.2.i.18 = and i64 %and551.2.i.17, 0\r\n %and551.3.i.18 = and i64 %and551.3.i.17, 0\r\n %and551.2.i.19 = and i64 %and551.2.i.18, 0\r\n %and551.3.i.19 = and i64 %and551.3.i.18, 0\r\n %and551.2.i.20 = and i64 %and551.2.i.19, 0\r\n %and551.3.i.20 = and i64 %and551.3.i.19, 0\r\n %and551.2.i.21 = and i64 %and551.2.i.20, 0\r\n %and551.3.i.21 = and i64 %and551.3.i.20, 0\r\n %gep1 = getelementptr inbounds i8, ptr %p, i64 16\r\n %gep2 = getelementptr inbounds i8, ptr %p, i64 24\r\n store i64 %and551.2.i.21, ptr %gep1, align 16\r\n store i64 %and551.3.i.21, ptr %gep2, align 8\r\n ret void\r\n}\r\n```\r\n```\r\nopt: /home/dtcxzyw/WorkSpace/Projects/compilers/llvm-project/llvm/lib/IR/Constants.cpp:2202: static llvm::Constant* llvm::ConstantExpr::getCast(unsigned int, llvm::Constant*, llvm::Type*, bool): Assertion `CastInst::castIsValid(opc, C, Ty) && \"Invalid constantexpr cast!\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0. Program arguments: bin/opt -passes=slp-vectorizer reduced.ll -S\r\n1. Running pass \"function(slp-vectorizer)\" on module \"reduced.ll\"\r\n2. Running pass \"slp-vectorizer\" on function \"main\"\r\n #0 0x00007c5d3e8138d2 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMSupport.so.20.0git+0x2138d2)\r\n #1 0x00007c5d3e81079f llvm::sys::RunSignalHandlers() (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMSupport.so.20.0git+0x21079f)\r\n #2 0x00007c5d3e8108e5 SignalHandler(int) Signals.cpp:0:0\r\n #3 0x00007c5d3e242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #4 0x00007c5d3e2969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\r\n #5 0x00007c5d3e2969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10\r\n #6 0x00007c5d3e2969fc pthread_kill ./nptl/pthread_kill.c:89:10\r\n #7 0x00007c5d3e242476 gsignal ./signal/../sysdeps/posix/raise.c:27:6\r\n #8 0x00007c5d3e2287f3 abort ./stdlib/abort.c:81:7\r\n #9 0x00007c5d3e22871b _nl_load_domain ./intl/loadmsgcat.c:1177:9\r\n#10 0x00007c5d3e239e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n#11 0x00007c5d36fb0c4d llvm::ConstantExpr::getCast(unsigned int, llvm::Constant*, llvm::Type*, bool) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMCore.so.20.0git+0x1b0c4d)\r\n#12 0x00007c5d394573b5 llvm::IRBuilderBase::CreateCast(llvm::Instruction::CastOps, llvm::Value*, llvm::Type*, llvm::Twine const&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x573b5)\r\n#13 0x00007c5d395ab173 llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::slpvectorizer::BoUpSLP::TreeEntry*, bool) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1ab173)\r\n#14 0x00007c5d395acf1e llvm::slpvectorizer::BoUpSLP::vectorizeOperand(llvm::slpvectorizer::BoUpSLP::TreeEntry*, unsigned int, bool) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1acf1e)\r\n#15 0x00007c5d395a7a13 llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::slpvectorizer::BoUpSLP::TreeEntry*, bool) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1a7a13)\r\n#16 0x00007c5d395acf1e llvm::slpvectorizer::BoUpSLP::vectorizeOperand(llvm::slpvectorizer::BoUpSLP::TreeEntry*, unsigned int, bool) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1acf1e)\r\n#17 0x00007c5d395a7cbb llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::slpvectorizer::BoUpSLP::TreeEntry*, bool) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1a7cbb)\r\n#18 0x00007c5d395acf1e llvm::slpvectorizer::BoUpSLP::vectorizeOperand(llvm::slpvectorizer::BoUpSLP::TreeEntry*, unsigned int, bool) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1acf1e)\r\n#19 0x00007c5d395a7a41 llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::slpvectorizer::BoUpSLP::TreeEntry*, bool) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1a7a41)\r\n#20 0x00007c5d395acf1e llvm::slpvectorizer::BoUpSLP::vectorizeOperand(llvm::slpvectorizer::BoUpSLP::TreeEntry*, unsigned int, bool) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1acf1e)\r\n#21 0x00007c5d395a7a13 llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::slpvectorizer::BoUpSLP::TreeEntry*, bool) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1a7a13)\r\n#22 0x00007c5d395acf1e llvm::slpvectorizer::BoUpSLP::vectorizeOperand(llvm::slpvectorizer::BoUpSLP::TreeEntry*, unsigned int, bool) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1acf1e)\r\n#23 0x00007c5d395a7a13 llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::slpvectorizer::BoUpSLP::TreeEntry*, bool) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1a7a13)\r\n#24 0x00007c5d395acf1e llvm::slpvectorizer::BoUpSLP::vectorizeOperand(llvm::slpvectorizer::BoUpSLP::TreeEntry*, unsigned int, bool) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1acf1e)\r\n#25 0x00007c5d395a7a13 llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::slpvectorizer::BoUpSLP::TreeEntry*, bool) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1a7a13)\r\n#26 0x00007c5d395acf1e llvm::slpvectorizer::BoUpSLP::vectorizeOperand(llvm::slpvectorizer::BoUpSLP::TreeEntry*, unsigned int, bool) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1acf1e)\r\n#27 0x00007c5d395a7a13 llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::slpvectorizer::BoUpSLP::TreeEntry*, bool) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1a7a13)\r\n#28 0x00007c5d395acf1e llvm::slpvectorizer::BoUpSLP::vectorizeOperand(llvm::slpvectorizer::BoUpSLP::TreeEntry*, unsigned int, bool) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1acf1e)\r\n#29 0x00007c5d395a7a13 llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::slpvectorizer::BoUpSLP::TreeEntry*, bool) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1a7a13)\r\n#30 0x00007c5d395acf1e llvm::slpvectorizer::BoUpSLP::vectorizeOperand(llvm::slpvectorizer::BoUpSLP::TreeEntry*, unsigned int, bool) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1acf1e)\r\n#31 0x00007c5d395a7a13 llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::slpvectorizer::BoUpSLP::TreeEntry*, bool) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1a7a13)\r\n#32 0x00007c5d395acf1e llvm::slpvectorizer::BoUpSLP::vectorizeOperand(llvm::slpvectorizer::BoUpSLP::TreeEntry*, unsigned int, bool) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1acf1e)\r\n#33 0x00007c5d395a7a13 llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::slpvectorizer::BoUpSLP::TreeEntry*, bool) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1a7a13)\r\n#34 0x00007c5d395acf1e llvm::slpvectorizer::BoUpSLP::vectorizeOperand(llvm::slpvectorizer::BoUpSLP::TreeEntry*, unsigned int, bool) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1acf1e)\r\n#35 0x00007c5d395a8f65 llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::slpvectorizer::BoUpSLP::TreeEntry*, bool) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1a8f65)\r\n#36 0x00007c5d395ae278 llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::MapVector<llvm::Value*, llvm::SmallVector<llvm::Instruction*, 2u>, llvm::DenseMap<llvm::Value*, unsigned int, llvm::DenseMapInfo<llvm::Value*, void>, llvm::detail::DenseMapPair<llvm::Value*, unsigned int>>, llvm::SmallVector<std::pair<llvm::Value*, llvm::SmallVector<llvm::Instruction*, 2u>>, 0u>> const&, llvm::SmallVectorImpl<std::pair<llvm::Value*, llvm::Value*>>&, llvm::Instruction*) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1ae278)\r\n#37 0x00007c5d395b207c llvm::slpvectorizer::BoUpSLP::vectorizeTree() (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1b207c)\r\n#38 0x00007c5d395c7cac llvm::SLPVectorizerPass::vectorizeStoreChain(llvm::ArrayRef<llvm::Value*>, llvm::slpvectorizer::BoUpSLP&, unsigned int, unsigned int, unsigned int&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1c7cac)\r\n#39 0x00007c5d395c9637 llvm::SLPVectorizerPass::vectorizeStores(llvm::ArrayRef<llvm::StoreInst*>, llvm::slpvectorizer::BoUpSLP&, llvm::DenseSet<std::tuple<llvm::Value*, llvm::Value*, llvm::Value*, llvm::Value*, unsigned int>, llvm::DenseMapInfo<std::tuple<llvm::Value*, llvm::Value*, llvm::Value*, llvm::Value*, unsigned int>, void>>&)::'lambda'(std::set<std::pair<unsigned int, int>, llvm::SLPVectorizerPass::vectorizeStores(llvm::ArrayRef<llvm::StoreInst*>, llvm::slpvectorizer::BoUpSLP&, llvm::DenseSet<std::tuple<llvm::Value*, llvm::Value*, llvm::Value*, llvm::Value*, unsigned int>, llvm::DenseMapInfo<std::tuple<llvm::Value*, llvm::Value*, llvm::Value*, llvm::Value*, unsigned int>, void>>&)::StoreDistCompare, std::allocator<std::pair<unsigned int, int>>> const&)::operator()(std::set<std::pair<unsigned int, int>, llvm::SLPVectorizerPass::vectorizeStores(llvm::ArrayRef<llvm::StoreInst*>, llvm::slpvectorizer::BoUpSLP&, llvm::DenseSet<std::tuple<llvm::Value*, llvm::Value*, llvm::Value*, llvm::Value*, unsigned int>, llvm::DenseMapInfo<std::tuple<llvm::Value*, llvm::Value*, llvm::Value*, llvm::Value*, unsigned int>, void>>&)::StoreDistCompare, std::allocator<std::pair<unsigned int, int>>> const&) const SLPVectorizer.cpp:0:0\r\n#40 0x00007c5d395cb92c llvm::SLPVectorizerPass::vectorizeStores(llvm::ArrayRef<llvm::StoreInst*>, llvm::slpvectorizer::BoUpSLP&, llvm::DenseSet<std::tuple<llvm::Value*, llvm::Value*, llvm::Value*, llvm::Value*, unsigned int>, llvm::DenseMapInfo<std::tuple<llvm::Value*, llvm::Value*, llvm::Value*, llvm::Value*, unsigned int>, void>>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1cb92c)\r\n#41 0x00007c5d395cc20f llvm::SLPVectorizerPass::vectorizeStoreChains(llvm::slpvectorizer::BoUpSLP&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1cc20f)\r\n#42 0x00007c5d395cd30f llvm::SLPVectorizerPass::runImpl(llvm::Function&, llvm::ScalarEvolution*, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo*, llvm::AAResults*, llvm::LoopInfo*, llvm::DominatorTree*, llvm::AssumptionCache*, llvm::DemandedBits*, llvm::OptimizationRemarkEmitter*) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1cd30f)\r\n#43 0x00007c5d395cdf86 llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMVectorize.so.20.0git+0x1cdf86)\r\n#44 0x00007c5d39ed4015 llvm::detail::PassModel<llvm::Function, llvm::SLPVectorizerPass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMPasses.so.20.0git+0xd4015)\r\n#45 0x00007c5d371546ed llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMCore.so.20.0git+0x3546ed)\r\n#46 0x00007c5d3d4d7f35 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMX86CodeGen.so.20.0git+0xd7f35)\r\n#47 0x00007c5d37153256 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMCore.so.20.0git+0x353256)\r\n#48 0x00007c5d3d4d88f5 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMX86CodeGen.so.20.0git+0xd88f5)\r\n#49 0x00007c5d3715121a llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/../lib/libLLVMCore.so.20.0git+0x35121a)\r\n#50 0x00007c5d3eb12fc7 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMOptDriver.so.20.0git+0x2cfc7)\r\n#51 0x00007c5d3eb1e962 optMain (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMOptDriver.so.20.0git+0x38962)\r\n#52 0x00007c5d3e229d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16\r\n#53 0x00007c5d3e229e40 call_init ./csu/../csu/libc-start.c:128:20\r\n#54 0x00007c5d3e229e40 __libc_start_main ./csu/../csu/libc-start.c:379:5\r\n#55 0x00005949b291d095 _start (bin/opt+0x1095)\r\nAborted (core dumped)\r\n```\r\n\r\ncc @alexey-bataev ",
69
+ "author": "dtcxzyw",
70
+ "labels": [
71
+ "llvm:SLPVectorizer",
72
+ "crash-on-valid"
73
+ ],
74
+ "comments": [
75
+ {
76
+ "author": "dtcxzyw",
77
+ "body": "Related PR: https://github.com/llvm/llvm-project/pull/103216\r\n"
78
+ }
79
+ ]
80
+ },
81
+ "verified": true
82
+ }
dataset/106780.json ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "106780",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/106780",
4
+ "bug_type": "crash",
5
+ "base_commit": "5aa83eb677d2f8cba0c2ad3dcc14f3f4e80a0bba",
6
+ "knowledge_cutoff": "2024-08-30T19:02:15Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/LoopVectorize"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "654bb4e9f287f9ccb5142d1c62a9ab17c16e29d7",
12
+ "components": [
13
+ "LoopVectorize"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
17
+ [
18
+ 6817,
19
+ 6822
20
+ ]
21
+ ]
22
+ },
23
+ "bug_location_funcname": {
24
+ "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
25
+ "LoopVectorizationCostModel::collectValuesToIgnore"
26
+ ]
27
+ }
28
+ },
29
+ "patch": "commit 654bb4e9f287f9ccb5142d1c62a9ab17c16e29d7\nAuthor: Florian Hahn <[email protected]>\nDate: Sun Sep 1 20:35:28 2024 +0100\n\n [LV] Don't consider branches leaving loop in collectValuesToIgnore.\n \n Branches exiting the loop will remain regardless, so don't consider them\n in collectValuesToIgnore.\n \n This fixes another divergence between legacy and VPlan-based cost model.\n \n Fixes https://github.com/llvm/llvm-project/issues/106780.\n\ndiff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\nindex fa05b8dd2242..a8722db654f5 100644\n--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\n+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\n@@ -6817,6 +6817,9 @@ void LoopVectorizationCostModel::collectValuesToIgnore() {\n if (auto *Br = dyn_cast_or_null<BranchInst>(Op)) {\n BasicBlock *ThenBB = Br->getSuccessor(0);\n BasicBlock *ElseBB = Br->getSuccessor(1);\n+ // Don't considers branches leaving the loop for simplification.\n+ if (!TheLoop->contains(ThenBB) || !TheLoop->contains(ElseBB))\n+ continue;\n bool ThenEmpty = IsEmptyBlock(ThenBB);\n bool ElseEmpty = IsEmptyBlock(ElseBB);\n if ((ThenEmpty && ElseEmpty) ||\n",
30
+ "tests": [
31
+ {
32
+ "file": "llvm/test/Transforms/LoopVectorize/RISCV/dead-ops-cost.ll",
33
+ "commands": [
34
+ "opt -p loop-vectorize -mtriple riscv64-linux-gnu -mattr=+v,+f -S %s"
35
+ ],
36
+ "tests": [
37
+ {
38
+ "test_name": "dead_load",
39
+ "test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\n\ndefine void @dead_load(ptr %p, i16 %start) {\nentry:\n %start.ext = sext i16 %start to i64\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ %start.ext, %entry ], [ %iv.next, %loop ]\n %gep = getelementptr i16, ptr %p, i64 %iv\n store i16 0, ptr %gep, align 2\n %l = load i16, ptr %gep, align 2\n %iv.next = add i64 %iv, 3\n %cmp = icmp slt i64 %iv, 111\n br i1 %cmp, label %loop, label %exit\n\nexit: ; preds = %loop\n ret void\n}\n"
40
+ },
41
+ {
42
+ "test_name": "cost_of_exit_branch_and_cond_insts",
43
+ "test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i16 @llvm.umax.i16(i16, i16) #0\n\ndefine i32 @cost_of_exit_branch_and_cond_insts(ptr %a, ptr %b, i1 %c, i16 %x) {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop.latch ]\n br i1 %c, label %then, label %loop.exiting\n\nthen: ; preds = %loop.header\n %gep = getelementptr inbounds i32, ptr %b, i32 %iv\n store i1 false, ptr %a, align 1\n store i32 0, ptr %gep, align 4\n br label %loop.exiting\n\nloop.exiting: ; preds = %then, %loop.header\n %iv.next = add i32 %iv, 1\n %umax = tail call i16 @llvm.umax.i16(i16 %x, i16 111)\n %umax.ext = zext i16 %umax to i32\n %sub = sub i32 770, %umax.ext\n %ec = icmp slt i32 %iv, %sub\n br i1 %ec, label %loop.latch, label %exit\n\nloop.latch: ; preds = %loop.exiting\n br label %loop.header\n\nexit: ; preds = %loop.exiting\n br label %return\n\nreturn: ; preds = %exit\n ret i32 0\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"
44
+ },
45
+ {
46
+ "test_name": "dead_live_out_due_to_scalar_epilogue_required",
47
+ "test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\n\ndefine i8 @dead_live_out_due_to_scalar_epilogue_required(ptr %src, ptr %dst) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]\n %idxprom = sext i32 %iv to i64\n %gep.src = getelementptr i8, ptr %src, i64 %idxprom\n %l = load i8, ptr %gep.src, align 1\n %gep.dst = getelementptr i8, ptr %dst, i64 %idxprom\n store i8 0, ptr %gep.dst, align 1\n %iv.next = add i32 %iv, 4\n %cmp = icmp ult i32 %iv, 1001\n br i1 %cmp, label %loop, label %exit\n\nexit: ; preds = %loop\n %r = phi i8 [ %l, %loop ]\n ret i8 %r\n}\n"
48
+ }
49
+ ]
50
+ }
51
+ ],
52
+ "issue": {
53
+ "title": "[VPlan] Assertion \" VPlan cost model and legacy cost model disagreed\"' failed.",
54
+ "body": "Tested using ef7b18a53c0d186dcda1e322be6035407fdedb55\r\n\r\nTestcase:\r\n```c\r\nunsigned short a;\r\nextern int b;\r\nvoid c(_Bool d, int e, long long f[], unsigned short g[][16],\r\n unsigned short h[][16], unsigned short i[][13], short j[][13],\r\n int k[][21], unsigned char l[][21][21], signed char m[][24]) {\r\n for (short n = 0; n < 5; n += -5532)\r\n for (char o = 0; o < 3; o += d)\r\n for (int p = 0; p < -({ g[d][1] > 0115 ? g[d][1] : 0115; }) + 770; p++)\r\n for (_Bool q = 0; q < (_Bool)e; q = 5)\r\n for (_Bool r = 2048749519 ? 8 ? f[d] : 0 : 0; r < 1; r = h)\r\n b = a = 0;\r\n}\r\nvoid hash();\r\nunsigned short a = 6;\r\nlong long f[6];\r\nunsigned short g[6][16];\r\nunsigned short h[1][16];\r\nunsigned short i[1][13];\r\nshort j[1][13];\r\nint k[1][21];\r\nunsigned char l[1][21][21];\r\nsigned char m[1][24];\r\nint main() {\r\n for (long s = 0; s < 6; ++s)\r\n f[s] = 6;\r\n for (long s = 0; s < 16; ++s)\r\n for (long n = 0; n < 16; ++n)\r\n g[s][n] = 7;\r\n c(1, 407418382874, f, g, h, i, j, k, l, m);\r\n hash(a);\r\n}\r\n```\r\nc command:\r\n```\r\n/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/clang -fno-strict-aliasing -march=rv64gcv -flto -O3 -fuse-ld=lld red.c -o rv64gcv.out -w\r\n```\r\n\r\nLLVM IR testcase:\r\n```llvm ir\r\n; ModuleID = 'reduced.bc'\r\ntarget datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\r\ntarget triple = \"riscv64-unknown-linux-gnu\"\r\n\r\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\r\ndeclare i16 @llvm.umax.i16(i16, i16) #0\r\n\r\ndefine i32 @main(ptr %a) #1 {\r\nentry:\r\n br label %for.cond22.preheader.us.us76.us.us.us.us.i.1\r\n\r\nfor.cond22.preheader.us.us76.us.us.us.us.i.1: ; preds = %for.cond22.preheader.us.us76.us.us.us.usthread-pre-split.i.1, %entry\r\n %p.072.us.us77.us.us.us.us.i.1 = phi i32 [ %inc.us.us80.us.us.us.us.i.1, %for.cond22.preheader.us.us76.us.us.us.usthread-pre-split.i.1 ], [ 0, %entry ]\r\n br i1 false, label %for.body41.lr.ph.us.us.us.us.us.us.us.i.1, label %for.cond22.for.cond.cleanup28_crit_edge.us.us.us.us.us.us.i.1\r\n\r\nfor.body41.lr.ph.us.us.us.us.us.us.us.i.1: ; preds = %for.cond22.preheader.us.us76.us.us.us.us.i.1\r\n store i1 false, ptr %a, align 1\r\n store i32 0, ptr null, align 4\r\n br label %for.cond22.for.cond.cleanup28_crit_edge.us.us.us.us.us.us.i.1\r\n\r\nfor.cond22.for.cond.cleanup28_crit_edge.us.us.us.us.us.us.i.1: ; preds = %for.body41.lr.ph.us.us.us.us.us.us.us.i.1, %for.cond22.preheader.us.us76.us.us.us.us.i.1\r\n %inc.us.us80.us.us.us.us.i.1 = add i32 %p.072.us.us77.us.us.us.us.i.1, 1\r\n %narrow.us.us81.us.us.us.us.i.1 = tail call i16 @llvm.umax.i16(i16 0, i16 0)\r\n %spec.select.us.us82.us.us.us.us.i.1 = zext i16 %narrow.us.us81.us.us.us.us.i.1 to i32\r\n %add.us.us83.us.us.us.us.i.1 = sub i32 770, %spec.select.us.us82.us.us.us.us.i.1\r\n %cmp18.us.us84.us.us.us.us.i.1 = icmp slt i32 %p.072.us.us77.us.us.us.us.i.1, %add.us.us83.us.us.us.us.i.1\r\n br i1 %cmp18.us.us84.us.us.us.us.i.1, label %for.cond22.preheader.us.us76.us.us.us.usthread-pre-split.i.1, label %for.cond22.for.cond.cleanup28_crit_edge.us.us.us.us.us.us.i.1.for.cond.cleanup20.us.us.us.us.i.1_crit_edge\r\n\r\nfor.cond22.for.cond.cleanup28_crit_edge.us.us.us.us.us.us.i.1.for.cond.cleanup20.us.us.us.us.i.1_crit_edge: ; preds = %for.cond22.for.cond.cleanup28_crit_edge.us.us.us.us.us.us.i.1\r\n br label %for.cond.cleanup20.us.us.us.us.i.1\r\n\r\nfor.cond.cleanup20.us.us.us.us.i.1: ; preds = %for.cond22.for.cond.cleanup28_crit_edge.us.us.us.us.us.us.i.1.for.cond.cleanup20.us.us.us.us.i.1_crit_edge\r\n ret i32 0\r\n\r\nfor.cond22.preheader.us.us76.us.us.us.usthread-pre-split.i.1: ; preds = %for.cond22.for.cond.cleanup28_crit_edge.us.us.us.us.us.us.i.1\r\n br label %for.cond22.preheader.us.us76.us.us.us.us.i.1\r\n}\r\n\r\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\r\nattributes #1 = { \"target-features\"=\"+64bit,+a,+c,+d,+f,+m,+relax,+v,+zicsr,+zifencei,+zmmul,+zve32f,+zve32x,+zve64d,+zve64f,+zve64x,+zvl128b,+zvl32b,+zvl64b,-b,-e,-experimental-smctr,-experimental-smmpm,-experimental-smnpm,-experimental-ssctr,-experimental-ssnpm,-experimental-sspm,-experimental-supm,-experimental-zacas,-experimental-zalasr,-experimental-zicfilp,-experimental-zicfiss,-experimental-zvbc32e,-experimental-zvkgs,-h,-shcounterenw,-shgatpa,-shtvala,-shvsatpa,-shvstvala,-shvstvecd,-smaia,-smcdeleg,-smcsrind,-smepmp,-smstateen,-ssaia,-ssccfg,-ssccptr,-sscofpmf,-sscounterenw,-sscsrind,-ssqosid,-ssstateen,-ssstrict,-sstc,-sstvala,-sstvecd,-ssu64xl,-svade,-svadu,-svbare,-svinval,-svnapot,-svpbmt,-xcvalu,-xcvbi,-xcvbitmanip,-xcvelw,-xcvmac,-xcvmem,-xcvsimd,-xsfcease,-xsfvcp,-xsfvfnrclipxfqf,-xsfvfwmaccqqq,-xsfvqmaccdod,-xsfvqmaccqoq,-xsifivecdiscarddlone,-xsifivecflushdlone,-xtheadba,-xtheadbb,-xtheadbs,-xtheadcmo,-xtheadcondmov,-xtheadfmemidx,-xtheadmac,-xtheadmemidx,-xtheadmempair,-xtheadsync,-xtheadvdot,-xventanacondops,-xwchc,-za128rs,-za64rs,-zaamo,-zabha,-zalrsc,-zama16b,-zawrs,-zba,-zbb,-zbc,-zbkb,-zbkc,-zbkx,-zbs,-zca,-zcb,-zcd,-zce,-zcf,-zcmop,-zcmp,-zcmt,-zdinx,-zfa,-zfbfmin,-zfh,-zfhmin,-zfinx,-zhinx,-zhinxmin,-zic64b,-zicbom,-zicbop,-zicboz,-ziccamoa,-ziccif,-zicclsm,-ziccrse,-zicntr,-zicond,-zihintntl,-zihintpause,-zihpm,-zimop,-zk,-zkn,-zknd,-zkne,-zknh,-zkr,-zks,-zksed,-zksh,-zkt,-ztso,-zvbb,-zvbc,-zvfbfmin,-zvfbfwma,-zvfh,-zvfhmin,-zvkb,-zvkg,-zvkn,-zvknc,-zvkned,-zvkng,-zvknha,-zvknhb,-zvks,-zvksc,-zvksed,-zvksg,-zvksh,-zvkt,-zvl1024b,-zvl16384b,-zvl2048b,-zvl256b,-zvl32768b,-zvl4096b,-zvl512b,-zvl65536b,-zvl8192b\" }\r\n```\r\n\r\nCommand/backtrace:\r\n```\r\n> /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt -passes=loop-vectorize reduced.ll -S\r\nopt: /scratch/tc-testing/tc-compiler-fuzz-trunk/llvm/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:7366: llvm::VectorizationFactor llvm::LoopVectorizationPlanner::computeBestVF(): Assertion `(BestFactor.Width == LegacyVF.Width || planContainsAdditionalSimplifications(getPlanFor(BestFactor.Width), CostCtx, OrigLoop)) && \" VPlan cost model and legacy cost model disagreed\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0. Program arguments: /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt -passes=loop-vectorize reduced.ll -S\r\n1. Running pass \"function(loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>)\" on module \"reduced.ll\"\r\n2. Running pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"main\"\r\n #0 0x00005e8221f7d690 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x301e690)\r\n #1 0x00005e8221f7aa9f llvm::sys::RunSignalHandlers() (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x301ba9f)\r\n #2 0x00005e8221f7abf5 SignalHandler(int) Signals.cpp:0:0\r\n #3 0x0000772c88c42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #4 0x0000772c88c969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\r\n #5 0x0000772c88c969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10\r\n #6 0x0000772c88c969fc pthread_kill ./nptl/pthread_kill.c:89:10\r\n #7 0x0000772c88c42476 gsignal ./signal/../sysdeps/posix/raise.c:27:6\r\n #8 0x0000772c88c287f3 abort ./stdlib/abort.c:81:7\r\n #9 0x0000772c88c2871b _nl_load_domain ./intl/loadmsgcat.c:1177:9\r\n#10 0x0000772c88c39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n#11 0x00005e8220f4a3e0 llvm::LoopVectorizationPlanner::computeBestVF() (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1feb3e0)\r\n#12 0x00005e8220f60ffb llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2001ffb)\r\n#13 0x00005e8220f64011 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2005011)\r\n#14 0x00005e8220f64687 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2005687)\r\n#15 0x00005e821fdc0fb6 llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xe61fb6)\r\n#16 0x00005e8221d8858f llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2e2958f)\r\n#17 0x00005e821fdc4146 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xe65146)\r\n#18 0x00005e8221d8730b llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2e2830b)\r\n#19 0x00005e821fdc03e6 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xe613e6)\r\n#20 0x00005e8221d8534d llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2e2634d)\r\n#21 0x00005e821f5e6ee6 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x687ee6)\r\n#22 0x00005e821f5d8c71 optMain (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x679c71)\r\n#23 0x0000772c88c29d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16\r\n#24 0x0000772c88c29e40 call_init ./csu/../csu/libc-start.c:128:20\r\n#25 0x0000772c88c29e40 __libc_start_main ./csu/../csu/libc-start.c:379:5\r\n#26 0x00005e821f5cf025 _start (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x670025)\r\nzsh: IOT instruction (core dumped) /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt\r\n```\r\nhttps://godbolt.org/z/ej1Gax953\r\n\r\nFound via fuzzer\r\n\r\nRelated/prior issue: https://github.com/llvm/llvm-project/issues/106641\r\n\r\ncc @fhahn",
55
+ "author": "patrick-rivos",
56
+ "labels": [
57
+ "vectorizers",
58
+ "crash"
59
+ ],
60
+ "comments": []
61
+ },
62
+ "verified": true
63
+ }
dataset/107015.json ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "107015",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/107015",
4
+ "bug_type": "crash",
5
+ "base_commit": "50a02e7c68f964c5d8338369746c849ed8d3bef4",
6
+ "knowledge_cutoff": "2024-09-02T18:45:19Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/LoopVectorize"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "954ed05c1001489802ae43d4bea403181570a799",
12
+ "components": [
13
+ "LoopVectorize"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
17
+ [
18
+ 8393,
19
+ 8398
20
+ ]
21
+ ],
22
+ "llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": [
23
+ [
24
+ 174,
25
+ 184
26
+ ]
27
+ ]
28
+ },
29
+ "bug_location_funcname": {
30
+ "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
31
+ "VPRecipeBuilder::tryToWiden"
32
+ ],
33
+ "llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h": [
34
+ "getVPValueOrAddLiveIn"
35
+ ]
36
+ }
37
+ },
38
+ "patch": "commit 954ed05c1001489802ae43d4bea403181570a799\nAuthor: Florian Hahn <[email protected]>\nDate: Mon Sep 2 21:25:30 2024 +0100\n\n [VPlan] Simplify MUL operands at recipe construction.\n \n This moves the logic to create simplified operands using SCEV to MUL\n recipe creation. This is needed to match the behavior of the legacy's cost\n model. TODOs are to extend to other opcodes and move to a transform.\n \n Note that this also restricts the number of SCEV simplifications we\n apply to more precisely match the cases handled by the legacy cost\n model.\n \n Fixes https://github.com/llvm/llvm-project/issues/107015.\n\ndiff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\nindex a8722db654f5..a64848c1fdce 100644\n--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\n+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\n@@ -8393,6 +8393,20 @@ VPWidenRecipe *VPRecipeBuilder::tryToWiden(Instruction *I,\n case Instruction::Sub:\n case Instruction::Xor:\n case Instruction::Freeze:\n+ if (I->getOpcode() == Instruction::Mul) {\n+ // Simplify operands of multiplications using SCEV. This is needed at the\n+ // moment to match the behavior of the legacy cost-model.\n+ // TODO: Generalize to any opcode and move to VPlan transformation.\n+ SmallVector<VPValue *> NewOps(Operands);\n+ ScalarEvolution &SE = *PSE.getSE();\n+ for (unsigned I = 0; I < Operands.size(); ++I) {\n+ Value *V = NewOps[I]->getUnderlyingValue();\n+ if (!isa<Constant>(V) && SE.isSCEVable(V->getType()))\n+ if (auto *C = dyn_cast<SCEVConstant>(PSE.getSE()->getSCEV(V)))\n+ NewOps[I] = Plan.getOrAddLiveIn(C->getValue());\n+ }\n+ return new VPWidenRecipe(*I, make_range(NewOps.begin(), NewOps.end()));\n+ }\n return new VPWidenRecipe(*I, make_range(Operands.begin(), Operands.end()));\n };\n }\ndiff --git a/llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h b/llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h\nindex 0fbdeeddaf4a..25b8bf3e089e 100644\n--- a/llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h\n+++ b/llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h\n@@ -174,11 +174,6 @@ public:\n if (auto *R = Ingredient2Recipe.lookup(I))\n return R->getVPSingleValue();\n }\n- ScalarEvolution &SE = *PSE.getSE();\n- if (!isa<Constant>(V) && SE.isSCEVable(V->getType()))\n- if (auto *C = dyn_cast<SCEVConstant>(PSE.getSE()->getSCEV(V)))\n- return Plan.getOrAddLiveIn(C->getValue());\n-\n return Plan.getOrAddLiveIn(V);\n }\n };\n",
39
+ "tests": [
40
+ {
41
+ "file": "llvm/test/Transforms/LoopVectorize/AArch64/mul-simplification.ll",
42
+ "commands": [
43
+ "opt -p loop-vectorize -S %s"
44
+ ],
45
+ "tests": [
46
+ {
47
+ "test_name": "mul_select_operand_known_1_via_scev",
48
+ "test_body": "target triple = \"arm64-apple-macosx\"\n\ndefine i64 @mul_select_operand_known_1_via_scev() {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %red = phi i64 [ 12, %entry ], [ %red.next, %loop ]\n %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]\n %0 = and i32 %iv, 1\n %cmp1.i = icmp eq i32 %0, 0\n %narrow.i = select i1 %cmp1.i, i32 1, i32 %iv\n %mul = zext nneg i32 %narrow.i to i64\n %red.next = mul nsw i64 %red, %mul\n %iv.next = add nuw nsw i32 %iv, 1\n %ec = icmp eq i32 %iv, 1\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n %res = phi i64 [ %red.next, %loop ]\n ret i64 %res\n}\n"
49
+ }
50
+ ]
51
+ }
52
+ ],
53
+ "issue": {
54
+ "title": "[clang] Crash with assertion failed in Vectorize",
55
+ "body": "The compiler crashed with -O2 in this code:\r\n\r\n```c\r\n#include<stdint.h>\r\nstatic uint8_t b[][1] = {127};\r\nlong a(int c, int e) {\r\n long d;\r\n for (; c <= e; c++)\r\n if (c % 2 == 0)\r\n ;\r\n else\r\n d *= c;\r\n return d;\r\n}\r\nint64_t f();\r\nint16_t g() {\r\n int32_t h = 1653000360;\r\n f(a(h - 1653000360, b[0][0] - 126));\r\n uint8_t *i[] = {b, b};\r\n}\r\n```\r\n\r\nThe crash is:\r\n```\r\nclang: /root/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:7369: llvm::VectorizationFactor llvm::LoopVectorizationPlanner::computeBestVF(): Assertion `(BestFactor.Width == LegacyVF.Width || planContainsAdditionalSimplifications(getPlanFor(BestFactor.Width), CostCtx, OrigLoop)) && \" VPlan cost model and legacy cost model disagreed\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.\r\n```\r\n\r\nThe details can be found here: https://godbolt.org/z/eeWW6raPb",
56
+ "author": "cardigan1008",
57
+ "labels": [
58
+ "vectorizers",
59
+ "crash"
60
+ ],
61
+ "comments": []
62
+ },
63
+ "verified": true
64
+ }
dataset/107016.json ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "107016",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/107016",
4
+ "bug_type": "crash",
5
+ "base_commit": "a586b5a49dbd3b6c658f9edbf0b4a9be0b108a14",
6
+ "knowledge_cutoff": "2024-09-02T19:14:36Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/LoopVectorize"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "50a02e7c68f964c5d8338369746c849ed8d3bef4",
12
+ "components": [
13
+ "LoopVectorize"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": [
17
+ [
18
+ 965,
19
+ 972
20
+ ]
21
+ ]
22
+ },
23
+ "bug_location_funcname": {
24
+ "llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp": [
25
+ "VPWidenCallRecipe::computeCost"
26
+ ]
27
+ }
28
+ },
29
+ "patch": "commit 50a02e7c68f964c5d8338369746c849ed8d3bef4\nAuthor: Florian Hahn <[email protected]>\nDate: Mon Sep 2 20:47:36 2024 +0100\n\n [VPlan] Pass intrinsic inst to TTI in VPWidenCallRecipe::computeCost.\n \n Follow-up to 9ccf825, adjust computeCost to also pass IntrinsicInst to\n TTI if available, as there are multiple places in TTI which use the\n IntrinsicInst.\n \n Fixes https://github.com/llvm/llvm-project/issues/107016.\n\ndiff --git a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp\nindex e782ac444d02..c91ea2d1663c 100644\n--- a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp\n+++ b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp\n@@ -965,8 +965,10 @@ InstructionCost VPWidenCallRecipe::computeCost(ElementCount VF,\n ParamTys.push_back(\n ToVectorTy(Ctx.Types.inferScalarType(getOperand(I)), VF));\n \n- IntrinsicCostAttributes CostAttrs(VectorIntrinsicID, RetTy, Arguments,\n- ParamTys, FMF);\n+ // TODO: Rework TTI interface to avoid reliance on underlying IntrinsicInst.\n+ IntrinsicCostAttributes CostAttrs(\n+ VectorIntrinsicID, RetTy, Arguments, ParamTys, FMF,\n+ dyn_cast_or_null<IntrinsicInst>(getUnderlyingValue()));\n return Ctx.TTI.getIntrinsicInstrCost(CostAttrs, CostKind);\n }\n \n",
30
+ "tests": [
31
+ {
32
+ "file": "llvm/test/Transforms/LoopVectorize/AArch64/call-costs.ll",
33
+ "commands": [
34
+ "opt -p loop-vectorize -S %s"
35
+ ],
36
+ "tests": [
37
+ {
38
+ "test_name": "fshl_operand_first_order_recurrence",
39
+ "test_body": "target triple = \"arm64-apple-macosx11.0.0\"\n\ndefine void @fshl_operand_first_order_recurrence(ptr %dst, ptr noalias %src) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %recur = phi i64 [ 0, %entry ], [ %l, %loop ]\n %gep.src = getelementptr inbounds i64, ptr %src, i64 %iv\n %l = load i64, ptr %gep.src, align 8\n %or = tail call i64 @llvm.fshl.i64(i64 1, i64 %recur, i64 1)\n %gep.dst = getelementptr inbounds i64, ptr %dst, i64 %iv\n store i64 %or, ptr %gep.dst, align 8\n %iv.next = add i64 %iv, 1\n %exitcond.not = icmp eq i64 %iv, 100\n br i1 %exitcond.not, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i64 @llvm.fshl.i64(i64, i64, i64) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"
40
+ },
41
+ {
42
+ "test_name": "powi_call",
43
+ "test_body": "target triple = \"arm64-apple-macosx11.0.0\"\n\ndefine void @powi_call(ptr %P) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %gep = getelementptr inbounds double, ptr %P, i64 %iv\n %l = load double, ptr %gep, align 8\n %powi = tail call double @llvm.powi.f64.i32(double %l, i32 3)\n store double %powi, ptr %gep, align 8\n %iv.next = add i64 %iv, 1\n %ec = icmp eq i64 %iv, 1\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare double @llvm.powi.f64.i32(double, i32) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"
44
+ }
45
+ ]
46
+ }
47
+ ],
48
+ "issue": {
49
+ "title": "[VPlan] clang crash",
50
+ "body": "Failure since https://github.com/llvm/llvm-project/pull/106047\r\n\r\n[repro.zip](https://github.com/user-attachments/files/16840758/repro.zip)\r\n\r\n```\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.\r\nStack dump:\r\n0.\tProgram arguments: /scratch3/packages/llvm/main-20240902/bin/clang-20 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -disable-free -clear-ast-before-backend -main-file-name PairCorrEstimator.cpp -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=none -menable-no-infs -menable-no-nans -fapprox-func -funsafe-math-optimizations -fno-signed-zeros -mreassociate -freciprocal-math -ffp-contract=fast -fno-rounding-math -ffast-math -ffinite-math-only -complex-range=basic -mconstructor-aliases -funwind-tables=2 -target-cpu skylake-avx512 -target-feature +prfchw -target-feature -cldemote -target-feature +avx -target-feature +aes -target-feature +sahf -target-feature +pclmul -target-feature -xop -target-feature +crc32 -target-feature +xsaves -target-feature -avx512fp16 -target-feature -usermsr -target-feature -sm4 -target-feature -egpr -target-feature +sse4.1 -target-feature -avx512ifma -target-feature +xsave -target-feature +sse4.2 -target-feature -tsxldtrk -target-feature -sm3 -target-feature -ptwrite -target-feature -widekl -target-feature +invpcid -target-feature +64bit -target-feature +xsavec -target-feature -avx10.1-512 -target-feature -avx512vpopcntdq -target-feature +cmov -target-feature -avx512vp2intersect -target-feature +avx512cd -target-feature +movbe -target-feature -avxvnniint8 -target-feature -ccmp -target-feature -amx-int8 -target-feature -kl -target-feature -avx10.1-256 -target-feature +evex512 -target-feature -avxvnni -target-feature +rtm -target-feature +adx -target-feature +avx2 -target-feature -hreset -target-feature -movdiri -target-feature -serialize -target-feature -sha512 -target-feature -vpclmulqdq -target-feature +avx512vl -target-feature -uintr -target-feature -cf -target-feature +clflushopt -target-feature -raoint -target-feature -cmpccxadd -target-feature +bmi -target-feature -amx-tile -target-feature +sse -target-feature -avx10.2-256 -target-feature -gfni -target-feature -avxvnniint16 -target-feature -amx-fp16 -target-feature -zu -target-feature -ndd -target-feature +xsaveopt -target-feature +rdrnd -target-feature +avx512f -target-feature -amx-bf16 -target-feature -avx512bf16 -target-feature -avx512vnni -target-feature -push2pop2 -target-feature +cx8 -target-feature +avx512bw -target-feature +sse3 -target-feature +pku -target-feature -nf -target-feature +fsgsbase -target-feature -clzero -target-feature -mwaitx -target-feature -lwp -target-feature +lzcnt -target-feature -sha -target-feature -movdir64b -target-feature -ppx -target-feature -wbnoinvd -target-feature -enqcmd -target-feature -avx10.2-512 -target-feature -avxneconvert -target-feature -tbm -target-feature -pconfig -target-feature -amx-complex -target-feature +ssse3 -target-feature +cx16 -target-feature +bmi2 -target-feature +fma -target-feature +popcnt -target-feature -avxifma -target-feature +f16c -target-feature -avx512bitalg -target-feature -rdpru -target-feature +clwb -target-feature +mmx -target-feature +sse2 -target-feature +rdseed -target-feature -avx512vbmi2 -target-feature -prefetchi -target-feature -rdpid -target-feature -fma4 -target-feature -avx512vbmi -target-feature -shstk -target-feature -vaes -target-feature -waitpkg -target-feature -sgx -target-feature +fxsr -target-feature +avx512dq -target-feature -sse4a -debugger-tuning=gdb -fdebug-compilation-dir=/scratch3/opt/qmcpack/build_clangPatched_real/src/QMCHamiltonians -fcoverage-compilation-dir=/scratch3/opt/qmcpack/build_clangPatched_real/src/QMCHamiltonians -sys-header-deps -D ADD_ -D H5_USE_110_API -D HAVE_CONFIG_H -D HAVE_EINSPLINE -D HAVE_LIBBOOST -D HAVE_LIBFFTW -D HAVE_MKL -D HAVE_MKL_VML -D MPICH_SKIP_MPICXX -D OMPI_SKIP_MPICXX -D OPENMP_NO_COMPLEX -D _MPICC_H -D restrict=__restrict__ -D NDEBUG -O3 -Wvla -Wall -Wno-unused-variable -Wno-overloaded-virtual -Wno-unused-private-field -Wno-unused-local-typedef -Wsuggest-override -Wno-unknown-pragmas -Wmisleading-indentation -std=c++17 -fdeprecated-macro -ferror-limit 19 -fopenmp -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcxx-exceptions -fexceptions -fcolor-diagnostics -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -x c++ PairCorrEstimator-40412c.cpp\r\n1.\t<eof> parser at end of file\r\n2.\tOptimizer\r\n3.\tRunning pass \"function<eager-inv>(float2int,lower-constant-intrinsics,chr,loop(loop-rotate<header-duplication;no-prepare-for-lto>,loop-deletion),loop-distribute,inject-tli-mappings,loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,infer-alignment,loop-load-elim,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,slp-vectorizer,vector-combine,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,loop-unroll<O3>,transform-warning,sroa<preserve-cfg>,infer-alignment,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,loop-sink,instsimplify,div-rem-pairs,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;speculate-unpredictables>)\" on module \"PairCorrEstimator-40412c.cpp\"\r\n4.\tRunning pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"_ZN11qmcplusplus17PairCorrEstimator15set_norm_factorEv\"\r\n #0 0x00005590c1746c00 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch3/packages/llvm/main-20240902/bin/clang-20+0x2cb6c00)\r\n #1 0x00005590c174400f llvm::sys::RunSignalHandlers() (/scratch3/packages/llvm/main-20240902/bin/clang-20+0x2cb400f)\r\n #2 0x00005590c1744165 SignalHandler(int) Signals.cpp:0:0\r\n #3 0x00007fb046e53520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #4 0x00005590bfa8725a llvm::BasicTTIImplBase<llvm::X86TTIImpl>::getIntrinsicInstrCost(llvm::IntrinsicCostAttributes const&, llvm::TargetTransformInfo::TargetCostKind) (/scratch3/packages/llvm/main-20240902/bin/clang-20+0xff725a)\r\n #5 0x00005590c07fac92 llvm::TargetTransformInfo::getIntrinsicInstrCost(llvm::IntrinsicCostAttributes const&, llvm::TargetTransformInfo::TargetCostKind) const (/scratch3/packages/llvm/main-20240902/bin/clang-20+0x1d6ac92)\r\n #6 0x00005590c31a87b9 llvm::VPWidenCallRecipe::computeCost(llvm::ElementCount, llvm::VPCostContext&) const (/scratch3/packages/llvm/main-20240902/bin/clang-20+0x47187b9)\r\n #7 0x00005590c31ab682 llvm::VPRecipeBase::cost(llvm::ElementCount, llvm::VPCostContext&) (/scratch3/packages/llvm/main-20240902/bin/clang-20+0x471b682)\r\n #8 0x00005590c31744af llvm::VPBasicBlock::cost(llvm::ElementCount, llvm::VPCostContext&) (/scratch3/packages/llvm/main-20240902/bin/clang-20+0x46e44af)\r\n #9 0x00005590c317b4b5 llvm::VPRegionBlock::cost(llvm::ElementCount, llvm::VPCostContext&) (/scratch3/packages/llvm/main-20240902/bin/clang-20+0x46eb4b5)\r\n#10 0x00005590c305cfb4 llvm::LoopVectorizationPlanner::cost(llvm::VPlan&, llvm::ElementCount) const (/scratch3/packages/llvm/main-20240902/bin/clang-20+0x45ccfb4)\r\n#11 0x00005590c3064878 llvm::LoopVectorizationPlanner::computeBestVF() (/scratch3/packages/llvm/main-20240902/bin/clang-20+0x45d4878)\r\n#12 0x00005590c307c6fb llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/scratch3/packages/llvm/main-20240902/bin/clang-20+0x45ec6fb)\r\n#13 0x00005590c307f711 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/scratch3/packages/llvm/main-20240902/bin/clang-20+0x45ef711)\r\n#14 0x00005590c307fd87 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch3/packages/llvm/main-20240902/bin/clang-20+0x45efd87)\r\n#15 0x00005590c2bdf2e6 llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch3/packages/llvm/main-20240902/bin/clang-20+0x414f2e6)\r\n#16 0x00005590c10e652f llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch3/packages/llvm/main-20240902/bin/clang-20+0x265652f)\r\n#17 0x00005590bfaa9996 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch3/packages/llvm/main-20240902/bin/clang-20+0x1019996)\r\n#18 0x00005590c10e52ab llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch3/packages/llvm/main-20240902/bin/clang-20+0x26552ab)\r\n#19 0x00005590bfaaa356 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch3/packages/llvm/main-20240902/bin/clang-20+0x101a356)\r\n#20 0x00005590c10e32ed llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch3/packages/llvm/main-20240902/bin/clang-20+0x26532ed)\r\n#21 0x00005590c19d36b6 (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>&, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>&, clang::BackendConsumer*) BackendUtil.cpp:0:0\r\n#22 0x00005590c19d70e9 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/scratch3/packages/llvm/main-20240902/bin/clang-20+0x2f470e9)\r\n#23 0x00005590c206a4b5 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/scratch3/packages/llvm/main-20240902/bin/clang-20+0x35da4b5)\r\n#24 0x00005590c3cfd42c clang::ParseAST(clang::Sema&, bool, bool) (/scratch3/packages/llvm/main-20240902/bin/clang-20+0x526d42c)\r\n#25 0x00005590c2318d19 clang::FrontendAction::Execute() (/scratch3/packages/llvm/main-20240902/bin/clang-20+0x3888d19)\r\n#26 0x00005590c22972b5 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/scratch3/packages/llvm/main-20240902/bin/clang-20+0x38072b5)\r\n#27 0x00005590c23ef9d3 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/scratch3/packages/llvm/main-20240902/bin/clang-20+0x395f9d3)\r\n#28 0x00005590bfa2dc87 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/scratch3/packages/llvm/main-20240902/bin/clang-20+0xf9dc87)\r\n#29 0x00005590bfa269ea ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\r\n#30 0x00005590bfa29be3 clang_main(int, char**, llvm::ToolContext const&) (/scratch3/packages/llvm/main-20240902/bin/clang-20+0xf99be3)\r\n#31 0x00005590bf955c4b main (/scratch3/packages/llvm/main-20240902/bin/clang-20+0xec5c4b)\r\n#32 0x00007fb046e3ad90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16\r\n#33 0x00007fb046e3ae40 call_init ./csu/../csu/libc-start.c:128:20\r\n#34 0x00007fb046e3ae40 __libc_start_main ./csu/../csu/libc-start.c:379:5\r\n#35 0x00005590bfa26115 _start (/scratch3/packages/llvm/main-20240902/bin/clang-20+0xf96115)\r\nPairCorrEstimator-40412c.sh: line 4: 840679 Segmentation fault (core dumped) \"/scratch3/packages/llvm/main-20240902/bin/clang-20\" \"-cc1\" \"-triple\" \"x86_64-unknown-linux-gnu\" \"-emit-obj\" \"-disable-free\" \"-clear-ast-before-backend\" \"-main-file-name\" \"PairCorrEstimator.cpp\" \"-mrelocation-model\" \"pic\" \"-pic-level\" \"2\" \"-pic-is-pie\" \"-mframe-pointer=none\" \"-menable-no-infs\" \"-menable-no-nans\" \"-fapprox-func\" \"-funsafe-math-optimizations\" \"-fno-signed-zeros\" \"-mreassociate\" \"-freciprocal-math\" \"-ffp-contract=fast\" \"-fno-rounding-math\" \"-ffast-math\" \"-ffinite-math-only\" \"-complex-range=basic\" \"-mconstructor-aliases\" \"-funwind-tables=2\" \"-target-cpu\" \"skylake-avx512\" \"-target-feature\" \"+prfchw\" \"-target-feature\" \"-cldemote\" \"-target-feature\" \"+avx\" \"-target-feature\" \"+aes\" \"-target-feature\" \"+sahf\" \"-target-feature\" \"+pclmul\" \"-target-feature\" \"-xop\" \"-target-feature\" \"+crc32\" \"-target-feature\" \"+xsaves\" \"-target-feature\" \"-avx512fp16\" \"-target-feature\" \"-usermsr\" \"-target-feature\" \"-sm4\" \"-target-feature\" \"-egpr\" \"-target-feature\" \"+sse4.1\" \"-target-feature\" \"-avx512ifma\" \"-target-feature\" \"+xsave\" \"-target-feature\" \"+sse4.2\" \"-target-feature\" \"-tsxldtrk\" \"-target-feature\" \"-sm3\" \"-target-feature\" \"-ptwrite\" \"-target-feature\" \"-widekl\" \"-target-feature\" \"+invpcid\" \"-target-feature\" \"+64bit\" \"-target-feature\" \"+xsavec\" \"-target-feature\" \"-avx10.1-512\" \"-target-feature\" \"-avx512vpopcntdq\" \"-target-feature\" \"+cmov\" \"-target-feature\" \"-avx512vp2intersect\" \"-target-feature\" \"+avx512cd\" \"-target-feature\" \"+movbe\" \"-target-feature\" \"-avxvnniint8\" \"-target-feature\" \"-ccmp\" \"-target-feature\" \"-amx-int8\" \"-target-feature\" \"-kl\" \"-target-feature\" \"-avx10.1-256\" \"-target-feature\" \"+evex512\" \"-target-feature\" \"-avxvnni\" \"-target-feature\" \"+rtm\" \"-target-feature\" \"+adx\" \"-target-feature\" \"+avx2\" \"-target-feature\" \"-hreset\" \"-target-feature\" \"-movdiri\" \"-target-feature\" \"-serialize\" \"-target-feature\" \"-sha512\" \"-target-feature\" \"-vpclmulqdq\" \"-target-feature\" \"+avx512vl\" \"-target-feature\" \"-uintr\" \"-target-feature\" \"-cf\" \"-target-feature\" \"+clflushopt\" \"-target-feature\" \"-raoint\" \"-target-feature\" \"-cmpccxadd\" \"-target-feature\" \"+bmi\" \"-target-feature\" \"-amx-tile\" \"-target-feature\" \"+sse\" \"-target-feature\" \"-avx10.2-256\" \"-target-feature\" \"-gfni\" \"-target-feature\" \"-avxvnniint16\" \"-target-feature\" \"-amx-fp16\" \"-target-feature\" \"-zu\" \"-target-feature\" \"-ndd\" \"-target-feature\" \"+xsaveopt\" \"-target-feature\" \"+rdrnd\" \"-target-feature\" \"+avx512f\" \"-target-feature\" \"-amx-bf16\" \"-target-feature\" \"-avx512bf16\" \"-target-feature\" \"-avx512vnni\" \"-target-feature\" \"-push2pop2\" \"-target-feature\" \"+cx8\" \"-target-feature\" \"+avx512bw\" \"-target-feature\" \"+sse3\" \"-target-feature\" \"+pku\" \"-target-feature\" \"-nf\" \"-target-feature\" \"+fsgsbase\" \"-target-feature\" \"-clzero\" \"-target-feature\" \"-mwaitx\" \"-target-feature\" \"-lwp\" \"-target-feature\" \"+lzcnt\" \"-target-feature\" \"-sha\" \"-target-feature\" \"-movdir64b\" \"-target-feature\" \"-ppx\" \"-target-feature\" \"-wbnoinvd\" \"-target-feature\" \"-enqcmd\" \"-target-feature\" \"-avx10.2-512\" \"-target-feature\" \"-avxneconvert\" \"-target-feature\" \"-tbm\" \"-target-feature\" \"-pconfig\" \"-target-feature\" \"-amx-complex\" \"-target-feature\" \"+ssse3\" \"-target-feature\" \"+cx16\" \"-target-feature\" \"+bmi2\" \"-target-feature\" \"+fma\" \"-target-feature\" \"+popcnt\" \"-target-feature\" \"-avxifma\" \"-target-feature\" \"+f16c\" \"-target-feature\" \"-avx512bitalg\" \"-target-feature\" \"-rdpru\" \"-target-feature\" \"+clwb\" \"-target-feature\" \"+mmx\" \"-target-feature\" \"+sse2\" \"-target-feature\" \"+rdseed\" \"-target-feature\" \"-avx512vbmi2\" \"-target-feature\" \"-prefetchi\" \"-target-feature\" \"-rdpid\" \"-target-feature\" \"-fma4\" \"-target-feature\" \"-avx512vbmi\" \"-target-feature\" \"-shstk\" \"-target-feature\" \"-vaes\" \"-target-feature\" \"-waitpkg\" \"-target-feature\" \"-sgx\" \"-target-feature\" \"+fxsr\" \"-target-feature\" \"+avx512dq\" \"-target-feature\" \"-sse4a\" \"-debugger-tuning=gdb\" \"-fdebug-compilation-dir=/scratch3/opt/qmcpack/build_clangPatched_real/src/QMCHamiltonians\" \"-fcoverage-compilation-dir=/scratch3/opt/qmcpack/build_clangPatched_real/src/QMCHamiltonians\" \"-sys-header-deps\" \"-D\" \"ADD_\" \"-D\" \"H5_USE_110_API\" \"-D\" \"HAVE_CONFIG_H\" \"-D\" \"HAVE_EINSPLINE\" \"-D\" \"HAVE_LIBBOOST\" \"-D\" \"HAVE_LIBFFTW\" \"-D\" \"HAVE_MKL\" \"-D\" \"HAVE_MKL_VML\" \"-D\" \"MPICH_SKIP_MPICXX\" \"-D\" \"OMPI_SKIP_MPICXX\" \"-D\" \"OPENMP_NO_COMPLEX\" \"-D\" \"_MPICC_H\" \"-D\" \"restrict=__restrict__\" \"-D\" \"NDEBUG\" \"-O3\" \"-Wvla\" \"-Wall\" \"-Wno-unused-variable\" \"-Wno-overloaded-virtual\" \"-Wno-unused-private-field\" \"-Wno-unused-local-typedef\" \"-Wsuggest-override\" \"-Wno-unknown-pragmas\" \"-Wmisleading-indentation\" \"-std=c++17\" \"-fdeprecated-macro\" \"-ferror-limit\" \"19\" \"-fopenmp\" \"-fgnuc-version=4.2.1\" \"-fskip-odr-check-in-gmf\" \"-fcxx-exceptions\" \"-fexceptions\" \"-fcolor-diagnostics\" \"-vectorize-loops\" \"-vectorize-slp\" \"-faddrsig\" \"-D__GCC_HAVE_DWARF2_CFI_ASM=1\" \"-x\" \"c++\" \"PairCorrEstimator-40412c.cpp\"\r\n```",
51
+ "author": "ye-luo",
52
+ "labels": [
53
+ "vectorizers",
54
+ "crash"
55
+ ],
56
+ "comments": []
57
+ },
58
+ "verified": true
59
+ }
dataset/107036.json ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "107036",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/107036",
4
+ "bug_type": "crash",
5
+ "base_commit": "70a19adbc60c738903bbbb8e6d5ef2d41b681089",
6
+ "knowledge_cutoff": "2024-09-03T01:22:22Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/SLPVectorizer"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "f381cd069965dabfeb277f30a4e532d7fd498f6e",
12
+ "components": [
13
+ "SLPVectorizer"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
17
+ [
18
+ 16055,
19
+ 16069
20
+ ]
21
+ ]
22
+ },
23
+ "bug_location_funcname": {
24
+ "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
25
+ "BoUpSLP::computeMinimumValueSizes"
26
+ ]
27
+ }
28
+ },
29
+ "patch": "commit f381cd069965dabfeb277f30a4e532d7fd498f6e\nAuthor: Alexey Bataev <[email protected]>\nDate: Tue Sep 3 04:52:47 2024 -0700\n\n [SLP]Fix PR107036: Check if the type of the user is sizable before requesting its size.\n \n Only some instructions should be considered as potentially reducing the\n size of the operands types, not all instructions should be considered.\n \n Fixes https://github.com/llvm/llvm-project/issues/107036\n\ndiff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\nindex 58137cd6f543..f58803fc56a2 100644\n--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n@@ -16055,15 +16055,16 @@ void BoUpSLP::computeMinimumValueSizes() {\n const TreeEntry *UserTE = E.UserTreeIndices.back().UserTE;\n if (TE == UserTE || !TE)\n return false;\n+ if (!isa<CastInst, BinaryOperator, FreezeInst, PHINode,\n+ SelectInst>(U) ||\n+ !isa<CastInst, BinaryOperator, FreezeInst, PHINode,\n+ SelectInst>(UserTE->getMainOp()))\n+ return true;\n unsigned UserTESz = DL->getTypeSizeInBits(\n UserTE->Scalars.front()->getType());\n auto It = MinBWs.find(TE);\n if (It != MinBWs.end() && It->second.first > UserTESz)\n return true;\n- // The size of icmp is always 1 and should not be\n- // considered.\n- if (TE->getOpcode() == Instruction::ICmp)\n- return true;\n return DL->getTypeSizeInBits(U->getType()) > UserTESz;\n }));\n })) {\n",
30
+ "tests": [
31
+ {
32
+ "file": "llvm/test/Transforms/SLPVectorizer/X86/minbw-user-non-sizable.ll",
33
+ "commands": [
34
+ "opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu < %s -slp-threshold=-100"
35
+ ],
36
+ "tests": [
37
+ {
38
+ "test_name": "test",
39
+ "test_body": "define void @test(ptr %i) {\nbb:\n %i1 = getelementptr i8, ptr %i, i64 4\n br label %bb2\n\nbb2: ; preds = %bb2, %bb\n %i3 = phi i32 [ %i6, %bb2 ], [ 0, %bb ]\n %i4 = phi i32 [ %i8, %bb2 ], [ 0, %bb ]\n store i32 %i3, ptr %i, align 4\n store i32 %i4, ptr %i1, align 4\n %i5 = trunc i32 0 to i1\n %i6 = select i1 %i5, i32 0, i32 0\n %i7 = trunc i32 %i4 to i1\n %i8 = select i1 %i7, i32 0, i32 0\n br label %bb2\n}\n"
40
+ }
41
+ ]
42
+ }
43
+ ],
44
+ "issue": {
45
+ "title": "[SLP] Cannot getTypeInfo() on a type that is unsized!",
46
+ "body": "I tried the following IR with SLP:\r\n\r\n```llvm\r\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\r\ntarget triple = \"x86_64-unknown-linux-gnu\"\r\n\r\ndefine void @foo(ptr %i) {\r\nbb:\r\n %i1 = getelementptr i8, ptr %i, i64 4\r\n br label %bb2\r\n\r\nbb2: ; preds = %bb2, %bb\r\n %i3 = phi i32 [ %i6, %bb2 ], [ 0, %bb ]\r\n %i4 = phi i32 [ %i8, %bb2 ], [ 0, %bb ]\r\n store i32 %i3, ptr %i\r\n store i32 %i4, ptr %i1\r\n %i5 = trunc i32 0 to i1\r\n %i6 = select i1 %i5, i32 0, i32 0\r\n %i7 = trunc i32 %i4 to i1\r\n %i8 = select i1 %i7, i32 0, i32 0\r\n br label %bb2\r\n}\r\n```\r\n\r\nIt failed with an error output:`Ty->isSized() && \"Cannot getTypeInfo() on a type that is unsized!\"' failed`. It's getting the size returned by the `store i32 %i4, ptr %i1` instruction.\u200b\r\n\r\nhttps://llvm.godbolt.org/z/fMx9qMcfK\r\n\r\ncc f6e01b9ece1e73f6eda6e1dbff3aa72e917f4007 @alexey-bataev\r\n",
47
+ "author": "DianQK",
48
+ "labels": [
49
+ "release:backport",
50
+ "llvm:SLPVectorizer",
51
+ "crash-on-valid"
52
+ ],
53
+ "comments": [
54
+ {
55
+ "author": "dtcxzyw",
56
+ "body": "https://github.com/llvm/llvm-project/blob/2cbd1bc830861bc08f78fb6cc11747b82f66c4c6/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp#L16067\r\n\r\n`U` is `store i32 %i4, ptr %i1`.\r\n"
57
+ },
58
+ {
59
+ "author": "DianQK",
60
+ "body": "Reverting f6e01b9ece1e73f6eda6e1dbff3aa72e917f4007 seems reasonable to me. What do you think? @alexey-bataev ^^"
61
+ },
62
+ {
63
+ "author": "alexey-bataev",
64
+ "body": "will fix it asap today"
65
+ }
66
+ ]
67
+ },
68
+ "verified": true
69
+ }
dataset/107051.json ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "107051",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/107051",
4
+ "bug_type": "crash",
5
+ "base_commit": "fcb7b390ccd5b4cfc71f13b5e16a846f3f400c10",
6
+ "knowledge_cutoff": "2024-09-03T06:19:24Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/LoopVectorize"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "3bd161e98d89d31696002994771b7761f1c74859",
12
+ "components": [
13
+ "LoopVectorize"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
17
+ [
18
+ 1290,
19
+ 1297
20
+ ],
21
+ [
22
+ 6194,
23
+ 6199
24
+ ],
25
+ [
26
+ 6206,
27
+ 6219
28
+ ],
29
+ [
30
+ 6229,
31
+ 6248
32
+ ]
33
+ ]
34
+ },
35
+ "bug_location_funcname": {
36
+ "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
37
+ "LoopVectorizationCostModel::setVectorizedCallDecision",
38
+ "collectUniformsAndScalars"
39
+ ]
40
+ }
41
+ },
42
+ "patch": "commit 3bd161e98d89d31696002994771b7761f1c74859\nAuthor: Florian Hahn <[email protected]>\nDate: Tue Sep 3 21:06:31 2024 +0100\n\n [LV] Honor forced scalars in setVectorizedCallDecision.\n \n Similarly to dd94537b4, setVectorizedCallDecision also did not consider\n ForcedScalars. This lead to VPlans not reflecting the decision by the\n legacy cost model (cost computation would use scalar cost, VPlan would\n have VPWidenCallRecipe).\n \n To fix this, check if the call has been forced to scalar in\n setVectorizedCallDecision.\n \n Note that this requires moving setVectorizedCallDecision after\n collectLoopUniforms (which sets ForcedScalars). collectLoopUniforms does\n not depend on call decisions and can safely be moved.\n \n Fixes https://github.com/llvm/llvm-project/issues/107051.\n\ndiff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\nindex 17050b2b433c..0200525a718d 100644\n--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\n+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\n@@ -1290,8 +1290,8 @@ public:\n if (VF.isScalar() || Uniforms.contains(VF))\n return;\n setCostBasedWideningDecision(VF);\n- setVectorizedCallDecision(VF);\n collectLoopUniforms(VF);\n+ setVectorizedCallDecision(VF);\n collectLoopScalars(VF);\n }\n \n@@ -6194,6 +6194,7 @@ void LoopVectorizationCostModel::setVectorizedCallDecision(ElementCount VF) {\n assert(!VF.isScalar() &&\n \"Trying to set a vectorization decision for a scalar VF\");\n \n+ auto ForcedScalar = ForcedScalars.find(VF);\n for (BasicBlock *BB : TheLoop->blocks()) {\n // For each instruction in the old loop.\n for (Instruction &I : *BB) {\n@@ -6206,14 +6207,37 @@ void LoopVectorizationCostModel::setVectorizedCallDecision(ElementCount VF) {\n InstructionCost VectorCost = InstructionCost::getInvalid();\n InstructionCost IntrinsicCost = InstructionCost::getInvalid();\n TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput;\n-\n Function *ScalarFunc = CI->getCalledFunction();\n Type *ScalarRetTy = CI->getType();\n SmallVector<Type *, 4> Tys, ScalarTys;\n- bool MaskRequired = Legal->isMaskRequired(CI);\n for (auto &ArgOp : CI->args())\n ScalarTys.push_back(ArgOp->getType());\n \n+ // Estimate cost of scalarized vector call. The source operands are\n+ // assumed to be vectors, so we need to extract individual elements from\n+ // there, execute VF scalar calls, and then gather the result into the\n+ // vector return value.\n+ InstructionCost ScalarCallCost =\n+ TTI.getCallInstrCost(ScalarFunc, ScalarRetTy, ScalarTys, CostKind);\n+\n+ // Compute costs of unpacking argument values for the scalar calls and\n+ // packing the return values to a vector.\n+ InstructionCost ScalarizationCost =\n+ getScalarizationOverhead(CI, VF, CostKind);\n+\n+ ScalarCost = ScalarCallCost * VF.getKnownMinValue() + ScalarizationCost;\n+ // Honor ForcedScalars decision.\n+ // TODO: For calls, it might still be more profitable to widen. Use\n+ // VPlan-based cost model to compare different options.\n+ if (VF.isVector() && ForcedScalar != ForcedScalars.end() &&\n+ ForcedScalar->second.contains(CI)) {\n+ setCallWideningDecision(CI, VF, CM_Scalarize, nullptr,\n+ Intrinsic::not_intrinsic, std::nullopt,\n+ ScalarCost);\n+ continue;\n+ }\n+\n+ bool MaskRequired = Legal->isMaskRequired(CI);\n // Compute corresponding vector type for return value and arguments.\n Type *RetTy = ToVectorTy(ScalarRetTy, VF);\n for (Type *ScalarTy : ScalarTys)\n@@ -6229,20 +6253,6 @@ void LoopVectorizationCostModel::setVectorizedCallDecision(ElementCount VF) {\n continue;\n }\n \n- // Estimate cost of scalarized vector call. The source operands are\n- // assumed to be vectors, so we need to extract individual elements from\n- // there, execute VF scalar calls, and then gather the result into the\n- // vector return value.\n- InstructionCost ScalarCallCost =\n- TTI.getCallInstrCost(ScalarFunc, ScalarRetTy, ScalarTys, CostKind);\n-\n- // Compute costs of unpacking argument values for the scalar calls and\n- // packing the return values to a vector.\n- InstructionCost ScalarizationCost =\n- getScalarizationOverhead(CI, VF, CostKind);\n-\n- ScalarCost = ScalarCallCost * VF.getKnownMinValue() + ScalarizationCost;\n-\n // Find the cost of vectorizing the call, if we can find a suitable\n // vector variant of the function.\n bool UsesMask = false;\n",
43
+ "tests": [
44
+ {
45
+ "file": "llvm/test/Transforms/LoopVectorize/AArch64/call-costs.ll",
46
+ "commands": [
47
+ "opt -p loop-vectorize -S %s"
48
+ ],
49
+ "tests": [
50
+ {
51
+ "test_name": "call_forced_scalar",
52
+ "test_body": "target triple = \"arm64-apple-macosx11.0.0\"\n\ndefine void @call_forced_scalar(ptr %src.1, ptr %src.2, ptr noalias %dst.1, ptr noalias %dst.2) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %0 = load i32, ptr %src.1, align 4\n %smax = tail call i32 @llvm.smax.i32(i32 %0, i32 0)\n %umin = tail call i32 @llvm.umin.i32(i32 %smax, i32 1)\n %umin.ext = zext i32 %umin to i64\n %gep.src.2 = getelementptr i8, ptr %src.2, i64 %umin.ext\n %1 = load i8, ptr %gep.src.2, align 1\n %l.ext = zext i8 %1 to i32\n %mul = mul i32 3, %l.ext\n store i32 %mul, ptr %dst.1, align 4\n %gep.dst.2 = getelementptr i32, ptr %dst.2, i64 %iv\n store i32 0, ptr %gep.dst.2, align 4\n %iv.next = add i64 %iv, 1\n %ec = icmp eq i64 %iv.next, 0\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.smax.i32(i32, i32) #0\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i32 @llvm.umin.i32(i32, i32) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"
53
+ },
54
+ {
55
+ "test_name": "call_scalarized",
56
+ "test_body": "target triple = \"arm64-apple-macosx11.0.0\"\n\ndefine void @call_scalarized(ptr noalias %src, ptr noalias %dst, double %0) {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i64 [ 100, %entry ], [ %iv.next, %loop.latch ]\n %iv.next = add i64 %iv, -1\n %gep.src = getelementptr double, ptr %src, i64 %iv.next\n %l = load double, ptr %gep.src, align 8\n %cmp295 = fcmp ugt double %0, 0.000000e+00\n %cmp299 = fcmp ugt double %l, 0.000000e+00\n %or.cond = or i1 %cmp295, %cmp299\n br i1 %or.cond, label %loop.latch, label %then\n\nthen: ; preds = %loop.header\n %sqrt = call double @llvm.sqrt.f64(double %l)\n %gep.dst = getelementptr double, ptr %dst, i64 %iv.next\n store double %sqrt, ptr %gep.dst, align 8\n br label %loop.latch\n\nloop.latch: ; preds = %then, %loop.header\n %tobool.not = icmp eq i64 %iv.next, 0\n br i1 %tobool.not, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n ret void\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare double @llvm.sqrt.f64(double) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"
57
+ },
58
+ {
59
+ "test_name": "fshl_operand_first_order_recurrence",
60
+ "test_body": "target triple = \"arm64-apple-macosx11.0.0\"\n\ndefine void @fshl_operand_first_order_recurrence(ptr %dst, ptr noalias %src) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %recur = phi i64 [ 0, %entry ], [ %l, %loop ]\n %gep.src = getelementptr inbounds i64, ptr %src, i64 %iv\n %l = load i64, ptr %gep.src, align 8\n %or = tail call i64 @llvm.fshl.i64(i64 1, i64 %recur, i64 1)\n %gep.dst = getelementptr inbounds i64, ptr %dst, i64 %iv\n store i64 %or, ptr %gep.dst, align 8\n %iv.next = add i64 %iv, 1\n %exitcond.not = icmp eq i64 %iv, 100\n br i1 %exitcond.not, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i64 @llvm.fshl.i64(i64, i64, i64) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"
61
+ },
62
+ {
63
+ "test_name": "powi_call",
64
+ "test_body": "target triple = \"arm64-apple-macosx11.0.0\"\n\ndefine void @powi_call(ptr %P) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %gep = getelementptr inbounds double, ptr %P, i64 %iv\n %l = load double, ptr %gep, align 8\n %powi = tail call double @llvm.powi.f64.i32(double %l, i32 3)\n store double %powi, ptr %gep, align 8\n %iv.next = add i64 %iv, 1\n %ec = icmp eq i64 %iv, 1\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare double @llvm.powi.f64.i32(double, i32) #0\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"
65
+ }
66
+ ]
67
+ }
68
+ ],
69
+ "issue": {
70
+ "title": "[clang] Assertion failed in Vectorize",
71
+ "body": "I compiled this code with -Os and a crash appeared in assertion failure:\r\n\r\n```c\r\n#include <stdint.h>\r\nint32_t *c;\r\nint8_t ****d;\r\nuint64_t g;\r\nint a();\r\nlong b(long, long h, long p3) {\r\n long e;\r\n int f = 0;\r\n if (h) {\r\n e = h;\r\n f = 1;\r\n }\r\n if (e > p3)\r\n f = 2;\r\n switch (f) {\r\n case 1:\r\n e++;\r\n case 2:\r\n e--;\r\n }\r\n if (e < h)\r\n e = h;\r\n return e;\r\n}\r\n\r\nuint8_t div_func_uint8_t_u_u(uint8_t ui1, uint8_t ui2)\r\n{\r\n return (ui1 / ui2);\r\n}\r\n\r\nuint64_t j() {\r\n uint16_t k[8];\r\n int i;\r\n for (i = 0; *c + ****d + (int)g + i < 8; i++)\r\n k[b(0, g, 0)] = 6;\r\n *c = div_func_uint8_t_u_u(k[6], a());\r\n}\r\n```\r\n\r\nThe crash is:\r\n```\r\nclang: /root/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:7369: llvm::VectorizationFactor llvm::LoopVectorizationPlanner::computeBestVF(): Assertion `(BestFactor.Width == LegacyVF.Width || planContainsAdditionalSimplifications(getPlanFor(BestFactor.Width), CostCtx, OrigLoop)) && \" VPlan cost model and legacy cost model disagreed\"' failed.\r\n```\r\n\r\nDetails can be found here: https://godbolt.org/z/T81adKPY5\r\n\r\n",
72
+ "author": "cardigan1008",
73
+ "labels": [
74
+ "vectorizers",
75
+ "crash"
76
+ ],
77
+ "comments": [
78
+ {
79
+ "author": "patrick-rivos",
80
+ "body": "Unreduced LLVM IR:\r\n```llvm ir\r\n; ModuleID = '/app/example.c'\r\nsource_filename = \"/app/example.c\"\r\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\r\ntarget triple = \"x86_64-unknown-linux-gnu\"\r\n\r\n@c = dso_local local_unnamed_addr global ptr null, align 8\r\n@d = dso_local local_unnamed_addr global ptr null, align 8\r\n@g = dso_local local_unnamed_addr global i64 0, align 8\r\n\r\n; Function Attrs: mustprogress nofree norecurse nosync nounwind optsize willreturn memory(none) uwtable\r\ndefine dso_local i64 @b(i64 noundef %0, i64 noundef %h, i64 noundef %p3) local_unnamed_addr #0 {\r\nentry:\r\n %tobool.not = icmp ne i64 %h, 0\r\n %spec.select = zext i1 %tobool.not to i32\r\n %cmp = icmp sgt i64 %h, %p3\r\n %f.1 = select i1 %cmp, i32 2, i32 %spec.select\r\n switch i32 %f.1, label %sw.epilog [\r\n i32 1, label %sw.bb\r\n i32 2, label %sw.bb3\r\n ]\r\n\r\nsw.bb: ; preds = %entry\r\n %inc = add nsw i64 %h, 1\r\n br label %sw.bb3\r\n\r\nsw.bb3: ; preds = %entry, %sw.bb\r\n %e.1 = phi i64 [ %h, %entry ], [ %inc, %sw.bb ]\r\n %dec = add nsw i64 %e.1, -1\r\n br label %sw.epilog\r\n\r\nsw.epilog: ; preds = %sw.bb3, %entry\r\n %e.2 = phi i64 [ %h, %entry ], [ %dec, %sw.bb3 ]\r\n %spec.select14 = tail call i64 @llvm.smax.i64(i64 %e.2, i64 %h)\r\n ret i64 %spec.select14\r\n}\r\n\r\n; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)\r\ndeclare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1\r\n\r\n; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)\r\ndeclare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1\r\n\r\n; Function Attrs: mustprogress nofree norecurse nosync nounwind optsize willreturn memory(none) uwtable\r\ndefine dso_local noundef zeroext i8 @div_func_uint8_t_u_u(i8 noundef zeroext %ui1, i8 noundef zeroext %ui2) local_unnamed_addr #0 {\r\nentry:\r\n %0 = udiv i8 %ui1, %ui2\r\n ret i8 %0\r\n}\r\n\r\n; Function Attrs: nounwind optsize uwtable\r\ndefine dso_local i64 @j() local_unnamed_addr #2 {\r\nentry:\r\n %k = alloca [8 x i16], align 16\r\n call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %k) #5\r\n %0 = load ptr, ptr @c, align 8, !tbaa !6\r\n %1 = load i32, ptr %0, align 4, !tbaa !10\r\n %2 = load ptr, ptr @d, align 8, !tbaa !6\r\n %3 = load ptr, ptr %2, align 8, !tbaa !6\r\n %4 = load ptr, ptr %3, align 8, !tbaa !6\r\n %5 = load ptr, ptr %4, align 8, !tbaa !6\r\n %6 = load i8, ptr %5, align 1, !tbaa !12\r\n %conv = sext i8 %6 to i32\r\n %7 = load i64, ptr @g, align 8, !tbaa !13\r\n %conv1 = trunc i64 %7 to i32\r\n %invariant.op = add i32 %conv, %conv1\r\n %add3.reass12 = add i32 %1, %invariant.op\r\n %cmp13 = icmp slt i32 %add3.reass12, 8\r\n br i1 %cmp13, label %for.body.lr.ph, label %for.end\r\n\r\nfor.body.lr.ph: ; preds = %entry\r\n %tobool.not.i = icmp ne i64 %7, 0\r\n %spec.select.i = zext i1 %tobool.not.i to i32\r\n %cmp.i = icmp sgt i64 %7, 0\r\n %f.1.i = select i1 %cmp.i, i32 2, i32 %spec.select.i\r\n %inc.i = add nsw i64 %7, 1\r\n br label %for.body\r\n\r\nfor.body: ; preds = %for.body.lr.ph, %b.exit\r\n %i.014 = phi i32 [ 0, %for.body.lr.ph ], [ %inc, %b.exit ]\r\n switch i32 %f.1.i, label %b.exit [\r\n i32 1, label %sw.bb.i\r\n i32 2, label %sw.bb3.i\r\n ]\r\n\r\nsw.bb.i: ; preds = %for.body\r\n br label %sw.bb3.i\r\n\r\nsw.bb3.i: ; preds = %sw.bb.i, %for.body\r\n %e.1.i = phi i64 [ %7, %for.body ], [ %inc.i, %sw.bb.i ]\r\n %dec.i = add nsw i64 %e.1.i, -1\r\n br label %b.exit\r\n\r\nb.exit: ; preds = %for.body, %sw.bb3.i\r\n %e.2.i = phi i64 [ %7, %for.body ], [ %dec.i, %sw.bb3.i ]\r\n %spec.select14.i = tail call i64 @llvm.smax.i64(i64 %e.2.i, i64 %7)\r\n %arrayidx = getelementptr inbounds [8 x i16], ptr %k, i64 0, i64 %spec.select14.i\r\n store i16 6, ptr %arrayidx, align 2, !tbaa !15\r\n %inc = add nuw nsw i32 %i.014, 1\r\n %add = add i32 %1, %inc\r\n %add3.reass = add i32 %add, %invariant.op\r\n %cmp = icmp slt i32 %add3.reass, 8\r\n br i1 %cmp, label %for.body, label %for.end.loopexit, !llvm.loop !17\r\n\r\nfor.end.loopexit: ; preds = %b.exit\r\n %arrayidx5.phi.trans.insert = getelementptr inbounds i8, ptr %k, i64 12\r\n %.pre = load i16, ptr %arrayidx5.phi.trans.insert, align 4, !tbaa !15\r\n %8 = trunc i16 %.pre to i8\r\n br label %for.end\r\n\r\nfor.end: ; preds = %for.end.loopexit, %entry\r\n %conv6 = phi i8 [ %8, %for.end.loopexit ], [ undef, %entry ]\r\n %call7 = tail call i32 (...) @a() #6\r\n %conv8 = trunc i32 %call7 to i8\r\n %9 = udiv i8 %conv6, %conv8\r\n %conv10 = zext i8 %9 to i32\r\n %10 = load ptr, ptr @c, align 8, !tbaa !6\r\n store i32 %conv10, ptr %10, align 4, !tbaa !10\r\n call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %k) #5\r\n ret i64 undef\r\n}\r\n\r\n; Function Attrs: optsize\r\ndeclare i32 @a(...) local_unnamed_addr #3\r\n\r\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\r\ndeclare i64 @llvm.smax.i64(i64, i64) #4\r\n\r\nattributes #0 = { mustprogress nofree norecurse nosync nounwind optsize willreturn memory(none) uwtable \"min-legal-vector-width\"=\"0\" \"no-trapping-math\"=\"true\" \"stack-protector-buffer-size\"=\"8\" \"target-cpu\"=\"x86-64\" \"target-features\"=\"+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87\" \"tune-cpu\"=\"generic\" }\r\nattributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }\r\nattributes #2 = { nounwind optsize uwtable \"min-legal-vector-width\"=\"0\" \"no-trapping-math\"=\"true\" \"stack-protector-buffer-size\"=\"8\" \"target-cpu\"=\"x86-64\" \"target-features\"=\"+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87\" \"tune-cpu\"=\"generic\" }\r\nattributes #3 = { optsize \"no-trapping-math\"=\"true\" \"stack-protector-buffer-size\"=\"8\" \"target-cpu\"=\"x86-64\" \"target-features\"=\"+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87\" \"tune-cpu\"=\"generic\" }\r\nattributes #4 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\r\nattributes #5 = { nounwind }\r\nattributes #6 = { nounwind optsize }\r\n\r\n!llvm.module.flags = !{!0, !1, !2, !3, !4}\r\n!llvm.ident = !{!5}\r\n\r\n!0 = !{i32 7, !\"Dwarf Version\", i32 4}\r\n!1 = !{i32 1, !\"wchar_size\", i32 4}\r\n!2 = !{i32 8, !\"PIC Level\", i32 2}\r\n!3 = !{i32 7, !\"PIE Level\", i32 2}\r\n!4 = !{i32 7, !\"uwtable\", i32 2}\r\n!5 = !{!\"clang version 20.0.0git (https://github.com/llvm/llvm-project.git b6597f521d8a040f2b9fee54b3f89c380de8e432)\"}\r\n!6 = !{!7, !7, i64 0}\r\n!7 = !{!\"any pointer\", !8, i64 0}\r\n!8 = !{!\"omnipotent char\", !9, i64 0}\r\n!9 = !{!\"Simple C/C++ TBAA\"}\r\n!10 = !{!11, !11, i64 0}\r\n!11 = !{!\"int\", !8, i64 0}\r\n!12 = !{!8, !8, i64 0}\r\n!13 = !{!14, !14, i64 0}\r\n!14 = !{!\"long\", !8, i64 0}\r\n!15 = !{!16, !16, i64 0}\r\n!16 = !{!\"short\", !8, i64 0}\r\n!17 = distinct !{!17, !18}\r\n!18 = !{!\"llvm.loop.mustprogress\"}\r\n```\r\n\r\nhttps://godbolt.org/z/Yo1crEjGG\r\n\r\ncc @fhahn "
81
+ }
82
+ ]
83
+ },
84
+ "verified": true
85
+ }
dataset/107139.json ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "107139",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/107139",
4
+ "bug_type": "crash",
5
+ "base_commit": "5d17293caaf0f62ea94fecc137b9b6f07c659dac",
6
+ "knowledge_cutoff": "2024-09-03T18:28:59Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/Coroutines"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "853bff2122e1f42398587f76234c05d56f16318e",
12
+ "components": [
13
+ "Coroutines"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Coroutines/CoroSplit.cpp": [
17
+ [
18
+ 2080,
19
+ 2091
20
+ ],
21
+ [
22
+ 2105,
23
+ 2117
24
+ ],
25
+ [
26
+ 2200,
27
+ 2205
28
+ ],
29
+ [
30
+ 2211,
31
+ 2217
32
+ ],
33
+ [
34
+ 2223,
35
+ 2236
36
+ ]
37
+ ]
38
+ },
39
+ "bug_location_funcname": {
40
+ "llvm/lib/Transforms/Coroutines/CoroSplit.cpp": [
41
+ "CoroSplitPass::run",
42
+ "replacePrepare",
43
+ "splitCoroutine",
44
+ "updateCallGraphAfterCoroutineSplit"
45
+ ]
46
+ }
47
+ },
48
+ "patch": "commit 853bff2122e1f42398587f76234c05d56f16318e\nAuthor: Yuxuan Chen <[email protected]>\nDate: Thu Sep 12 10:45:20 2024 -0700\n\n [Coroutines] properly update CallGraph in CoroSplit (#107935)\n \n Fixes https://github.com/llvm/llvm-project/issues/107139.\n \n We weren't updating the call graph properly in CoroSplit. This crash is\n due to the await_suspend() function calling the coroutine, forming a\n multi-node SCC. The issue bisected to\n https://github.com/llvm/llvm-project/pull/79712 but I think this is red\n herring. We haven't been properly updating the call graph.\n \n Added an example of such code as a test case.\n\ndiff --git a/llvm/lib/Transforms/Coroutines/CoroSplit.cpp b/llvm/lib/Transforms/Coroutines/CoroSplit.cpp\nindex dc3829d7f28e..8ea460badaad 100644\n--- a/llvm/lib/Transforms/Coroutines/CoroSplit.cpp\n+++ b/llvm/lib/Transforms/Coroutines/CoroSplit.cpp\n@@ -2080,12 +2080,13 @@ splitCoroutine(Function &F, SmallVectorImpl<Function *> &Clones,\n return Shape;\n }\n \n-static void updateCallGraphAfterCoroutineSplit(\n+static LazyCallGraph::SCC &updateCallGraphAfterCoroutineSplit(\n LazyCallGraph::Node &N, const coro::Shape &Shape,\n const SmallVectorImpl<Function *> &Clones, LazyCallGraph::SCC &C,\n LazyCallGraph &CG, CGSCCAnalysisManager &AM, CGSCCUpdateResult &UR,\n FunctionAnalysisManager &FAM) {\n \n+ auto *CurrentSCC = &C;\n if (!Clones.empty()) {\n switch (Shape.ABI) {\n case coro::ABI::Switch:\n@@ -2105,13 +2106,16 @@ static void updateCallGraphAfterCoroutineSplit(\n }\n \n // Let the CGSCC infra handle the changes to the original function.\n- updateCGAndAnalysisManagerForCGSCCPass(CG, C, N, AM, UR, FAM);\n+ CurrentSCC = &updateCGAndAnalysisManagerForCGSCCPass(CG, *CurrentSCC, N, AM,\n+ UR, FAM);\n }\n \n // Do some cleanup and let the CGSCC infra see if we've cleaned up any edges\n // to the split functions.\n postSplitCleanup(N.getFunction());\n- updateCGAndAnalysisManagerForFunctionPass(CG, C, N, AM, UR, FAM);\n+ CurrentSCC = &updateCGAndAnalysisManagerForFunctionPass(CG, *CurrentSCC, N,\n+ AM, UR, FAM);\n+ return *CurrentSCC;\n }\n \n /// Replace a call to llvm.coro.prepare.retcon.\n@@ -2200,6 +2204,7 @@ PreservedAnalyses CoroSplitPass::run(LazyCallGraph::SCC &C,\n if (Coroutines.empty() && PrepareFns.empty())\n return PreservedAnalyses::all();\n \n+ auto *CurrentSCC = &C;\n // Split all the coroutines.\n for (LazyCallGraph::Node *N : Coroutines) {\n Function &F = N->getFunction();\n@@ -2211,7 +2216,8 @@ PreservedAnalyses CoroSplitPass::run(LazyCallGraph::SCC &C,\n coro::Shape Shape =\n splitCoroutine(F, Clones, FAM.getResult<TargetIRAnalysis>(F),\n OptimizeFrame, MaterializableCallback);\n- updateCallGraphAfterCoroutineSplit(*N, Shape, Clones, C, CG, AM, UR, FAM);\n+ CurrentSCC = &updateCallGraphAfterCoroutineSplit(\n+ *N, Shape, Clones, *CurrentSCC, CG, AM, UR, FAM);\n \n auto &ORE = FAM.getResult<OptimizationRemarkEmitterAnalysis>(F);\n ORE.emit([&]() {\n@@ -2223,14 +2229,14 @@ PreservedAnalyses CoroSplitPass::run(LazyCallGraph::SCC &C,\n \n if (!Shape.CoroSuspends.empty()) {\n // Run the CGSCC pipeline on the original and newly split functions.\n- UR.CWorklist.insert(&C);\n+ UR.CWorklist.insert(CurrentSCC);\n for (Function *Clone : Clones)\n UR.CWorklist.insert(CG.lookupSCC(CG.get(*Clone)));\n }\n }\n \n for (auto *PrepareFn : PrepareFns) {\n- replaceAllPrepares(PrepareFn, CG, C);\n+ replaceAllPrepares(PrepareFn, CG, *CurrentSCC);\n }\n \n return PreservedAnalyses::none();\n",
49
+ "tests": [
50
+ {
51
+ "file": "llvm/test/Transforms/Coroutines/gh107139-split-in-scc.ll",
52
+ "commands": [
53
+ "opt < %s -passes='cgscc(coro-split)' -S"
54
+ ],
55
+ "tests": [
56
+ {
57
+ "test_name": "<module>",
58
+ "test_body": "; Verify that we don't crash on mutually recursive coroutines\n\ntarget triple = \"x86_64-redhat-linux-gnu\"\n\ndefine void @foo() presplitcoroutine personality ptr null {\nentry:\n\n %0 = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr null)\n %1 = call ptr @llvm.coro.begin(token %0, ptr null)\n %2 = call token @llvm.coro.save(ptr null)\n %3 = call i8 @llvm.coro.suspend(token none, i1 false)\n %4 = call token @llvm.coro.save(ptr null)\n call void @llvm.coro.await.suspend.void(ptr null, ptr null, ptr @bar)\n ret void\n}\n\ndefine void @bar(ptr %0, ptr %1) {\nentry:\n call void @foo()\n ret void\n}\n\n\ndeclare token @llvm.coro.id(i32, ptr readnone, ptr nocapture readonly, ptr) #0\ndeclare ptr @llvm.coro.begin(token, ptr writeonly) nounwind\ndeclare token @llvm.coro.save(ptr) nomerge nounwind\ndeclare void @llvm.coro.await.suspend.void(ptr, ptr, ptr)\ndeclare i8 @llvm.coro.suspend(token, i1) nounwind\n\nattributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: read) }"
59
+ }
60
+ ]
61
+ }
62
+ ],
63
+ "issue": {
64
+ "title": "\"Invalidated the current SCC\" assertion failure after #79712",
65
+ "body": "For the source file in https://gist.github.com/smeenai/fcd14380467e813a28f1ef8c5484b775 (reduced from a large example that uses libunifex; it's probably possible to reduce this further but I'm not at all familiar with coroutines), the following command succeeds with Clang 18 but fails with Clang 19 and trunk:\r\n\r\n```\r\n$ clang -c -o /dev/null coroutine_crash.cpp -std=c++20 -w\r\nclang: llvm/lib/Analysis/CGSCCPassManager.cpp:1167: LazyCallGraph::SCC &updateCGAndAnalysisManagerForPass(llvm::LazyCallGraph &, LazyCallGraph::SCC &, LazyCallGraph::Node &, llvm::CGSCCAnalysisManager &, llvm::CGSCCUpdateResult &, llvm::FunctionAnalysisManager &, bool): Assertion `!UR.InvalidatedSCCs.count(C) && \"Invalidated the current SCC!\"' failed.\r\n```\r\n\r\nI bisected this to #79712. CC @fpasserby, @ChuanqiXu9, and @yuxuanchen1997 ",
66
+ "author": "smeenai",
67
+ "labels": [
68
+ "crash",
69
+ "coroutines",
70
+ "llvm:transforms"
71
+ ],
72
+ "comments": [
73
+ {
74
+ "author": "yuxuanchen1997",
75
+ "body": "I took a look at this and I think it was due to incorrect call graph updates. `updateCGAndAnalysisManagerFor(CGSCC|Function)Pass` seems to return an updated SCC but we discarded the updated SCC.\r\n\r\nSee example usage: https://github.com/llvm/llvm-project/blob/main/llvm/lib/Analysis/CGSCCPassManager.cpp#L561-L562\r\nSee implementation: https://github.com/llvm/llvm-project/blob/main/llvm/lib/Analysis/CGSCCPassManager.cpp#L1170-L1175\r\n\r\nI have a patch https://github.com/llvm/llvm-project/pull/107935 but still need some time for a test case. "
76
+ },
77
+ {
78
+ "author": "yuxuanchen1997",
79
+ "body": "This happens when foo has is not a single node SCC:\r\n```\r\ndefine void @foo() presplitcoroutine personality ptr null {\r\nentry:\r\n %0 = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr null)\r\n %1 = call ptr @llvm.coro.begin(token %0, ptr null)\r\n %2 = call token @llvm.coro.save(ptr null)\r\n %3 = call i8 @llvm.coro.suspend(token none, i1 false)\r\n %4 = call token @llvm.coro.save(ptr null)\r\n call void @llvm.coro.await.suspend.void(ptr null, ptr null, ptr @bar)\r\n ret void\r\n}\r\n\r\ndefine void @bar(ptr %0, ptr %1) {\r\nentry:\r\n call void @foo()\r\n ret void\r\n}\r\n\r\ndeclare token @llvm.coro.id(i32, ptr readnone, ptr nocapture readonly, ptr) #0\r\ndeclare ptr @llvm.coro.begin(token, ptr writeonly) nounwind\r\ndeclare token @llvm.coro.save(ptr) nomerge nounwind\r\ndeclare void @llvm.coro.await.suspend.void(ptr, ptr, ptr)\r\ndeclare i8 @llvm.coro.suspend(token, i1) nounwind\r\n\r\nattributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: read) }\r\n```\r\n\r\nRepro the crash with `clang -O0 bad.ll`."
80
+ },
81
+ {
82
+ "author": "yuxuanchen1997",
83
+ "body": "The 3rd argument to `@llvm.coro.await.suspend` is the `await_suspend` function in C++. This happens when `await_suspend()` calls the same coroutine from its body. "
84
+ }
85
+ ]
86
+ },
87
+ "verified": true
88
+ }
dataset/107171.json ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "107171",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/107171",
4
+ "bug_type": "crash",
5
+ "base_commit": "34f2c9a9ce73a61b27d75dab7e1eed256491afcc",
6
+ "knowledge_cutoff": "2024-09-04T00:23:05Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/LoopVectorize"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "3fe6a064f15cd854fd497594cc20e8b680cd2133",
12
+ "components": [
13
+ "LoopVectorize"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
17
+ [
18
+ 6606,
19
+ 6614
20
+ ]
21
+ ]
22
+ },
23
+ "bug_location_funcname": {
24
+ "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
25
+ "LoopVectorizationCostModel::getInstructionCost"
26
+ ]
27
+ }
28
+ },
29
+ "patch": "commit 3fe6a064f15cd854fd497594cc20e8b680cd2133\nAuthor: Florian Hahn <[email protected]>\nDate: Wed Sep 4 20:50:05 2024 +0100\n\n [LV] Check if compare is truncated directly in getInstructionCost.\n \n The current check for truncated compares in getInstructionCost misses\n cases where either the first or both operands are constants.\n Check directly if the compare is marked for truncation. In that case,\n the minimum bitwidth is that of the operands.\n \n The patch also adds asserts to ensure that.\n \n This fixes a divergence between legacy and VPlan-based cost model, where\n the legacy cost model incorrectly estimated the cost of compares with\n truncated operands.\n \n Fixes https://github.com/llvm/llvm-project/issues/107171.\n\ndiff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\nindex 0200525a718d..0ccf442dac99 100644\n--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\n+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\n@@ -6606,9 +6606,20 @@ LoopVectorizationCostModel::getInstructionCost(Instruction *I,\n case Instruction::ICmp:\n case Instruction::FCmp: {\n Type *ValTy = I->getOperand(0)->getType();\n+\n Instruction *Op0AsInstruction = dyn_cast<Instruction>(I->getOperand(0));\n- if (canTruncateToMinimalBitwidth(Op0AsInstruction, VF))\n- ValTy = IntegerType::get(ValTy->getContext(), MinBWs[Op0AsInstruction]);\n+ (void)Op0AsInstruction;\n+ assert((!canTruncateToMinimalBitwidth(Op0AsInstruction, VF) ||\n+ canTruncateToMinimalBitwidth(I, VF)) &&\n+ \"truncating Op0 must imply truncating the compare\");\n+ if (canTruncateToMinimalBitwidth(I, VF)) {\n+ assert(!canTruncateToMinimalBitwidth(Op0AsInstruction, VF) ||\n+ MinBWs[I] == MinBWs[Op0AsInstruction] &&\n+ \"if both the operand and the compare are marked for \"\n+ \"truncation, they must have the same bitwidth\");\n+ ValTy = IntegerType::get(ValTy->getContext(), MinBWs[I]);\n+ }\n+\n VectorTy = ToVectorTy(ValTy, VF);\n return TTI.getCmpSelInstrCost(I->getOpcode(), VectorTy, nullptr,\n cast<CmpInst>(I)->getPredicate(), CostKind,\n",
30
+ "tests": [
31
+ {
32
+ "file": "llvm/test/Transforms/LoopVectorize/RISCV/truncate-to-minimal-bitwidth-cost.ll",
33
+ "commands": [
34
+ "opt -p loop-vectorize -mattr=+v -S %s"
35
+ ],
36
+ "tests": [
37
+ {
38
+ "test_name": "test_pr98413_zext_removed",
39
+ "test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\ndefine void @test_pr98413_zext_removed(ptr %src, ptr noalias %dst, i64 %x) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %gep.src = getelementptr inbounds i16, ptr %src, i64 %iv\n %l = load i16, ptr %gep.src, align 8\n %ext.l = zext i16 %l to i64\n %and = and i64 %x, %ext.l\n %trunc.and = trunc i64 %and to i8\n %gep.dst = getelementptr inbounds i8, ptr %dst, i64 %iv\n store i8 %trunc.and, ptr %gep.dst, align 1\n %iv.next = add i64 %iv, 1\n %exitcond.not = icmp eq i64 %iv, 96\n br i1 %exitcond.not, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n"
40
+ },
41
+ {
42
+ "test_name": "truncate_to_i1_used_by_branch",
43
+ "test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\ndefine void @truncate_to_i1_used_by_branch(i8 %x, ptr %dst) #0 {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %f.039 = phi i8 [ 0, %entry ], [ %add, %loop.latch ]\n %0 = or i8 23, %x\n %extract.t = trunc i8 %0 to i1\n br i1 %extract.t, label %then, label %loop.latch\n\nthen: ; preds = %loop.header\n store i8 0, ptr %dst, align 1\n br label %loop.latch\n\nloop.latch: ; preds = %then, %loop.header\n %add = add i8 %f.039, 1\n %conv = sext i8 %f.039 to i32\n %cmp = icmp slt i32 %conv, 1\n br i1 %cmp, label %loop.header, label %exit\n\nexit: ; preds = %loop.latch\n ret void\n}\n\nattributes #0 = { \"target-features\"=\"+64bit,+v,+zvl256b\" }\n"
44
+ },
45
+ {
46
+ "test_name": "icmp_ops_narrowed_to_i1",
47
+ "test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\ndefine i8 @icmp_ops_narrowed_to_i1() #0 {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i16 [ 0, %entry ], [ %iv.next, %loop ]\n %c = icmp eq i8 0, 0\n %ext = zext i1 %c to i64\n %shr = lshr i64 %ext, 1\n %trunc = trunc i64 %shr to i8\n %iv.next = add i16 %iv, 1\n %ec = icmp eq i16 %iv.next, 100\n br i1 %ec, label %exit, label %loop\n\nexit: ; preds = %loop\n ret i8 %trunc\n}\n\nattributes #0 = { \"target-features\"=\"+64bit,+v\" }\n"
48
+ },
49
+ {
50
+ "test_name": "test_pr98413_sext_removed",
51
+ "test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\ntarget triple = \"riscv64-unknown-linux-gnu\"\n\ndefine void @test_pr98413_sext_removed(ptr %src, ptr noalias %dst, i64 %x) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]\n %gep.src = getelementptr inbounds i16, ptr %src, i64 %iv\n %l = load i16, ptr %gep.src, align 8\n %ext.l = sext i16 %l to i64\n %and = and i64 %x, %ext.l\n %trunc.and = trunc i64 %and to i8\n %gep.dst = getelementptr inbounds i8, ptr %dst, i64 %iv\n store i8 %trunc.and, ptr %gep.dst, align 1\n %iv.next = add i64 %iv, 1\n %exitcond.not = icmp eq i64 %iv, 96\n br i1 %exitcond.not, label %exit, label %loop\n\nexit: ; preds = %loop\n ret void\n}\n"
52
+ }
53
+ ]
54
+ }
55
+ ],
56
+ "issue": {
57
+ "title": "[VPlan] Assertion \" VPlan cost model and legacy cost model disagreed\"' failed.",
58
+ "body": "Testing using 3bd161e98d89d31696002994771b7761f1c74859\r\n\r\nC testcase:\r\n```c\r\nchar a;\r\nunsigned b = 221;\r\nshort c = 35;\r\nchar d[6];\r\nint main() {\r\n d[0] = 4079751220931503459;\r\n for (short e = 3; e; e += 3)\r\n for (short f = 0; f < 1; f += -1832)\r\n for (long g = ({\r\n __typeof__(0) h = !d[f * 1];\r\n h;\r\n });\r\n g < c - 3; g += b - 219)\r\n a -= 8;\r\n}\r\n```\r\n`/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/clang -I/scratch/tc-testing/compiler-fuzz-ci/csmith-build/include -fsigned-char -fno-strict-aliasing -fwrapv -march=rv64gcv -flto -O3 -fuse-ld=lld red.c -o rv64gcv.out -w`\r\n\r\nLLVM IR:\r\n```llvm ir\r\n; ModuleID = 'reduced.bc'\r\ntarget datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\r\ntarget triple = \"riscv64-unknown-linux-gnu\"\r\n\r\ndefine i32 @main() #0 {\r\nentry:\r\n br label %for.body14.preheader48\r\n\r\nfor.cond.cleanup: ; preds = %for.body14.preheader48\r\n store i8 %1, ptr null, align 1\r\n ret i32 0\r\n\r\nfor.body14.preheader48: ; preds = %for.body14.preheader48, %entry\r\n %e.047 = phi i16 [ 0, %entry ], [ %add27, %for.body14.preheader48 ]\r\n %tobool6.not = icmp eq i8 0, 0\r\n %conv7 = zext i1 %tobool6.not to i64\r\n %0 = lshr i64 %conv7, 1\r\n %1 = trunc i64 %0 to i8\r\n %add27 = add i16 %e.047, 1\r\n %tobool.not = icmp eq i16 %add27, 0\r\n br i1 %tobool.not, label %for.cond.cleanup, label %for.body14.preheader48\r\n}\r\n\r\nattributes #0 = { \"target-features\"=\"+64bit,+a,+c,+d,+f,+m,+relax,+v,+zicsr,+zifencei,+zmmul,+zve32f,+zve32x,+zve64d,+zve64f,+zve64x,+zvl128b,+zvl32b,+zvl64b,-b,-e,-experimental-smctr,-experimental-smmpm,-experimental-smnpm,-experimental-ssctr,-experimental-ssnpm,-experimental-sspm,-experimental-supm,-experimental-zacas,-experimental-zalasr,-experimental-zicfilp,-experimental-zicfiss,-experimental-zvbc32e,-experimental-zvkgs,-h,-shcounterenw,-shgatpa,-shtvala,-shvsatpa,-shvstvala,-shvstvecd,-smaia,-smcdeleg,-smcsrind,-smepmp,-smstateen,-ssaia,-ssccfg,-ssccptr,-sscofpmf,-sscounterenw,-sscsrind,-ssqosid,-ssstateen,-ssstrict,-sstc,-sstvala,-sstvecd,-ssu64xl,-svade,-svadu,-svbare,-svinval,-svnapot,-svpbmt,-xcvalu,-xcvbi,-xcvbitmanip,-xcvelw,-xcvmac,-xcvmem,-xcvsimd,-xsfcease,-xsfvcp,-xsfvfnrclipxfqf,-xsfvfwmaccqqq,-xsfvqmaccdod,-xsfvqmaccqoq,-xsifivecdiscarddlone,-xsifivecflushdlone,-xtheadba,-xtheadbb,-xtheadbs,-xtheadcmo,-xtheadcondmov,-xtheadfmemidx,-xtheadmac,-xtheadmemidx,-xtheadmempair,-xtheadsync,-xtheadvdot,-xventanacondops,-xwchc,-za128rs,-za64rs,-zaamo,-zabha,-zalrsc,-zama16b,-zawrs,-zba,-zbb,-zbc,-zbkb,-zbkc,-zbkx,-zbs,-zca,-zcb,-zcd,-zce,-zcf,-zcmop,-zcmp,-zcmt,-zdinx,-zfa,-zfbfmin,-zfh,-zfhmin,-zfinx,-zhinx,-zhinxmin,-zic64b,-zicbom,-zicbop,-zicboz,-ziccamoa,-ziccif,-zicclsm,-ziccrse,-zicntr,-zicond,-zihintntl,-zihintpause,-zihpm,-zimop,-zk,-zkn,-zknd,-zkne,-zknh,-zkr,-zks,-zksed,-zksh,-zkt,-ztso,-zvbb,-zvbc,-zvfbfmin,-zvfbfwma,-zvfh,-zvfhmin,-zvkb,-zvkg,-zvkn,-zvknc,-zvkned,-zvkng,-zvknha,-zvknhb,-zvks,-zvksc,-zvksed,-zvksg,-zvksh,-zvkt,-zvl1024b,-zvl16384b,-zvl2048b,-zvl256b,-zvl32768b,-zvl4096b,-zvl512b,-zvl65536b,-zvl8192b\" }\r\n```\r\n\r\nCommand/backtrace:\r\n```\r\n /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt -passes=loop-vectorize reduced.ll -S\r\nopt: /scratch/tc-testing/tc-compiler-fuzz-trunk/llvm/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:7389: llvm::VectorizationFactor llvm::LoopVectorizationPlanner::computeBestVF(): Assertion `(BestFactor.Width == LegacyVF.Width || planContainsAdditionalSimplifications(getPlanFor(BestFactor.Width), CostCtx, OrigLoop)) && \" VPlan cost model and legacy cost model disagreed\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0. Program arguments: /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt -passes=loop-vectorize reduced.ll -S\r\n1. Running pass \"function(loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>)\" on module \"reduced.ll\"\r\n2. Running pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"main\"\r\n #0 0x000061eac73d9f50 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x3010f50)\r\n #1 0x000061eac73d735f llvm::sys::RunSignalHandlers() (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x300e35f)\r\n #2 0x000061eac73d74b5 SignalHandler(int) Signals.cpp:0:0\r\n #3 0x00007496e1242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #4 0x00007496e12969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\r\n #5 0x00007496e12969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10\r\n #6 0x00007496e12969fc pthread_kill ./nptl/pthread_kill.c:89:10\r\n #7 0x00007496e1242476 gsignal ./signal/../sysdeps/posix/raise.c:27:6\r\n #8 0x00007496e12287f3 abort ./stdlib/abort.c:81:7\r\n #9 0x00007496e122871b _nl_load_domain ./intl/loadmsgcat.c:1177:9\r\n#10 0x00007496e1239e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n#11 0x000061eac63ad810 llvm::LoopVectorizationPlanner::computeBestVF() (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1fe4810)\r\n#12 0x000061eac63c45bb llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1ffb5bb)\r\n#13 0x000061eac63c75d1 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1ffe5d1)\r\n#14 0x000061eac63c7c47 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1ffec47)\r\n#15 0x000061eac5222626 llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xe59626)\r\n#16 0x000061eac71e5cef llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2e1ccef)\r\n#17 0x000061eac52257b6 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xe5c7b6)\r\n#18 0x000061eac71e4a6b llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2e1ba6b)\r\n#19 0x000061eac5221a56 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xe58a56)\r\n#20 0x000061eac71e2aad llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2e19aad)\r\n#21 0x000061eac4a4fde6 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x686de6)\r\n#22 0x000061eac4a41b71 optMain (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x678b71)\r\n#23 0x00007496e1229d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16\r\n#24 0x00007496e1229e40 call_init ./csu/../csu/libc-start.c:128:20\r\n#25 0x00007496e1229e40 __libc_start_main ./csu/../csu/libc-start.c:379:5\r\n#26 0x000061eac4a37f25 _start (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x66ef25)\r\nzsh: IOT instruction (core dumped) /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt\r\n```\r\nhttps://godbolt.org/z/x316voG8q\r\n\r\nFound via fuzzer\r\n\r\nRelated/prior issue: https://github.com/llvm/llvm-project/issues/106780\r\n\r\ncc @fhahn",
59
+ "author": "patrick-rivos",
60
+ "labels": [
61
+ "vectorizers",
62
+ "crash"
63
+ ],
64
+ "comments": []
65
+ },
66
+ "verified": true
67
+ }
dataset/107198.json ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "107198",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/107198",
4
+ "bug_type": "crash",
5
+ "base_commit": "c2b92a4250b3f514685676ba8985ea73450f14d3",
6
+ "knowledge_cutoff": "2024-09-04T08:17:58Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/SLPVectorizer"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "d65ff3e9364536f9e0bd5f1c1bace626c256a2ad",
12
+ "components": [
13
+ "SLPVectorizer"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
17
+ [
18
+ 7780,
19
+ 7785
20
+ ]
21
+ ]
22
+ },
23
+ "bug_location_funcname": {
24
+ "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
25
+ "BoUpSLP::canMapToVector"
26
+ ]
27
+ }
28
+ },
29
+ "patch": "commit d65ff3e9364536f9e0bd5f1c1bace626c256a2ad\nAuthor: Alexey Bataev <[email protected]>\nDate: Wed Sep 4 05:12:17 2024 -0700\n\n [SLP]Fix PR107198: add a check for empty complex type\n \n Need to check if the complex type is empty before trying to dig in,\n trying to find vectorizable type\n \n Fixes https://github.com/llvm/llvm-project/issues/107198\n\ndiff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\nindex 19b95cf473e9..a2af7f4e1b01 100644\n--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n@@ -7780,6 +7780,8 @@ unsigned BoUpSLP::canMapToVector(Type *T) const {\n Type *EltTy = T;\n \n while (isa<StructType, ArrayType, FixedVectorType>(EltTy)) {\n+ if (EltTy->isEmptyTy())\n+ return 0;\n if (auto *ST = dyn_cast<StructType>(EltTy)) {\n // Check that struct is homogeneous.\n for (const auto *Ty : ST->elements())\n",
30
+ "tests": [
31
+ {
32
+ "file": "llvm/test/Transforms/SLPVectorizer/empty-struct.ll",
33
+ "commands": [
34
+ "opt -S --passes=slp-vectorizer < %s"
35
+ ],
36
+ "tests": [
37
+ {
38
+ "test_name": "test",
39
+ "test_body": "define { { {}, {}, {}, {}, {}, {}, {} } } @test({ {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, { {}, {}, {}, {}, {}, {}, {} }, { {} } } %0) {\n %2 = extractvalue { {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, { {}, {}, {}, {}, {}, {}, {} }, { {} } } %0, 18\n %3 = insertvalue { { {}, {}, {}, {}, {}, {}, {} } } undef, { {}, {}, {}, {}, {}, {}, {} } %2, 0\n ret { { {}, {}, {}, {}, {}, {}, {} } } %3\n}\n"
40
+ }
41
+ ]
42
+ }
43
+ ],
44
+ "issue": {
45
+ "title": "Crash on slp-vectorizer",
46
+ "body": "When running `/opt/llvm-19/bin/opt -O3 -S bug.ll` opt crashes with the following:\r\n\r\n(tested on 19 rc2 and rc4 and 18)\r\n```\r\n/opt/llvm-19/bin/llvm-config --version\r\n19.1.0-rc2\r\n\r\n/opt/llvm-19/bin/opt: WARNING: failed to create target machine for 'arm64-apple-darwin23.6.0': unable to get target for 'arm64-apple-darwin23.6.0', see --version and --triple.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0.\tProgram arguments: /opt/llvm-19/bin/opt -O3 -S bug.ll\r\n1.\tRunning pass \"function<eager-inv>(float2int,lower-constant-intrinsics,chr,loop(loop-rotate<header-duplication;no-prepare-for-lto>,loop-deletion),loop-distribute,inject-tli-mappings,loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,infer-alignment,loop-load-elim,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,slp-vectorizer,vector-combine,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,loop-unroll<O3>,transform-warning,sroa<preserve-cfg>,infer-alignment,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,loop-sink,instsimplify,div-rem-pairs,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch;speculate-unpredictables>)\" on module \"lol.ll\"\r\n2.\tRunning pass \"slp-vectorizer\" on function \"bug\"\r\n #0 0x00005558779163f7 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/admin/repos/llvm-project/llvm/lib/Support/Unix/Signals.inc:723:13\r\n #1 0x0000555877914570 llvm::sys::RunSignalHandlers() /home/admin/repos/llvm-project/llvm/lib/Support/Signals.cpp:106:18\r\n #2 0x0000555877916d9a SignalHandler(int) /home/admin/repos/llvm-project/llvm/lib/Support/Unix/Signals.inc:413:1\r\n #3 0x00007fb7b7e5b050 (/lib/x86_64-linux-gnu/libc.so.6+0x3c050)\r\n #4 0x0000555878d08ae0 llvm::slpvectorizer::BoUpSLP::canMapToVector(llvm::Type*) const /home/admin/repos/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:0:0\r\n #5 0x0000555878d3ca29 llvm::SLPVectorizerPass::vectorizeInsertValueInst(llvm::InsertValueInst*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&, bool) /home/admin/repos/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:18336:8\r\n #6 0x0000555878d3d459 llvm::SLPVectorizerPass::vectorizeInserts(llvm::SmallSetVector<llvm::Instruction*, 8u>&, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) /home/admin/repos/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:0:11\r\n #7 0x0000555878d3e35b llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&)::$_172::operator()(bool) const /home/admin/repos/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:18847:20\r\n #8 0x0000555878d34039 llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) /home/admin/repos/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:18963:18\r\n #9 0x0000555878d31968 llvm::SLPVectorizerPass::runImpl(llvm::Function&, llvm::ScalarEvolution*, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo*, llvm::AAResults*, llvm::LoopInfo*, llvm::DominatorTree*, llvm::AssumptionCache*, llvm::DemandedBits*, llvm::OptimizationRemarkEmitter*) /home/admin/repos/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:15865:13\r\n#10 0x0000555878d31431 llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /home/admin/repos/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:15796:18\r\n#11 0x0000555878921dfd llvm::detail::PassModel<llvm::Function, llvm::SLPVectorizerPass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /home/admin/repos/llvm-project/llvm/include/llvm/IR/PassManagerInternal.h:90:5\r\n#12 0x0000555877ab570d llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /home/admin/repos/llvm-project/llvm/include/llvm/IR/PassManagerImpl.h:85:8\r\n#13 0x00005558785d887d llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) /home/admin/repos/llvm-project/llvm/include/llvm/IR/PassManagerInternal.h:90:5\r\n#14 0x0000555877ab94f0 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) /home/admin/repos/llvm-project/llvm/lib/IR/PassManager.cpp:129:23\r\n#15 0x00005558785d86cd llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) /home/admin/repos/llvm-project/llvm/include/llvm/IR/PassManagerInternal.h:90:5\r\n#16 0x0000555877ab44ed llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) /home/admin/repos/llvm-project/llvm/include/llvm/IR/PassManagerImpl.h:85:8\r\n#17 0x00005558788ca8c9 llvm::SmallPtrSetImplBase::isSmall() const /home/admin/repos/llvm-project/llvm/include/llvm/ADT/SmallPtrSet.h:197:33\r\n#18 0x00005558788ca8c9 llvm::SmallPtrSetImplBase::~SmallPtrSetImplBase() /home/admin/repos/llvm-project/llvm/include/llvm/ADT/SmallPtrSet.h:84:10\r\n#19 0x00005558788ca8c9 llvm::PreservedAnalyses::~PreservedAnalyses() /home/admin/repos/llvm-project/llvm/include/llvm/IR/Analysis.h:111:7\r\n#20 0x00005558788ca8c9 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) /home/admin/repos/llvm-project/llvm/tools/opt/NewPMDriver.cpp:547:3\r\n#21 0x00005558778e5779 optMain /home/admin/repos/llvm-project/llvm/tools/opt/optdriver.cpp:739:12\r\n#22 0x00007fb7b7e4624a (/lib/x86_64-linux-gnu/libc.so.6+0x2724a)\r\n#23 0x00007fb7b7e46305 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x27305)\r\n#24 0x00005558778dfd21 _start (/opt/llvm-19/bin/opt+0xf17d21)\r\nSegmentation fault\r\n```\r\n\r\n```llvmir\r\n; ModuleID = 'LLVMDialectModule'\r\nsource_filename = \"LLVMDialectModule\"\r\ntarget datalayout = \"e-m:o-i64:64-i128:128-n32:64-S128\"\r\ntarget triple = \"arm64-apple-darwin23.6.0\"\r\n\r\ndefine { { {}, {}, {}, {}, {}, {}, {} } } @\"bug\"({ {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, { {}, {}, {}, {}, {}, {}, {} }, { {} } } %0) {\r\n %2 = extractvalue { {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, { {}, {}, {}, {}, {}, {}, {} }, { {} } } %0, 18\r\n %3 = insertvalue { { {}, {}, {}, {}, {}, {}, {} } } undef, { {}, {}, {}, {}, {}, {}, {} } %2, 0\r\n ret { { {}, {}, {}, {}, {}, {}, {} } } %3\r\n}\r\n\r\n!llvm.module.flags = !{!0}\r\n\r\n!0 = !{i32 2, !\"Debug Info Version\", i32 3}\r\n```",
47
+ "author": "edg-l",
48
+ "labels": [
49
+ "llvm:SLPVectorizer",
50
+ "crash"
51
+ ],
52
+ "comments": [
53
+ {
54
+ "author": "edg-l",
55
+ "body": "one question, will this be included in llvm 19?"
56
+ },
57
+ {
58
+ "author": "alexey-bataev",
59
+ "body": "Not sure, it is not an immediate regression from 18 to 19, and it is too late, I think, to include it into 19"
60
+ }
61
+ ]
62
+ },
63
+ "verified": true
64
+ }
dataset/107473.json ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "107473",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/107473",
4
+ "bug_type": "crash",
5
+ "base_commit": "99fb1506a869fa5e82dbd36e1a63cd21450f1502",
6
+ "knowledge_cutoff": "2024-09-05T21:51:36Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/LoopVectorize"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "e3c537ff903af9a92ff43bab6d21c0ea759d65e5",
12
+ "components": [
13
+ "LoopVectorize"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
17
+ [
18
+ 7314,
19
+ 7322
20
+ ]
21
+ ]
22
+ },
23
+ "bug_location_funcname": {
24
+ "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
25
+ "planContainsAdditionalSimplifications"
26
+ ]
27
+ }
28
+ },
29
+ "patch": "commit e3c537ff903af9a92ff43bab6d21c0ea759d65e5\nAuthor: Florian Hahn <[email protected]>\nDate: Tue Sep 10 21:37:12 2024 +0100\n\n [VPlan] Consider non-header phis in planContainsAdditionalSimp.\n \n Update planContainsAdditionalSimplifications to also check phis not in\n the loop header. This ensures we don't miss cases where VPBlendRecipes\n (which correspond to such phis) have been simplified.\n \n Fixes https://github.com/llvm/llvm-project/issues/107473.\n\ndiff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\nindex 2be3b5775292..b821da03c16e 100644\n--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\n+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\n@@ -7314,9 +7314,10 @@ static bool planContainsAdditionalSimplifications(VPlan &Plan,\n // Return true if the loop contains any instructions that are not also part of\n // the VPlan or are skipped for VPlan-based cost computations. This indicates\n // that the VPlan contains extra simplifications.\n- return any_of(TheLoop->blocks(), [&SeenInstrs, &CostCtx](BasicBlock *BB) {\n- return any_of(*BB, [&SeenInstrs, &CostCtx](Instruction &I) {\n- if (isa<PHINode>(&I))\n+ return any_of(TheLoop->blocks(), [&SeenInstrs, &CostCtx,\n+ TheLoop](BasicBlock *BB) {\n+ return any_of(*BB, [&SeenInstrs, &CostCtx, TheLoop, BB](Instruction &I) {\n+ if (isa<PHINode>(&I) && BB == TheLoop->getHeader())\n return false;\n return !SeenInstrs.contains(&I) && !CostCtx.skipCostComputation(&I, true);\n });\n",
30
+ "tests": [
31
+ {
32
+ "file": "llvm/test/Transforms/LoopVectorize/RISCV/dead-ops-cost.ll",
33
+ "commands": [
34
+ "opt -p loop-vectorize -mtriple riscv64-linux-gnu -mattr=+v,+f -S %s"
35
+ ],
36
+ "tests": [
37
+ {
38
+ "test_name": "dead_load",
39
+ "test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\n\ndefine void @dead_load(ptr %p, i16 %start) {\nentry:\n %start.ext = sext i16 %start to i64\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i64 [ %start.ext, %entry ], [ %iv.next, %loop ]\n %gep = getelementptr i16, ptr %p, i64 %iv\n store i16 0, ptr %gep, align 2\n %l = load i16, ptr %gep, align 2\n %iv.next = add i64 %iv, 3\n %cmp = icmp slt i64 %iv, 111\n br i1 %cmp, label %loop, label %exit\n\nexit: ; preds = %loop\n ret void\n}\n"
40
+ },
41
+ {
42
+ "test_name": "dead_live_out_due_to_scalar_epilogue_required",
43
+ "test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\n\ndefine i8 @dead_live_out_due_to_scalar_epilogue_required(ptr %src, ptr %dst) {\nentry:\n br label %loop\n\nloop: ; preds = %loop, %entry\n %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]\n %idxprom = sext i32 %iv to i64\n %gep.src = getelementptr i8, ptr %src, i64 %idxprom\n %l = load i8, ptr %gep.src, align 1\n %gep.dst = getelementptr i8, ptr %dst, i64 %idxprom\n store i8 0, ptr %gep.dst, align 1\n %iv.next = add i32 %iv, 4\n %cmp = icmp ult i32 %iv, 1001\n br i1 %cmp, label %loop, label %exit\n\nexit: ; preds = %loop\n %r = phi i8 [ %l, %loop ]\n ret i8 %r\n}\n"
44
+ },
45
+ {
46
+ "test_name": "test_phi_in_latch_redundant",
47
+ "test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\n\ndefine void @test_phi_in_latch_redundant(ptr %dst, i32 %a) {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]\n br i1 false, label %loop.latch, label %then\n\nthen: ; preds = %loop.header\n %not.a = xor i32 %a, -1\n br label %loop.latch\n\nloop.latch: ; preds = %then, %loop.header\n %p = phi i32 [ %not.a, %then ], [ 0, %loop.header ]\n %gep = getelementptr i32, ptr %dst, i64 %iv\n store i32 %p, ptr %gep, align 4\n %iv.next = add i64 %iv, 9\n %ec = icmp slt i64 %iv, 322\n br i1 %ec, label %loop.header, label %exit\n\nexit: ; preds = %loop.latch\n ret void\n}\n"
48
+ },
49
+ {
50
+ "test_name": "cost_of_exit_branch_and_cond_insts",
51
+ "test_body": "target datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\n\n; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)\ndeclare i16 @llvm.umax.i16(i16, i16) #0\n\ndefine i32 @cost_of_exit_branch_and_cond_insts(ptr %a, ptr %b, i1 %c, i16 %x) {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop.latch ]\n br i1 %c, label %then, label %loop.exiting\n\nthen: ; preds = %loop.header\n %gep = getelementptr inbounds i32, ptr %b, i32 %iv\n store i1 false, ptr %a, align 1\n store i32 0, ptr %gep, align 4\n br label %loop.exiting\n\nloop.exiting: ; preds = %then, %loop.header\n %iv.next = add i32 %iv, 1\n %umax = tail call i16 @llvm.umax.i16(i16 %x, i16 111)\n %umax.ext = zext i16 %umax to i32\n %sub = sub i32 770, %umax.ext\n %ec = icmp slt i32 %iv, %sub\n br i1 %ec, label %loop.latch, label %exit\n\nloop.latch: ; preds = %loop.exiting\n br label %loop.header\n\nexit: ; preds = %loop.exiting\n br label %return\n\nreturn: ; preds = %exit\n ret i32 0\n}\n\nattributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }\n"
52
+ }
53
+ ]
54
+ }
55
+ ],
56
+ "issue": {
57
+ "title": "[VPlan] Assertion \" VPlan cost model and legacy cost model disagreed\"' failed.",
58
+ "body": "Testing using 0c1500ef05e0a5b25cae79d2bd361dbc6e14e726\r\n\r\nC testcase:\r\n```\r\nint a;\r\nextern int b[][3][3][3][3][3];\r\n_Bool c;\r\nunsigned char d[1][13][13];\r\nunsigned e[1][13][13][13];\r\nint f[6];\r\nunsigned short g[1][13][13][13];\r\nunsigned h[1][13][13], i[1][13][13];\r\nshort j[1][13][13];\r\nunsigned k[3][13][13];\r\nunsigned short l[1][13];\r\nshort m[1][13];\r\nunsigned short n[1][13][13];\r\nunsigned o[1][13];\r\nvoid p(char q, int r, char s, unsigned char z[][13][13],\r\n unsigned aa[][13][13][13], int ab[], unsigned short ac[][13][13][13],\r\n unsigned ad[][13][13], short ae[][13][13], unsigned af[][13][13],\r\n unsigned short ag[][13], short ah[][13], unsigned short ai[][13][13],\r\n unsigned aj[][13][13], unsigned ak[][13]) {\r\n for (unsigned t = 0; t < q; t += 50)\r\n for (unsigned u = 0; u < 2; u = 6)\r\n for (short w = 0; w < 2; w += 42155)\r\n for (signed x = -15; x < r; x += s) {\r\n b[x][x][u][2][x][2] = ab[5] ? ~af[2][1][x] : 0;\r\n a = x ? c ? aj[2][u][x] : 0 : ae[2][w][4];\r\n }\r\n}\r\nint main() {\r\n f[5] = 8;\r\n for (long t = 0; t < 3; ++t)\r\n for (long v = 0; v < 3; ++v)\r\n for (long y = 0; y < 3; ++y)\r\n k[t][v][y] = 3004284279;\r\n p(8, 322, 9, d, e, f, g, h, j, k, l, m, n, i, o);\r\n}\r\n```\r\n\r\nLLVM IR:\r\n```llvm ir\r\n; ModuleID = 'reduced.bc'\r\ntarget datalayout = \"e-m:e-p:64:64-i64:64-i128:128-n32:64-S128\"\r\ntarget triple = \"riscv64-unknown-linux-gnu\"\r\n\r\ndefine i32 @main(i64 %indvars.iv) #0 {\r\nentry:\r\n br label %for.body17.us77.us.us.i\r\n\r\nfor.body17.us77.us.us.i: ; preds = %cond.end.us84.us.us.i, %entry\r\n %indvars.iv1 = phi i64 [ %indvars.iv.next, %cond.end.us84.us.us.i ], [ 0, %entry ]\r\n br i1 false, label %cond.end.us84.us.us.i, label %cond.true.us80.us.us.i\r\n\r\ncond.true.us80.us.us.i: ; preds = %for.body17.us77.us.us.i\r\n %not.us83.us.us.i = xor i32 0, 0\r\n br label %cond.end.us84.us.us.i\r\n\r\ncond.end.us84.us.us.i: ; preds = %cond.true.us80.us.us.i, %for.body17.us77.us.us.i\r\n %cond.us85.us.us.i = phi i32 [ %not.us83.us.us.i, %cond.true.us80.us.us.i ], [ 0, %for.body17.us77.us.us.i ]\r\n %arrayidx30.us87.us.us.i = getelementptr [0 x [3 x [3 x [3 x [3 x [3 x i32]]]]]], ptr null, i64 0, i64 %indvars.iv1, i64 %indvars.iv, i64 0, i64 2, i64 %indvars.iv, i64 2\r\n store i32 %cond.us85.us.us.i, ptr %arrayidx30.us87.us.us.i, align 4\r\n %indvars.iv.next = add i64 %indvars.iv1, 9\r\n %cmp14.us95.us.us.i = icmp slt i64 %indvars.iv1, 322\r\n br i1 %cmp14.us95.us.us.i, label %for.body17.us77.us.us.i, label %for.body17.us77.us.us.1.i.preheader\r\n\r\nfor.body17.us77.us.us.1.i.preheader: ; preds = %cond.end.us84.us.us.i\r\n ret i32 0\r\n}\r\n\r\nattributes #0 = { \"target-features\"=\"+64bit,+a,+c,+d,+f,+m,+relax,+v,+zicsr,+zifencei,+zmmul,+zve32f,+zve32x,+zve64d,+zve64f,+zve64x,+zvl128b,+zvl32b,+zvl64b,-b,-e,-experimental-smctr,-experimental-smmpm,-experimental-smnpm,-experimental-ssctr,-experimental-ssnpm,-experimental-sspm,-experimental-supm,-experimental-zacas,-experimental-zalasr,-experimental-zicfilp,-experimental-zicfiss,-experimental-zvbc32e,-experimental-zvkgs,-h,-shcounterenw,-shgatpa,-shtvala,-shvsatpa,-shvstvala,-shvstvecd,-smaia,-smcdeleg,-smcsrind,-smepmp,-smstateen,-ssaia,-ssccfg,-ssccptr,-sscofpmf,-sscounterenw,-sscsrind,-ssqosid,-ssstateen,-ssstrict,-sstc,-sstvala,-sstvecd,-ssu64xl,-svade,-svadu,-svbare,-svinval,-svnapot,-svpbmt,-xcvalu,-xcvbi,-xcvbitmanip,-xcvelw,-xcvmac,-xcvmem,-xcvsimd,-xsfcease,-xsfvcp,-xsfvfnrclipxfqf,-xsfvfwmaccqqq,-xsfvqmaccdod,-xsfvqmaccqoq,-xsifivecdiscarddlone,-xsifivecflushdlone,-xtheadba,-xtheadbb,-xtheadbs,-xtheadcmo,-xtheadcondmov,-xtheadfmemidx,-xtheadmac,-xtheadmemidx,-xtheadmempair,-xtheadsync,-xtheadvdot,-xventanacondops,-xwchc,-za128rs,-za64rs,-zaamo,-zabha,-zalrsc,-zama16b,-zawrs,-zba,-zbb,-zbc,-zbkb,-zbkc,-zbkx,-zbs,-zca,-zcb,-zcd,-zce,-zcf,-zcmop,-zcmp,-zcmt,-zdinx,-zfa,-zfbfmin,-zfh,-zfhmin,-zfinx,-zhinx,-zhinxmin,-zic64b,-zicbom,-zicbop,-zicboz,-ziccamoa,-ziccif,-zicclsm,-ziccrse,-zicntr,-zicond,-zihintntl,-zihintpause,-zihpm,-zimop,-zk,-zkn,-zknd,-zkne,-zknh,-zkr,-zks,-zksed,-zksh,-zkt,-ztso,-zvbb,-zvbc,-zvfbfmin,-zvfbfwma,-zvfh,-zvfhmin,-zvkb,-zvkg,-zvkn,-zvknc,-zvkned,-zvkng,-zvknha,-zvknhb,-zvks,-zvksc,-zvksed,-zvksg,-zvksh,-zvkt,-zvl1024b,-zvl16384b,-zvl2048b,-zvl256b,-zvl32768b,-zvl4096b,-zvl512b,-zvl65536b,-zvl8192b\" }\r\n```\r\n\r\nCommand/backtrace:\r\n```\r\n> /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt -passes=loop-vectorize reduced.ll -S\r\nopt: /scratch/tc-testing/tc-compiler-fuzz-trunk/llvm/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:7400: llvm::VectorizationFactor llvm::LoopVectorizationPlanner::computeBestVF(): Assertion `(BestFactor.Width == LegacyVF.Width || planContainsAdditionalSimplifications(getPlanFor(BestFactor.Width), CostCtx, OrigLoop)) && \" VPlan cost model and legacy cost model disagreed\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0. Program arguments: /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt -passes=loop-vectorize reduced.ll -S\r\n1. Running pass \"function(loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>)\" on module \"reduced.ll\"\r\n2. Running pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"main\"\r\n #0 0x000059162be7f6e0 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x30136e0)\r\n #1 0x000059162be7caef llvm::sys::RunSignalHandlers() (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x3010aef)\r\n #2 0x000059162be7cc45 SignalHandler(int) Signals.cpp:0:0\r\n #3 0x00007152dd642520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #4 0x00007152dd6969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\r\n #5 0x00007152dd6969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10\r\n #6 0x00007152dd6969fc pthread_kill ./nptl/pthread_kill.c:89:10\r\n #7 0x00007152dd642476 gsignal ./signal/../sysdeps/posix/raise.c:27:6\r\n #8 0x00007152dd6287f3 abort ./stdlib/abort.c:81:7\r\n #9 0x00007152dd62871b _nl_load_domain ./intl/loadmsgcat.c:1177:9\r\n#10 0x00007152dd639e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n#11 0x000059162ae52310 llvm::LoopVectorizationPlanner::computeBestVF() (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1fe6310)\r\n#12 0x000059162ae6910b llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x1ffd10b)\r\n#13 0x000059162ae6c121 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2000121)\r\n#14 0x000059162ae6c797 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2000797)\r\n#15 0x0000591629cc8756 llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xe5c756)\r\n#16 0x000059162bc8b67f llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2e1f67f)\r\n#17 0x0000591629ccb8e6 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xe5f8e6)\r\n#18 0x000059162bc89a1b llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2e1da1b)\r\n#19 0x0000591629cc7b36 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0xe5bb36)\r\n#20 0x000059162bc8a57d llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x2e1e57d)\r\n#21 0x00005916294f41b6 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x6881b6)\r\n#22 0x00005916294e5f11 optMain (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x679f11)\r\n#23 0x00007152dd629d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16\r\n#24 0x00007152dd629e40 call_init ./csu/../csu/libc-start.c:128:20\r\n#25 0x00007152dd629e40 __libc_start_main ./csu/../csu/libc-start.c:379:5\r\n#26 0x00005916294dc2c5 _start (/scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt+0x6702c5)\r\nzsh: IOT instruction (core dumped) /scratch/tc-testing/tc-compiler-fuzz-trunk/build-gcv/build-llvm-linux/bin/opt\r\n```\r\nhttps://godbolt.org/z/qEEqe1exM\r\n\r\nFound via fuzzer\r\n\r\nRelated/prior issue: https://github.com/llvm/llvm-project/issues/107171\r\n\r\ncc @fhahn",
59
+ "author": "patrick-rivos",
60
+ "labels": [
61
+ "vectorizers",
62
+ "crash"
63
+ ],
64
+ "comments": [
65
+ {
66
+ "author": "patrick-rivos",
67
+ "body": "Ping. The C fuzzer is hitting this assertion ~15 times a day since the runs starting sep 6th."
68
+ }
69
+ ]
70
+ },
71
+ "verified": true
72
+ }
dataset/108004.json ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "108004",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/108004",
4
+ "bug_type": "crash",
5
+ "base_commit": "512cecad4c384c84b79fea050a755cb7e46c6ac5",
6
+ "knowledge_cutoff": "2024-09-10T11:32:26Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/LoopVectorize"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "7858e14547c509c95503b74ff8ffc7bf2fc5b110",
12
+ "components": [
13
+ "LoopVectorize"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
17
+ [
18
+ 8663,
19
+ 8668
20
+ ]
21
+ ]
22
+ },
23
+ "bug_location_funcname": {
24
+ "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
25
+ "collectUsersInExitBlock"
26
+ ]
27
+ }
28
+ },
29
+ "patch": "commit 7858e14547c509c95503b74ff8ffc7bf2fc5b110\nAuthor: Hari Limaye <[email protected]>\nDate: Wed Sep 11 16:43:34 2024 +0100\n\n [LV] Amend check for IV increments in collectUsersInEntryBlock (#108020)\n \n The check for IV increments in collectUsersInEntryBlock currently\n triggers for exit-block PHIs which use the IV start value, resulting in\n us failing to add the input value for the middle block to these PHIs.\n \n Fix this by amending the check for IV increments to only include\n incoming values that are instructions inside the loop.\n \n Fixes #108004\n\ndiff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\nindex b821da03c16e..640a7bf3d672 100644\n--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\n+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\n@@ -8663,6 +8663,7 @@ static MapVector<PHINode *, VPValue *> collectUsersInExitBlock(\n !cast<VPWidenIntOrFpInductionRecipe>(V)->getTruncInst()) ||\n isa<VPWidenPointerInductionRecipe>(V) ||\n (isa<Instruction>(IncomingValue) &&\n+ OrigLoop->contains(cast<Instruction>(IncomingValue)) &&\n any_of(IncomingValue->users(), [&Inductions](User *U) {\n auto *P = dyn_cast<PHINode>(U);\n return P && Inductions.contains(P);\n",
30
+ "tests": [
31
+ {
32
+ "file": "llvm/test/Transforms/LoopVectorize/use-iv-start-value.ll",
33
+ "commands": [
34
+ "opt < %s -passes=loop-vectorize -force-vector-width=4 -force-vector-interleave=1 -S"
35
+ ],
36
+ "tests": [
37
+ {
38
+ "test_name": "foo",
39
+ "test_body": "define i64 @foo(ptr %p1, ptr %p2, i64 %start, i64 %end) {\nentry:\n %start2 = and i64 %start, 12345\n br label %for.body\n\nfor.body: ; preds = %for.body, %entry\n %ind = phi i64 [ %start2, %entry ], [ %ind.next, %for.body ]\n %arrayidx1 = getelementptr inbounds i32, ptr %p1, i64 %ind\n %0 = load i32, ptr %arrayidx1, align 4\n %arrayidx2 = getelementptr inbounds i32, ptr %p2, i64 %ind\n %1 = load i32, ptr %arrayidx2, align 4\n %ind.next = add i64 %ind, 1\n %cmp = icmp ne i64 %ind.next, %end\n br i1 %cmp, label %for.body, label %exit\n\nexit: ; preds = %for.body\n %use = phi i64 [ %start2, %for.body ]\n ret i64 %use\n}\n"
40
+ }
41
+ ]
42
+ }
43
+ ],
44
+ "issue": {
45
+ "title": "[LoopVectorize] Assertion fails when IV start value is used by an exit block PHI",
46
+ "body": "With the following IR:\r\n```\r\ndefine i64 @foo(i64 %start, i64 %end) {\r\nentry:\r\n %p1 = alloca [1024 x i32]\r\n %p2 = alloca [1024 x i32]\r\n call void @init_mem(ptr %p1, i64 1024)\r\n call void @init_mem(ptr %p2, i64 1024)\r\n %start2 = and i64 %start, 12345\r\n br label %for.body\r\n\r\nfor.body:\r\n %ind = phi i64 [ %ind.next, %for.body ], [ %start2, %entry ]\r\n %arrayidx1 = getelementptr inbounds i32, ptr %p1, i64 %ind\r\n %0 = load i32, ptr %arrayidx1, align 4\r\n %arrayidx2 = getelementptr inbounds i32, ptr %p2, i64 %ind\r\n %1 = load i32, ptr %arrayidx2, align 4\r\n %ind.next = add i64 %ind, 1\r\n %cmp = icmp ne i64 %ind.next, %end\r\n br i1 %cmp, label %for.body, label %exit\r\n\r\nexit:\r\n %use = phi i64 [ %start2, %for.body ]\r\n ret i64 %use\r\n}\r\n\r\ndeclare void @init_mem(ptr, i64)\r\n```\r\n\r\nLV crashes due to hitting the following assertion:\r\n```\r\nLV: Vectorizing: innermost loop.\r\nPHINode should have one entry for each predecessor of its parent basic block!\r\n %bob = phi i64 [ %start2, %for.body ]\r\nopt: /work/llvm-project-wt/nuw-clang-arr/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:10244: bool llvm::LoopVectorizePass::processLoop(Loop *): Assertion `!verif\r\nyFunction(*L->getHeader()->getParent(), &dbgs())' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0. Program arguments: ./build/bin/opt -passes=loop-vectorize -force-vector-interleave=2 -force-vector-width=4 -debug test.ll -o - -S\r\n1. Running pass \"function(loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>)\" on module \"test.ll\"\r\n2. Running pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"foo\"\r\n #0 0x0000aaaaaec431c0 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (./build/bin/opt+0x41a31c0)\r\n #1 0x0000aaaaaec4102c llvm::sys::RunSignalHandlers() (./build/bin/opt+0x41a102c)\r\n #2 0x0000aaaaaec438dc SignalHandler(int) Signals.cpp:0:0\r\n #3 0x0000fffff7ffb9d0 (linux-vdso.so.1+0x9d0)\r\n #4 0x0000fffff7b5f200 __pthread_kill_implementation ./nptl/pthread_kill.c:44:76\r\n #5 0x0000fffff7b1a67c gsignal ./signal/../sysdeps/posix/raise.c:27:6\r\n #6 0x0000fffff7b07130 abort ./stdlib/abort.c:81:7\r\n #7 0x0000fffff7b13fd0 __assert_fail_base ./assert/assert.c:89:7\r\n #8 0x0000fffff7b14040 __assert_perror_fail ./assert/assert-perr.c:31:1\r\n #9 0x0000aaaaadee375c llvm::LoopVectorizePass::processLoop(llvm::Loop*) (./build/bin/opt+0x344375c)\r\n#10 0x0000aaaaadee72d0 llvm::LoopVectorizePass::runImpl(llvm::Function&) (./build/bin/opt+0x34472d0)\r\n#11 0x0000aaaaadee7ac0 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (./build/bin/opt+0x3447ac0)\r\n#12 0x0000aaaaaea9676c llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (./bui\r\nld/bin/opt+0x3ff676c)\r\n#13 0x0000aaaaaea9a1fc llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (./build/bin/opt+0x3ffa1fc)\r\n#14 0x0000aaaaaea958cc llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (./build/bin/o\r\npt+0x3ff58cc)\r\n#15 0x0000aaaaab5b3d88 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOu\r\ntputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::Outpu\r\ntKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (./build/bin/opt+0xb13d88)\r\n#16 0x0000aaaaab5a7fc0 optMain (./build/bin/opt+0xb07fc0)\r\n#17 0x0000fffff7b073fc __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3\r\n#18 0x0000fffff7b074cc call_init ./csu/../csu/libc-start.c:128:20\r\n#19 0x0000fffff7b074cc __libc_start_main ./csu/../csu/libc-start.c:379:5\r\n#20 0x0000aaaaab5a1ef0 _start (./build/bin/opt+0xb01ef0)\r\n```\r\n\r\nSeems like we fail to properly handle fixing up the incoming value for this PHI from the middle block. ",
47
+ "author": "hazzlim",
48
+ "labels": [
49
+ "vectorizers",
50
+ "crash"
51
+ ],
52
+ "comments": [
53
+ {
54
+ "author": "hazzlim",
55
+ "body": "Note: I am actively looking into this and plan to put up a fix "
56
+ }
57
+ ]
58
+ },
59
+ "verified": true
60
+ }
dataset/108098.json ADDED
The diff for this file is too large to render. See raw diff
 
dataset/108620.json ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "108620",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/108620",
4
+ "bug_type": "crash",
5
+ "base_commit": "03618ceabd003be94190b068db11b607fd1108ef",
6
+ "knowledge_cutoff": "2024-09-13T18:15:02Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/SLPVectorizer"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "1e3536ef3141d6429f3616af624b81b6d6ab2959",
12
+ "components": [
13
+ "SLPVectorizer"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
17
+ [
18
+ 1283,
19
+ 1293
20
+ ],
21
+ [
22
+ 14222,
23
+ 14235
24
+ ],
25
+ [
26
+ 14373,
27
+ 14378
28
+ ],
29
+ [
30
+ 14426,
31
+ 14436
32
+ ],
33
+ [
34
+ 14530,
35
+ 14537
36
+ ],
37
+ [
38
+ 14757,
39
+ 14762
40
+ ],
41
+ [
42
+ 17660,
43
+ 17666
44
+ ],
45
+ [
46
+ 17956,
47
+ 17961
48
+ ],
49
+ [
50
+ 18024,
51
+ 18031
52
+ ]
53
+ ]
54
+ },
55
+ "bug_location_funcname": {
56
+ "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
57
+ "BoUpSLP::vectorizeTree",
58
+ "tryToReduce"
59
+ ]
60
+ }
61
+ },
62
+ "patch": "commit 1e3536ef3141d6429f3616af624b81b6d6ab2959\nAuthor: Alexey Bataev <[email protected]>\nDate: Fri Sep 13 15:40:22 2024 -0700\n\n [SLP]Fix PR108620: Need to check, if the reduced value was transformed\n \n Before trying to include the scalar into the list of\n ExternallyUsedValues, need to check, if it was transformed in previous\n iteration and use the transformed value, not the original one, to avoid\n compiler crash when building external uses.\n \n Fixes https://github.com/llvm/llvm-project/issues/108620\n\ndiff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\nindex 0afe02fc08ff..5f2bf082fb87 100644\n--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n@@ -1283,11 +1283,8 @@ public:\n /// Vectorize the tree but with the list of externally used values \\p\n /// ExternallyUsedValues. Values in this MapVector can be replaced but the\n /// generated extractvalue instructions.\n- /// \\param ReplacedExternals containd list of replaced external values\n- /// {scalar, replace} after emitting extractelement for external uses.\n Value *\n vectorizeTree(const ExtraValueToDebugLocsMap &ExternallyUsedValues,\n- SmallVectorImpl<std::pair<Value *, Value *>> &ReplacedExternals,\n Instruction *ReductionRoot = nullptr);\n \n /// \\returns the cost incurred by unwanted spills and fills, caused by\n@@ -14222,14 +14219,12 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E, bool PostponedPHIs) {\n \n Value *BoUpSLP::vectorizeTree() {\n ExtraValueToDebugLocsMap ExternallyUsedValues;\n- SmallVector<std::pair<Value *, Value *>> ReplacedExternals;\n- return vectorizeTree(ExternallyUsedValues, ReplacedExternals);\n+ return vectorizeTree(ExternallyUsedValues);\n }\n \n-Value *BoUpSLP::vectorizeTree(\n- const ExtraValueToDebugLocsMap &ExternallyUsedValues,\n- SmallVectorImpl<std::pair<Value *, Value *>> &ReplacedExternals,\n- Instruction *ReductionRoot) {\n+Value *\n+BoUpSLP::vectorizeTree(const ExtraValueToDebugLocsMap &ExternallyUsedValues,\n+ Instruction *ReductionRoot) {\n // All blocks must be scheduled before any instructions are inserted.\n for (auto &BSIter : BlocksSchedules) {\n scheduleBlock(BSIter.second.get());\n@@ -14373,6 +14368,7 @@ Value *BoUpSLP::vectorizeTree(\n SmallDenseSet<Value *, 4> UsedInserts;\n DenseMap<std::pair<Value *, Type *>, Value *> VectorCasts;\n SmallDenseSet<Value *, 4> ScalarsWithNullptrUser;\n+ SmallDenseSet<ExtractElementInst *, 4> IgnoredExtracts;\n // Extract all of the elements with the external uses.\n for (const auto &ExternalUse : ExternalUses) {\n Value *Scalar = ExternalUse.Scalar;\n@@ -14426,11 +14422,16 @@ Value *BoUpSLP::vectorizeTree(\n if (ReplaceInst) {\n // Leave the instruction as is, if it cheaper extracts and all\n // operands are scalar.\n- auto *CloneInst = Inst->clone();\n- CloneInst->insertBefore(Inst);\n- if (Inst->hasName())\n- CloneInst->takeName(Inst);\n- Ex = CloneInst;\n+ if (auto *EE = dyn_cast<ExtractElementInst>(Inst)) {\n+ IgnoredExtracts.insert(EE);\n+ Ex = EE;\n+ } else {\n+ auto *CloneInst = Inst->clone();\n+ CloneInst->insertBefore(Inst);\n+ if (Inst->hasName())\n+ CloneInst->takeName(Inst);\n+ Ex = CloneInst;\n+ }\n } else if (auto *ES = dyn_cast<ExtractElementInst>(Scalar);\n ES && isa<Instruction>(Vec)) {\n Value *V = ES->getVectorOperand();\n@@ -14530,8 +14531,12 @@ Value *BoUpSLP::vectorizeTree(\n }\n Value *NewInst = ExtractAndExtendIfNeeded(Vec);\n // Required to update internally referenced instructions.\n- Scalar->replaceAllUsesWith(NewInst);\n- ReplacedExternals.emplace_back(Scalar, NewInst);\n+ if (Scalar != NewInst) {\n+ assert((!isa<ExtractElementInst>(Scalar) ||\n+ !IgnoredExtracts.contains(cast<ExtractElementInst>(Scalar))) &&\n+ \"Extractelements should not be replaced.\");\n+ Scalar->replaceAllUsesWith(NewInst);\n+ }\n continue;\n }\n \n@@ -14757,6 +14762,9 @@ Value *BoUpSLP::vectorizeTree(\n if (Entry->getOpcode() == Instruction::GetElementPtr &&\n !isa<GetElementPtrInst>(Scalar))\n continue;\n+ if (auto *EE = dyn_cast<ExtractElementInst>(Scalar);\n+ EE && IgnoredExtracts.contains(EE))\n+ continue;\n #ifndef NDEBUG\n Type *Ty = Scalar->getType();\n if (!Ty->isVoidTy()) {\n@@ -17660,7 +17668,6 @@ public:\n // because of the vectorization.\n DenseMap<Value *, WeakTrackingVH> TrackedVals(ReducedVals.size() *\n ReducedVals.front().size());\n- SmallVector<std::pair<Value *, Value *>> ReplacedExternals;\n \n // The compare instruction of a min/max is the insertion point for new\n // instructions and may be replaced with a new compare instruction.\n@@ -17956,6 +17963,8 @@ public:\n if (Cnt >= Pos && Cnt < Pos + ReduxWidth)\n continue;\n Value *RdxVal = Candidates[Cnt];\n+ if (auto It = TrackedVals.find(RdxVal); It != TrackedVals.end())\n+ RdxVal = It->second;\n if (!Visited.insert(RdxVal).second)\n continue;\n // Check if the scalar was vectorized as part of the vectorization\n@@ -18024,8 +18033,8 @@ public:\n InsertPt = GetCmpForMinMaxReduction(RdxRootInst);\n \n // Vectorize a tree.\n- Value *VectorizedRoot = V.vectorizeTree(LocalExternallyUsedValues,\n- ReplacedExternals, InsertPt);\n+ Value *VectorizedRoot =\n+ V.vectorizeTree(LocalExternallyUsedValues, InsertPt);\n \n Builder.SetInsertPoint(InsertPt);\n \n",
63
+ "tests": [
64
+ {
65
+ "file": "llvm/test/Transforms/SLPVectorizer/X86/reduced-val-extracted-and-externally-used.ll",
66
+ "commands": [
67
+ "opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu < %s"
68
+ ],
69
+ "tests": [
70
+ {
71
+ "test_name": "test",
72
+ "test_body": "define void @test(i32 %arg) {\nbb:\n br label %bb1\n\nbb1: ; preds = %bb1, %bb\n %phi = phi i32 [ 0, %bb ], [ %add27, %bb1 ]\n %phi2 = phi i32 [ 0, %bb ], [ %add24, %bb1 ]\n %phi3 = phi i32 [ 0, %bb ], [ %xor26, %bb1 ]\n %add = add i32 %phi2, 0\n %add4 = add i32 %phi2, 0\n %xor = xor i32 %add, %add4\n %add5 = add i32 %phi, 0\n %add6 = add i32 %phi2, 0\n %add7 = add i32 %phi2, 0\n %xor8 = xor i32 %add6, %xor\n %xor9 = xor i32 %xor8, %add5\n %xor10 = xor i32 %xor9, %add7\n %add11 = add i32 %phi, 0\n %add12 = add i32 %phi2, 0\n %add13 = add i32 %phi2, 0\n %xor14 = xor i32 %add12, %xor10\n %xor15 = xor i32 %xor14, %add11\n %xor16 = xor i32 %xor15, %add13\n %add17 = add i32 %phi, 0\n %add18 = add i32 %phi2, 0\n %add19 = add i32 %phi2, 0\n %xor20 = xor i32 %add18, %xor16\n %xor21 = xor i32 %xor20, %add17\n %xor22 = xor i32 %xor21, %add19\n %add23 = add i32 %phi2, 0\n %add24 = add i32 %arg, 0\n %xor25 = xor i32 %add23, %xor22\n %xor26 = xor i32 %xor25, %add24\n %add27 = add i32 1, 0\n %icmp = icmp ult i32 %add27, 0\n br label %bb1\n}\n"
73
+ }
74
+ ]
75
+ }
76
+ ],
77
+ "issue": {
78
+ "title": "Assertion `(I->use_empty() || all_of(I->uses(), [&](Use &U) { return isDeleted( cast<Instruction>(U.getUser())); })) && \"trying to erase instruction with users.\"' failed.",
79
+ "body": "To reproduce run the following test with -passes=slp-vectorizer\r\n```\r\n; ModuleID = './reduced.ll'\r\nsource_filename = \"./reduced.ll\"\r\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128-ni:1-p2:32:8:8:32-ni:2\"\r\ntarget triple = \"x86_64-unknown-linux-gnu\"\r\n\r\ndefine void @wombat(i32 %arg) gc \"statepoint-example\" {\r\nbb:\r\n br label %bb1\r\n\r\nbb1: ; preds = %bb1, %bb\r\n %phi = phi i32 [ 0, %bb ], [ %add27, %bb1 ]\r\n %phi2 = phi i32 [ 0, %bb ], [ %add24, %bb1 ]\r\n %phi3 = phi i32 [ 0, %bb ], [ %xor26, %bb1 ]\r\n %add = add i32 %phi2, 0\r\n %add4 = add i32 %phi2, 0\r\n %xor = xor i32 %add, %add4\r\n %add5 = add i32 %phi, 0\r\n %add6 = add i32 %phi2, 0\r\n %add7 = add i32 %phi2, 0\r\n %xor8 = xor i32 %add6, %xor\r\n %xor9 = xor i32 %xor8, %add5\r\n %xor10 = xor i32 %xor9, %add7\r\n %add11 = add i32 %phi, 0\r\n %add12 = add i32 %phi2, 0\r\n %add13 = add i32 %phi2, 0\r\n %xor14 = xor i32 %add12, %xor10\r\n %xor15 = xor i32 %xor14, %add11\r\n %xor16 = xor i32 %xor15, %add13\r\n %add17 = add i32 %phi, 0\r\n %add18 = add i32 %phi2, 0\r\n %add19 = add i32 %phi2, 0\r\n %xor20 = xor i32 %add18, %xor16\r\n %xor21 = xor i32 %xor20, %add17\r\n %xor22 = xor i32 %xor21, %add19\r\n %add23 = add i32 %phi2, 0\r\n %add24 = add i32 %arg, 0\r\n %xor25 = xor i32 %add23, %xor22\r\n %xor26 = xor i32 %xor25, %add24\r\n %add27 = add i32 1, 0\r\n %icmp = icmp ult i32 %add27, 0\r\n br label %bb1\r\n}\r\n```\r\nReproducer: https://godbolt.org/z/77hKre61P\r\n\r\nStack dump:\r\n```\r\nopt: /root/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:2663: void llvm::slpvectorizer::BoUpSLP::removeInstructionsAndOperands(llvm::ArrayRef<U*>) [with T = llvm::Instruction]: Assertion `(I->use_empty() || all_of(I->uses(), [&](Use &U) { return isDeleted( cast<Instruction>(U.getUser())); })) && \"trying to erase instruction with users.\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=slp-vectorizer <source>\r\n1.\tRunning pass \"function(slp-vectorizer)\" on module \"<source>\"\r\n2.\tRunning pass \"slp-vectorizer\" on function \"wombat\"\r\n #0 0x00000000050106b8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x50106b8)\r\n #1 0x000000000500ddfc SignalHandler(int) Signals.cpp:0:0\r\n #2 0x0000737fffa42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #3 0x0000737fffa969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\r\n #4 0x0000737fffa42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\r\n #5 0x0000737fffa287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\r\n #6 0x0000737fffa2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\r\n #7 0x0000737fffa39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n #8 0x00000000040b91cf void llvm::slpvectorizer::BoUpSLP::removeInstructionsAndOperands<llvm::Instruction>(llvm::ArrayRef<llvm::Instruction*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x40b91cf)\r\n #9 0x000000000410b80a llvm::slpvectorizer::BoUpSLP::vectorizeTree(llvm::MapVector<llvm::Value*, llvm::SmallVector<llvm::Instruction*, 2u>, llvm::DenseMap<llvm::Value*, unsigned int, llvm::DenseMapInfo<llvm::Value*, void>, llvm::detail::DenseMapPair<llvm::Value*, unsigned int>>, llvm::SmallVector<std::pair<llvm::Value*, llvm::SmallVector<llvm::Instruction*, 2u>>, 0u>> const&, llvm::SmallVectorImpl<std::pair<llvm::Value*, llvm::Value*>>&, llvm::Instruction*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x410b80a)\r\n#10 0x0000000004115bed (anonymous namespace)::HorizontalReduction::tryToReduce(llvm::slpvectorizer::BoUpSLP&, llvm::DataLayout const&, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo const&) SLPVectorizer.cpp:0:0\r\n#11 0x0000000004118321 llvm::SLPVectorizerPass::vectorizeHorReduction(llvm::PHINode*, llvm::Instruction*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&, llvm::TargetTransformInfo*, llvm::SmallVectorImpl<llvm::WeakTrackingVH>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4118321)\r\n#12 0x000000000411cb18 llvm::SLPVectorizerPass::vectorizeRootInstruction(llvm::PHINode*, llvm::Instruction*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&, llvm::TargetTransformInfo*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x411cb18)\r\n#13 0x00000000041212fa llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x41212fa)\r\n#14 0x0000000004127719 llvm::SLPVectorizerPass::runImpl(llvm::Function&, llvm::ScalarEvolution*, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo*, llvm::AAResults*, llvm::LoopInfo*, llvm::DominatorTree*, llvm::AssumptionCache*, llvm::DemandedBits*, llvm::OptimizationRemarkEmitter*) (.part.0) SLPVectorizer.cpp:0:0\r\n#15 0x00000000041283cb llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x41283cb)\r\n#16 0x0000000002efda4e llvm::detail::PassModel<llvm::Function, llvm::SLPVectorizerPass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2efda4e)\r\n#17 0x0000000004e12948 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4e12948)\r\n#18 0x0000000000e06f8e llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xe06f8e)\r\n#19 0x0000000004e1136e llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4e1136e)\r\n#20 0x0000000000e0679e llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xe0679e)\r\n#21 0x0000000004e10da0 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4e10da0)\r\n#22 0x00000000008fb642 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8fb642)\r\n#23 0x00000000008ee4cc optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8ee4cc)\r\n#24 0x0000737fffa29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\r\n#25 0x0000737fffa29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\r\n#26 0x00000000008e5f9e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8e5f9e)\r\nProgram terminated with signal: SIGSEGV\r\nCompiler returned: 139\r\n```",
80
+ "author": "TatyanaDoubts",
81
+ "labels": [
82
+ "llvm:SLPVectorizer",
83
+ "crash"
84
+ ],
85
+ "comments": []
86
+ },
87
+ "verified": true
88
+ }
dataset/108697.json ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "108697",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/108697",
4
+ "bug_type": "crash",
5
+ "base_commit": "848cb21ddca5dc4d8c52e487264936be8f1bfe8d",
6
+ "knowledge_cutoff": "2024-09-14T13:01:28Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/LoopVectorize"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "9de327c94d0c995803b6485fb28ac4cad1e53bbe",
12
+ "components": [
13
+ "LoopVectorize"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
17
+ [
18
+ 6551,
19
+ 6564
20
+ ]
21
+ ]
22
+ },
23
+ "bug_location_funcname": {
24
+ "llvm/lib/Transforms/Vectorize/LoopVectorize.cpp": [
25
+ "LoopVectorizationCostModel::getInstructionCost"
26
+ ]
27
+ }
28
+ },
29
+ "patch": "commit 9de327c94d0c995803b6485fb28ac4cad1e53bbe\nAuthor: Florian Hahn <[email protected]>\nDate: Wed Oct 2 20:16:41 2024 +0100\n\n [LV] Generalize predication checks from 2c8836c899 for operands.\n \n This fixes another case where the VPlan-based and legacy cost models\n disagree. If any of the operands is predicated, it can't be trivially\n hoisted and we should consider the cost for evaluating it each loop\n iteration.\n \n Fixes https://github.com/llvm/llvm-project/issues/108697.\n\ndiff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\nindex de3b981a4fe3..6e082b1c134d 100644\n--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\n+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp\n@@ -6551,14 +6551,17 @@ LoopVectorizationCostModel::getInstructionCost(Instruction *I,\n Op2 = cast<SCEVConstant>(PSE.getSCEV(Op2))->getValue();\n }\n auto Op2Info = TTI.getOperandInfo(Op2);\n- auto IsInvariant = [this](Value *Op) {\n+ std::function<bool(Value *)> IsInvariant =\n+ [this, &IsInvariant](Value *Op) -> bool {\n if (!Legal->isInvariant(Op))\n return false;\n- // Consider Op2 invariant, if it is not a predicated instruction in the\n- // loop. In that case, it is not trivially hoistable.\n+ // Consider Op2invariant, if it or its operands aren't predicated\n+ // instruction in the loop. In that case, it is not trivially hoistable.\n return !isa<Instruction>(Op) ||\n !TheLoop->contains(cast<Instruction>(Op)) ||\n- !isPredicatedInst(cast<Instruction>(Op));\n+ (!isPredicatedInst(cast<Instruction>(Op)) &&\n+ all_of(cast<Instruction>(Op)->operands(),\n+ [&IsInvariant](Value *Op) { return IsInvariant(Op); }));\n };\n if (Op2Info.Kind == TargetTransformInfo::OK_AnyValue && IsInvariant(Op2))\n Op2Info.Kind = TargetTransformInfo::OK_UniformValue;\n",
30
+ "tests": [
31
+ {
32
+ "file": "llvm/test/Transforms/LoopVectorize/X86/predicated-instruction-cost.ll",
33
+ "commands": [
34
+ "opt -p loop-vectorize -S %s"
35
+ ],
36
+ "tests": [
37
+ {
38
+ "test_name": "predicated_urem_shl_cost",
39
+ "test_body": "target datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine void @predicated_urem_shl_cost(ptr %A, i32 %x, i1 %c) {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i32 [ 1, %entry ], [ %iv.next, %loop.latch ]\n %gep = getelementptr inbounds i32, ptr %A, i32 %iv\n %l = load i32, ptr %gep, align 4\n br i1 %c, label %then, label %loop.latch\n\nthen: ; preds = %loop.header\n %rem = urem i32 2, %x\n %shl = shl i32 %l, %rem\n br label %loop.latch\n\nloop.latch: ; preds = %then, %loop.header\n %p = phi i32 [ 0, %loop.header ], [ %shl, %then ]\n store i32 %p, ptr %gep, align 4\n %iv.next = add i32 %iv, 1\n %ec = icmp eq i32 %iv, 0\n br i1 %ec, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n ret void\n}\n"
40
+ },
41
+ {
42
+ "test_name": "test_wide_shift_uses_predicated_invariant_instruction",
43
+ "test_body": "target datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\ntarget triple = \"x86_64-unknown-linux-gnu\"\n\ndefine void @test_wide_shift_uses_predicated_invariant_instruction(i32 %d, i1 %c, ptr %dst) {\nentry:\n br label %loop.header\n\nloop.header: ; preds = %loop.latch, %entry\n %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop.latch ]\n br i1 %c, label %loop.latch, label %else\n\nelse: ; preds = %loop.header\n %rem = urem i32 100, %d\n %sext = shl i32 %rem, 12\n %shl.i = shl i32 999, %sext\n br label %loop.latch\n\nloop.latch: ; preds = %else, %loop.header\n %p = phi i32 [ %shl.i, %else ], [ 0, %loop.header ]\n %gep = getelementptr inbounds i32, ptr %dst, i32 %iv\n store i32 %p, ptr %gep, align 4\n %iv.next = add i32 %iv, 1\n %ec = icmp eq i32 %iv.next, 100\n br i1 %ec, label %exit, label %loop.header\n\nexit: ; preds = %loop.latch\n ret void\n}\n"
44
+ }
45
+ ]
46
+ }
47
+ ],
48
+ "issue": {
49
+ "title": "clang crashes on valid code at -O{2,3} on x86_64-linux-gnu: Assertion `(BestFactor.Width == LegacyVF.Width || planContainsAdditionalSimplifications(getPlanFor(BestFactor.Width), CostCtx, OrigLoop)) && \" VPlan cost model and legacy cost model disagreed\"' failed ",
50
+ "body": "Compiler Explorer: https://godbolt.org/z/9K4a3Pr7j\r\n\r\n```\r\n[508] % clangtk -v\r\nclang version 20.0.0git (https://github.com/llvm/llvm-project.git 223e2efa5e886502a9467b7ef700ebce9b7886e8)\r\nTarget: x86_64-unknown-linux-gnu\r\nThread model: posix\r\nInstalledDir: /local/suz-local/software/local/clang-trunk/bin\r\nBuild config: +assertions\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9\r\nSelected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11\r\nCandidate multilib: .;@m64\r\nSelected multilib: .;@m64\r\n[509] % \r\n[509] % clangtk -O2 small.c\r\nclang-20: /local/suz-local/software/clangbuild/llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:7390: llvm::VectorizationFactor llvm::LoopVectorizationPlanner::computeBestVF(): Assertion `(BestFactor.Width == LegacyVF.Width || planContainsAdditionalSimplifications(getPlanFor(BestFactor.Width), CostCtx, OrigLoop)) && \" VPlan cost model and legacy cost model disagreed\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.\r\nStack dump:\r\n0.\tProgram arguments: /local/suz-local/software/local/clang-trunk/bin/clang-20 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -dumpdir a- -disable-free -clear-ast-before-backend -main-file-name small.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/local/suz-local/software/emitesting/bugs/20240914-clangtk-m64-O3-build-061621/delta -fcoverage-compilation-dir=/local/suz-local/software/emitesting/bugs/20240914-clangtk-m64-O3-build-061621/delta -resource-dir /local/suz-local/software/local/clang-trunk/lib/clang/20 -I /usr/local/include -I /local/suz-local/software/local/include -internal-isystem /local/suz-local/software/local/clang-trunk/lib/clang/20/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcolor-diagnostics -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/small-34578e.o -x c small.c\r\n1.\t<eof> parser at end of file\r\n2.\tOptimizer\r\n3.\tRunning pass \"function<eager-inv>(float2int,lower-constant-intrinsics,loop(loop-rotate<header-duplication;no-prepare-for-lto>,loop-deletion),loop-distribute,inject-tli-mappings,loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,infer-alignment,loop-load-elim,instcombine<max-iterations=1;no-verify-fixpoint>,simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,slp-vectorizer,vector-combine,instcombine<max-iterations=1;no-verify-fixpoint>,loop-unroll<O2>,transform-warning,sroa<preserve-cfg>,infer-alignment,instcombine<max-iterations=1;no-verify-fixpoint>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,loop-sink,instsimplify,div-rem-pairs,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;speculate-unpredictables>)\" on module \"small.c\"\r\n4.\tRunning pass \"loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>\" on function \"main\"\r\n #0 0x000055ba1845c4ff llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x43484ff)\r\n #1 0x000055ba18459a34 SignalHandler(int) Signals.cpp:0:0\r\n #2 0x00007fbbfabd4420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)\r\n #3 0x00007fbbfa60b00b raise /build/glibc-LcI20x/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1\r\n #4 0x00007fbbfa5ea859 abort /build/glibc-LcI20x/glibc-2.31/stdlib/abort.c:81:7\r\n #5 0x00007fbbfa5ea729 get_sysdep_segment_value /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:509:8\r\n #6 0x00007fbbfa5ea729 _nl_load_domain /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:970:34\r\n #7 0x00007fbbfa5fbfd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)\r\n #8 0x000055ba19db5fcb llvm::LoopVectorizationPlanner::computeBestVF() (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5ca1fcb)\r\n #9 0x000055ba19dd169a llvm::LoopVectorizePass::processLoop(llvm::Loop*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5cbd69a)\r\n#10 0x000055ba19dd42d1 llvm::LoopVectorizePass::runImpl(llvm::Function&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5cc02d1)\r\n#11 0x000055ba19dd4943 llvm::LoopVectorizePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5cc0943)\r\n#12 0x000055ba19946a06 llvm::detail::PassModel<llvm::Function, llvm::LoopVectorizePass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x5832a06)\r\n#13 0x000055ba17dec0d1 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x3cd80d1)\r\n#14 0x000055ba15926546 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x1812546)\r\n#15 0x000055ba17deaa3d llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x3cd6a3d)\r\n#16 0x000055ba15925216 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x1811216)\r\n#17 0x000055ba17dea471 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x3cd6471)\r\n#18 0x000055ba18713673 (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>&, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>&, clang::BackendConsumer*) BackendUtil.cpp:0:0\r\n#19 0x000055ba187167f8 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x46027f8)\r\n#20 0x000055ba18decf5c clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4cd8f5c)\r\n#21 0x000055ba1ac8966c clang::ParseAST(clang::Sema&, bool, bool) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x6b7566c)\r\n#22 0x000055ba18ded378 clang::CodeGenAction::ExecuteAction() (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4cd9378)\r\n#23 0x000055ba1908a659 clang::FrontendAction::Execute() (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4f76659)\r\n#24 0x000055ba1900c07e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x4ef807e)\r\n#25 0x000055ba191772b6 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x50632b6)\r\n#26 0x000055ba154f2b15 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x13deb15)\r\n#27 0x000055ba154ebbba ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0\r\n#28 0x000055ba154ef58e clang_main(int, char**, llvm::ToolContext const&) (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x13db58e)\r\n#29 0x000055ba153dd43b main (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x12c943b)\r\n#30 0x00007fbbfa5ec083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3\r\n#31 0x000055ba154eb64e _start (/local/suz-local/software/local/clang-trunk/bin/clang-20+0x13d764e)\r\nclangtk: error: unable to execute command: Aborted\r\nclangtk: error: clang frontend command failed due to signal (use -v to see invocation)\r\nclang version 20.0.0git (https://github.com/llvm/llvm-project.git 223e2efa5e886502a9467b7ef700ebce9b7886e8)\r\nTarget: x86_64-unknown-linux-gnu\r\nThread model: posix\r\nInstalledDir: /local/suz-local/software/local/clang-trunk/bin\r\nBuild config: +assertions\r\nclangtk: note: diagnostic msg: \r\n********************\r\n\r\nPLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:\r\nPreprocessed source(s) and associated run script(s) are located at:\r\nclangtk: note: diagnostic msg: /tmp/small-682958.c\r\nclangtk: note: diagnostic msg: /tmp/small-682958.sh\r\nclangtk: note: diagnostic msg: \r\n\r\n********************\r\n[510] % \r\n[510] % cat small.c\r\nshort a, b, c, d;\r\nunsigned short e;\r\nint main() {\r\n for (; d; d++) {\r\n e = a + b;\r\n c = b > 3 || e > b ? e : e << b;\r\n c = c ? 2 / c : 0;\r\n b = 1;\r\n }\r\n return 0;\r\n}\r\n```",
51
+ "author": "zhendongsu",
52
+ "labels": [
53
+ "vectorizers",
54
+ "crash-on-valid"
55
+ ],
56
+ "comments": []
57
+ },
58
+ "verified": true
59
+ }
dataset/108698.json ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "108698",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/108698",
4
+ "bug_type": "miscompilation",
5
+ "base_commit": "ba8e4246e2f17030788e8a4954bf5c290332206f",
6
+ "knowledge_cutoff": "2024-09-14T13:16:53Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/VectorCombine"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "87663fdab9d0e7bcc0b963ea078da9e2eb574908",
12
+ "components": [
13
+ "VectorCombine"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Vectorize/VectorCombine.cpp": [
17
+ [
18
+ 2597,
19
+ 2607
20
+ ],
21
+ [
22
+ 2628,
23
+ 2634
24
+ ]
25
+ ]
26
+ },
27
+ "bug_location_funcname": {
28
+ "llvm/lib/Transforms/Vectorize/VectorCombine.cpp": [
29
+ "VectorCombine::shrinkType"
30
+ ]
31
+ }
32
+ },
33
+ "patch": "commit 87663fdab9d0e7bcc0b963ea078da9e2eb574908\nAuthor: Yingwei Zheng <[email protected]>\nDate: Sun Sep 15 18:38:06 2024 +0800\n\n [VectorCombine] Don't shrink lshr if the shamt is not less than bitwidth (#108705)\n \n Consider the following case:\n ```\n define <2 x i32> @test(<2 x i64> %vec.ind16, <2 x i32> %broadcast.splat20) {\n %19 = icmp eq <2 x i64> %vec.ind16, zeroinitializer\n %20 = zext <2 x i1> %19 to <2 x i32>\n %21 = lshr <2 x i32> %20, %broadcast.splat20\n ret <2 x i32> %21\n }\n ```\n After https://github.com/llvm/llvm-project/pull/104606, we shrink the\n lshr into:\n ```\n define <2 x i32> @test(<2 x i64> %vec.ind16, <2 x i32> %broadcast.splat20) {\n %1 = icmp eq <2 x i64> %vec.ind16, zeroinitializer\n %2 = trunc <2 x i32> %broadcast.splat20 to <2 x i1>\n %3 = lshr <2 x i1> %1, %2\n %4 = zext <2 x i1> %3 to <2 x i32>\n ret <2 x i32> %4\n }\n ```\n It is incorrect since `lshr i1 X, 1` returns `poison`.\n This patch adds additional check on the shamt operand. The lshr will get\n shrunk iff we ensure that the shamt is less than bitwidth of the smaller\n type. As `computeKnownBits(&I, *DL).countMaxActiveBits() > BW` always\n evaluates to true for `lshr(zext(X), Y)`, this check will only apply to\n bitwise logical instructions.\n \n Alive2: https://alive2.llvm.org/ce/z/j_RmTa\n Fixes https://github.com/llvm/llvm-project/issues/108698.\n\ndiff --git a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp\nindex d7afe2f426d3..58701bfa60a3 100644\n--- a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp\n+++ b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp\n@@ -2597,11 +2597,19 @@ bool VectorCombine::shrinkType(llvm::Instruction &I) {\n auto *SmallTy = cast<FixedVectorType>(ZExted->getType());\n unsigned BW = SmallTy->getElementType()->getPrimitiveSizeInBits();\n \n- // Check that the expression overall uses at most the same number of bits as\n- // ZExted\n- KnownBits KB = computeKnownBits(&I, *DL);\n- if (KB.countMaxActiveBits() > BW)\n- return false;\n+ if (I.getOpcode() == Instruction::LShr) {\n+ // Check that the shift amount is less than the number of bits in the\n+ // smaller type. Otherwise, the smaller lshr will return a poison value.\n+ KnownBits ShAmtKB = computeKnownBits(I.getOperand(1), *DL);\n+ if (ShAmtKB.getMaxValue().uge(BW))\n+ return false;\n+ } else {\n+ // Check that the expression overall uses at most the same number of bits as\n+ // ZExted\n+ KnownBits KB = computeKnownBits(&I, *DL);\n+ if (KB.countMaxActiveBits() > BW)\n+ return false;\n+ }\n \n // Calculate costs of leaving current IR as it is and moving ZExt operation\n // later, along with adding truncates if needed\n@@ -2628,7 +2636,7 @@ bool VectorCombine::shrinkType(llvm::Instruction &I) {\n return false;\n \n // Check if we can propagate ZExt through its other users\n- KB = computeKnownBits(UI, *DL);\n+ KnownBits KB = computeKnownBits(UI, *DL);\n if (KB.countMaxActiveBits() > BW)\n return false;\n \n",
34
+ "tests": [
35
+ {
36
+ "file": "llvm/test/Transforms/VectorCombine/AArch64/shrink-types.ll",
37
+ "commands": [
38
+ "opt -passes=vector-combine -S %s"
39
+ ],
40
+ "tests": [
41
+ {
42
+ "test_name": "pr108698",
43
+ "test_body": "target triple = \"aarch64\"\n\ndefine <2 x i32> @pr108698(<2 x i64> %x, <2 x i32> %y) {\n %cmp = icmp eq <2 x i64> %x, zeroinitializer\n %ext = zext <2 x i1> %cmp to <2 x i32>\n %lshr = lshr <2 x i32> %ext, %y\n ret <2 x i32> %lshr\n}\n"
44
+ }
45
+ ]
46
+ }
47
+ ],
48
+ "issue": {
49
+ "title": "wrong code at -O{2,3} on x86_64-linux-gnu",
50
+ "body": "It appears to be a recent regression as it doesn't reproduce with 18.1.0 and earlier. \r\n\r\nCompiler Explorer: https://godbolt.org/z/EGasYh8x1\r\n\r\n```\r\n[691] % clangtk -v\r\nclang version 20.0.0git (https://github.com/llvm/llvm-project.git 223e2efa5e886502a9467b7ef700ebce9b7886e8)\r\nTarget: x86_64-unknown-linux-gnu\r\nThread model: posix\r\nInstalledDir: /local/suz-local/software/local/clang-trunk/bin\r\nBuild config: +assertions\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11\r\nFound candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9\r\nSelected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11\r\nCandidate multilib: .;@m64\r\nSelected multilib: .;@m64\r\n[692] % \r\n[692] % clangtk -O1 small.c; ./a.out\r\n[693] % \r\n[693] % clangtk -O2 small.c\r\n[694] % ./a.out\r\nAborted\r\n[695] % \r\n[695] % cat small.c\r\nchar a[8];\r\nint b = 1, c;\r\nint main() {\r\n for (; c < 8; c++)\r\n a[c] = !c >> b;\r\n if (a[0] != 0)\r\n __builtin_abort();\r\n return 0;\r\n}\r\n```",
51
+ "author": "zhendongsu",
52
+ "labels": [
53
+ "miscompilation",
54
+ "vectorizers"
55
+ ],
56
+ "comments": [
57
+ {
58
+ "author": "dtcxzyw",
59
+ "body": "Reproducer: https://alive2.llvm.org/ce/z/5SkPZS\r\n```\r\n; bin/opt -passes=vector-combine test.ll -S\r\n\r\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\r\ntarget triple = \"x86_64-unknown-linux-gnu\"\r\n\r\ndefine <2 x i32> @test(<2 x i64> %vec.ind16, <2 x i32> %broadcast.splat20) {\r\n %19 = icmp eq <2 x i64> %vec.ind16, zeroinitializer\r\n %20 = zext <2 x i1> %19 to <2 x i32>\r\n %21 = lshr <2 x i32> %20, %broadcast.splat20\r\n ret <2 x i32> %21\r\n}\r\n```\r\n```\r\ndefine <2 x i32> @test(<2 x i64> %vec.ind16, <2 x i32> %broadcast.splat20) {\r\n %1 = icmp eq <2 x i64> %vec.ind16, zeroinitializer\r\n %2 = trunc <2 x i32> %broadcast.splat20 to <2 x i1>\r\n %3 = lshr <2 x i1> %1, %2\r\n %4 = zext <2 x i1> %3 to <2 x i32>\r\n ret <2 x i32> %4\r\n}\r\n```"
60
+ },
61
+ {
62
+ "author": "dtcxzyw",
63
+ "body": "Related PR: https://github.com/llvm/llvm-project/pull/104606\r\n"
64
+ }
65
+ ]
66
+ },
67
+ "verified": true
68
+ }
dataset/108700.json ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bug_id": "108700",
3
+ "issue_url": "https://github.com/llvm/llvm-project/issues/108700",
4
+ "bug_type": "crash",
5
+ "base_commit": "4c6f313cb340c435f47ac032857030768c81c341",
6
+ "knowledge_cutoff": "2024-09-14T13:45:54Z",
7
+ "lit_test_dir": [
8
+ "llvm/test/Transforms/SLPVectorizer"
9
+ ],
10
+ "hints": {
11
+ "fix_commit": "f564a48f0ea4d2100c0cadfa6e6f20f97244025e",
12
+ "components": [
13
+ "SLPVectorizer"
14
+ ],
15
+ "bug_location_lineno": {
16
+ "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
17
+ [
18
+ 7481,
19
+ 7487
20
+ ],
21
+ [
22
+ 7492,
23
+ 7506
24
+ ]
25
+ ]
26
+ },
27
+ "bug_location_funcname": {
28
+ "llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp": [
29
+ "BoUpSLP::buildTree_rec"
30
+ ]
31
+ }
32
+ },
33
+ "patch": "commit f564a48f0ea4d2100c0cadfa6e6f20f97244025e\nAuthor: Alexey Bataev <[email protected]>\nDate: Mon Sep 16 09:19:42 2024 -0700\n\n [SLP]Fix PR108700: correctly identify id of the operand node\n \n If the operand node for truncs is not created during construction, but\n one of the previous ones is reused instead, need to correctly identify\n its index, to correctly emit the code.\n \n Fixes https://github.com/llvm/llvm-project/issues/108700\n\ndiff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\nindex 5f2bf082fb87..282bb8eac7e2 100644\n--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp\n@@ -7481,7 +7481,16 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth,\n PrevMaxBW),\n std::min<unsigned>(DL->getTypeSizeInBits(VL0->getType()),\n PrevMinBW));\n- ExtraBitWidthNodes.insert(VectorizableTree.size() + 1);\n+ }\n+ TreeEntry *TE = newTreeEntry(VL, Bundle /*vectorized*/, S, UserTreeIdx,\n+ ReuseShuffleIndices);\n+ LLVM_DEBUG(dbgs() << \"SLP: added a vector of casts.\\n\");\n+\n+ TE->setOperandsInOrder();\n+ for (unsigned I : seq<unsigned>(0, VL0->getNumOperands()))\n+ buildTree_rec(TE->getOperand(I), Depth + 1, {TE, I});\n+ if (ShuffleOrOp == Instruction::Trunc) {\n+ ExtraBitWidthNodes.insert(getOperandEntry(TE, 0)->Idx);\n } else if (ShuffleOrOp == Instruction::SIToFP ||\n ShuffleOrOp == Instruction::UIToFP) {\n unsigned NumSignBits =\n@@ -7492,15 +7501,8 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth,\n }\n if (NumSignBits * 2 >=\n DL->getTypeSizeInBits(VL0->getOperand(0)->getType()))\n- ExtraBitWidthNodes.insert(VectorizableTree.size() + 1);\n+ ExtraBitWidthNodes.insert(getOperandEntry(TE, 0)->Idx);\n }\n- TreeEntry *TE = newTreeEntry(VL, Bundle /*vectorized*/, S, UserTreeIdx,\n- ReuseShuffleIndices);\n- LLVM_DEBUG(dbgs() << \"SLP: added a vector of casts.\\n\");\n-\n- TE->setOperandsInOrder();\n- for (unsigned I : seq<unsigned>(0, VL0->getNumOperands()))\n- buildTree_rec(TE->getOperand(I), Depth + 1, {TE, I});\n return;\n }\n case Instruction::ICmp:\n",
34
+ "tests": [
35
+ {
36
+ "file": "llvm/test/Transforms/SLPVectorizer/X86/minbitwidth-user-not-min.ll",
37
+ "commands": [
38
+ "opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu < %s"
39
+ ],
40
+ "tests": [
41
+ {
42
+ "test_name": "test",
43
+ "test_body": "define void @test(ptr %block, ptr noalias %pixels, i1 %b) {\nentry:\n %0 = load i16, ptr %block, align 2\n %tobool.not.i78 = icmp ult i16 %0, 0\n %conv.i80 = sext i1 true to i8\n %conv1.i81 = trunc i16 %0 to i8\n %retval.0.i82 = select i1 %tobool.not.i78, i8 %conv1.i81, i8 %conv.i80\n store i8 %retval.0.i82, ptr %pixels, align 1\n %arrayidx2 = getelementptr i8, ptr %block, i64 2\n %1 = load i16, ptr %arrayidx2, align 2\n %tobool.not.i73 = icmp ult i16 %1, 0\n %conv.i75 = sext i1 %b to i8\n %conv1.i76 = trunc i16 %1 to i8\n %retval.0.i77 = select i1 %tobool.not.i73, i8 %conv1.i76, i8 %conv.i75\n %arrayidx5 = getelementptr i8, ptr %pixels, i64 1\n store i8 %retval.0.i77, ptr %arrayidx5, align 1\n %arrayidx6 = getelementptr i8, ptr %block, i64 4\n %2 = load i16, ptr %arrayidx6, align 2\n %tobool.not.i68 = icmp ult i16 %2, 0\n %conv.i70 = sext i1 false to i8\n %conv1.i71 = trunc i16 %2 to i8\n %retval.0.i72 = select i1 %tobool.not.i68, i8 %conv1.i71, i8 %conv.i70\n %arrayidx9 = getelementptr i8, ptr %pixels, i64 2\n store i8 %retval.0.i72, ptr %arrayidx9, align 1\n %arrayidx10 = getelementptr i8, ptr %block, i64 6\n %3 = load i16, ptr %arrayidx10, align 2\n %tobool.not.i63 = icmp ult i16 %3, 0\n %conv.i65 = sext i1 false to i8\n %conv1.i66 = trunc i16 %3 to i8\n %retval.0.i67 = select i1 %tobool.not.i63, i8 %conv1.i66, i8 %conv.i65\n %arrayidx13 = getelementptr i8, ptr %pixels, i64 3\n store i8 %retval.0.i67, ptr %arrayidx13, align 1\n ret void\n}\n"
44
+ }
45
+ ]
46
+ },
47
+ {
48
+ "file": "llvm/test/Transforms/SLPVectorizer/X86/trunc-node-reused.ll",
49
+ "commands": [
50
+ "opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu < %s"
51
+ ],
52
+ "tests": [
53
+ {
54
+ "test_name": "test",
55
+ "test_body": "define i16 @test() {\nentry:\n %conv73 = xor i64 0, 0\n %and.i = and i64 0, 0\n %xor2.i = or i64 %and.i, 0\n %sub.i = or i64 %xor2.i, 0\n %xor3.i = xor i64 %sub.i, %conv73\n %and4.i = and i64 %xor3.i, 0\n %cmp.i = icmp slt i64 %and4.i, 0\n %0 = trunc i64 %conv73 to i16\n %1 = or i16 0, %0\n %conv73i = xor i64 0, 0\n %andi.i = and i64 0, 0\n %xor2i.i = or i64 %andi.i, 0\n %subi.i = or i64 %xor2i.i, 0\n %xor3i.i = xor i64 %subi.i, %conv73i\n %and4i.i = and i64 %xor3i.i, 0\n %cmpi.i = icmp slt i64 %and4i.i, 0\n %2 = trunc i64 %conv73i to i16\n %3 = or i16 0, %2\n %4 = select i1 %cmpi.i, i16 0, i16 %3\n %5 = select i1 %cmp.i, i16 0, i16 %1\n %6 = zext i32 0 to i64\n %add.ip = or i64 %6, 0\n %orp = or i64 %add.ip, 0\n %conv72p = shl i64 %orp, 0\n %sextp = ashr i64 %conv72p, 0\n %conv73p = xor i64 %sextp, 0\n %and.ip = and i64 0, 0\n %xor2.ip = or i64 %and.ip, 0\n %sub.ip = or i64 %xor2.ip, 0\n %xor3.ip = xor i64 %sub.ip, %conv73p\n %and4.ip = and i64 %xor3.ip, 0\n %cmp.ip = icmp slt i64 %and4.ip, 0\n %7 = trunc i64 %conv73p to i16\n %8 = or i16 0, %7\n %9 = select i1 %cmp.ip, i16 0, i16 %8\n %conv76i = and i16 %4, %5\n %conv76p = and i16 %conv76i, %9\n %10 = zext i32 0 to i64\n %add.ip1 = or i64 %10, 0\n %orp1 = or i64 %add.ip1, 0\n %conv72p1 = shl i64 %orp1, 0\n %sextp1 = ashr i64 %conv72p1, 0\n %conv73p1 = xor i64 %sextp1, 0\n %and.ip1 = and i64 0, 0\n %xor2.ip1 = or i64 %and.ip1, 0\n %sub.ip1 = or i64 %xor2.ip1, 0\n %xor3.ip1 = xor i64 %sub.ip1, %conv73p1\n %and4.ip1 = and i64 %xor3.ip1, 0\n %cmp.ip1 = icmp slt i64 %and4.ip1, 0\n %11 = trunc i64 %conv73p1 to i16\n %12 = or i16 0, %11\n %13 = select i1 %cmp.ip1, i16 0, i16 %12\n %conv76p2 = and i16 %conv76p, %13\n ret i16 %conv76p2\n}\n"
56
+ }
57
+ ]
58
+ }
59
+ ],
60
+ "issue": {
61
+ "title": "[SLPVectorizer] Assertion `OpIdx < Operands.size() && \"Off bounds\"' failed.",
62
+ "body": "Reproducer: https://godbolt.org/z/8Es17cqcW\r\n```\r\n; bin/opt -passes=slp-vectorizer reduced.ll -S\r\ntarget datalayout = \"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128\"\r\ntarget triple = \"x86_64-unknown-linux-gnu\"\r\n\r\ndefine i16 @main() {\r\nentry:\r\n %conv73.i.peel.i.i.i.i.i = xor i64 0, 0\r\n %and.i.i.peel.i.i.i.i.i = and i64 0, 0\r\n %xor2.i.i.peel.i.i.i.i.i = or i64 %and.i.i.peel.i.i.i.i.i, 0\r\n %sub.i.i.peel.i.i.i.i.i = or i64 %xor2.i.i.peel.i.i.i.i.i, 0\r\n %xor3.i.i.peel.i.i.i.i.i = xor i64 %sub.i.i.peel.i.i.i.i.i, %conv73.i.peel.i.i.i.i.i\r\n %and4.i.i.peel.i.i.i.i.i = and i64 %xor3.i.i.peel.i.i.i.i.i, 0\r\n %cmp.i.i.peel.i.i.i.i.i = icmp slt i64 %and4.i.i.peel.i.i.i.i.i, 0\r\n %0 = trunc i64 %conv73.i.peel.i.i.i.i.i to i16\r\n %1 = or i16 0, %0\r\n %conv73.i.i.i.i.i.i = xor i64 0, 0\r\n %and.i.i.i.i.i.i.i = and i64 0, 0\r\n %xor2.i.i.i.i.i.i.i = or i64 %and.i.i.i.i.i.i.i, 0\r\n %sub.i.i.i.i.i.i.i = or i64 %xor2.i.i.i.i.i.i.i, 0\r\n %xor3.i.i.i.i.i.i.i = xor i64 %sub.i.i.i.i.i.i.i, %conv73.i.i.i.i.i.i\r\n %and4.i.i.i.i.i.i.i = and i64 %xor3.i.i.i.i.i.i.i, 0\r\n %cmp.i.i.i.i.i.i.i = icmp slt i64 %and4.i.i.i.i.i.i.i, 0\r\n %2 = trunc i64 %conv73.i.i.i.i.i.i to i16\r\n %3 = or i16 0, %2\r\n %4 = select i1 %cmp.i.i.i.i.i.i.i, i16 0, i16 %3\r\n %5 = select i1 %cmp.i.i.peel.i.i.i.i.i, i16 0, i16 %1\r\n %6 = zext i32 0 to i64\r\n %add.i.i.peel.i369.i.i.i.i = or i64 %6, 0\r\n %or.i.peel.i371.i.i.i.i = or i64 %add.i.i.peel.i369.i.i.i.i, 0\r\n %conv72.i.peel.i372.i.i.i.i = shl i64 %or.i.peel.i371.i.i.i.i, 0\r\n %sext.i.peel.i373.i.i.i.i = ashr i64 %conv72.i.peel.i372.i.i.i.i, 0\r\n %conv73.i.peel.i374.i.i.i.i = xor i64 %sext.i.peel.i373.i.i.i.i, 0\r\n %and.i.i.peel.i376.i.i.i.i = and i64 0, 0\r\n %xor2.i.i.peel.i377.i.i.i.i = or i64 %and.i.i.peel.i376.i.i.i.i, 0\r\n %sub.i.i.peel.i378.i.i.i.i = or i64 %xor2.i.i.peel.i377.i.i.i.i, 0\r\n %xor3.i.i.peel.i379.i.i.i.i = xor i64 %sub.i.i.peel.i378.i.i.i.i, %conv73.i.peel.i374.i.i.i.i\r\n %and4.i.i.peel.i380.i.i.i.i = and i64 %xor3.i.i.peel.i379.i.i.i.i, 0\r\n %cmp.i.i.peel.i381.i.i.i.i = icmp slt i64 %and4.i.i.peel.i380.i.i.i.i, 0\r\n %7 = trunc i64 %conv73.i.peel.i374.i.i.i.i to i16\r\n %8 = or i16 0, %7\r\n %9 = select i1 %cmp.i.i.peel.i381.i.i.i.i, i16 0, i16 %8\r\n %conv76.i.i.i.i.i.i = and i16 %4, %5\r\n %conv76.i.peel.i384.i.i.i.i = and i16 %conv76.i.i.i.i.i.i, %9\r\n %10 = zext i32 0 to i64\r\n %add.i.i.peel.i417.i.i.i.i = or i64 %10, 0\r\n %or.i.peel.i419.i.i.i.i = or i64 %add.i.i.peel.i417.i.i.i.i, 0\r\n %conv72.i.peel.i420.i.i.i.i = shl i64 %or.i.peel.i419.i.i.i.i, 0\r\n %sext.i.peel.i421.i.i.i.i = ashr i64 %conv72.i.peel.i420.i.i.i.i, 0\r\n %conv73.i.peel.i422.i.i.i.i = xor i64 %sext.i.peel.i421.i.i.i.i, 0\r\n %and.i.i.peel.i424.i.i.i.i = and i64 0, 0\r\n %xor2.i.i.peel.i425.i.i.i.i = or i64 %and.i.i.peel.i424.i.i.i.i, 0\r\n %sub.i.i.peel.i426.i.i.i.i = or i64 %xor2.i.i.peel.i425.i.i.i.i, 0\r\n %xor3.i.i.peel.i427.i.i.i.i = xor i64 %sub.i.i.peel.i426.i.i.i.i, %conv73.i.peel.i422.i.i.i.i\r\n %and4.i.i.peel.i428.i.i.i.i = and i64 %xor3.i.i.peel.i427.i.i.i.i, 0\r\n %cmp.i.i.peel.i429.i.i.i.i = icmp slt i64 %and4.i.i.peel.i428.i.i.i.i, 0\r\n %11 = trunc i64 %conv73.i.peel.i422.i.i.i.i to i16\r\n %12 = or i16 0, %11\r\n %13 = select i1 %cmp.i.i.peel.i429.i.i.i.i, i16 0, i16 %12\r\n %conv76.i.peel.i432.i.i.i.i = and i16 %conv76.i.peel.i384.i.i.i.i, %13\r\n ret i16 %conv76.i.peel.i432.i.i.i.i\r\n}\r\n```\r\n```\r\nopt: /root/llvm-project/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:3180: llvm::slpvectorizer::BoUpSLP::ValueList& llvm::slpvectorizer::BoUpSLP::TreeEntry::getOperand(unsigned int): Assertion `OpIdx < Operands.size() && \"Off bounds\"' failed.\r\nPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.\r\nStack dump:\r\n0.\tProgram arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S --passes=slp-vectorizer <source>\r\n1.\tRunning pass \"function(slp-vectorizer)\" on module \"<source>\"\r\n2.\tRunning pass \"slp-vectorizer\" on function \"main\"\r\n #0 0x0000000005016bb8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x5016bb8)\r\n #1 0x00000000050142fc SignalHandler(int) Signals.cpp:0:0\r\n #2 0x00007955e2242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)\r\n #3 0x00007955e22969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)\r\n #4 0x00007955e2242476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)\r\n #5 0x00007955e22287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)\r\n #6 0x00007955e222871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)\r\n #7 0x00007955e2239e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)\r\n #8 0x000000000406f2b8 llvm::slpvectorizer::BoUpSLP::TreeEntry::getOperand(unsigned int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x406f2b8)\r\n #9 0x00000000040f675e llvm::slpvectorizer::BoUpSLP::getEntryCost(llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::ArrayRef<llvm::Value*>, llvm::SmallPtrSetImpl<llvm::Value*>&)::'lambda0'(llvm::function_ref<llvm::InstructionCost (unsigned int)>, llvm::function_ref<llvm::InstructionCost (llvm::InstructionCost)>)::operator()(llvm::function_ref<llvm::InstructionCost (unsigned int)>, llvm::function_ref<llvm::InstructionCost (llvm::InstructionCost)>) const SLPVectorizer.cpp:0:0\r\n#10 0x00000000040f74aa llvm::slpvectorizer::BoUpSLP::getEntryCost(llvm::slpvectorizer::BoUpSLP::TreeEntry const*, llvm::ArrayRef<llvm::Value*>, llvm::SmallPtrSetImpl<llvm::Value*>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x40f74aa)\r\n#11 0x0000000004114641 llvm::slpvectorizer::BoUpSLP::getTreeCost(llvm::ArrayRef<llvm::Value*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4114641)\r\n#12 0x00000000041198c8 (anonymous namespace)::HorizontalReduction::tryToReduce(llvm::slpvectorizer::BoUpSLP&, llvm::DataLayout const&, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo const&) SLPVectorizer.cpp:0:0\r\n#13 0x000000000411bfe1 llvm::SLPVectorizerPass::vectorizeHorReduction(llvm::PHINode*, llvm::Instruction*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&, llvm::TargetTransformInfo*, llvm::SmallVectorImpl<llvm::WeakTrackingVH>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x411bfe1)\r\n#14 0x0000000004120876 llvm::SLPVectorizerPass::vectorizeRootInstruction(llvm::PHINode*, llvm::Instruction*, llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&, llvm::TargetTransformInfo*) (.constprop.0) SLPVectorizer.cpp:0:0\r\n#15 0x0000000004124e16 llvm::SLPVectorizerPass::vectorizeChainsInBlock(llvm::BasicBlock*, llvm::slpvectorizer::BoUpSLP&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4124e16)\r\n#16 0x000000000412b2e1 llvm::SLPVectorizerPass::runImpl(llvm::Function&, llvm::ScalarEvolution*, llvm::TargetTransformInfo*, llvm::TargetLibraryInfo*, llvm::AAResults*, llvm::LoopInfo*, llvm::DominatorTree*, llvm::AssumptionCache*, llvm::DemandedBits*, llvm::OptimizationRemarkEmitter*) (.part.0) SLPVectorizer.cpp:0:0\r\n#17 0x000000000412bf6b llvm::SLPVectorizerPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x412bf6b)\r\n#18 0x0000000002f0034e llvm::detail::PassModel<llvm::Function, llvm::SLPVectorizerPass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2f0034e)\r\n#19 0x0000000004e18ff8 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4e18ff8)\r\n#20 0x0000000000e06a0e llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xe06a0e)\r\n#21 0x0000000004e17a1e llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4e17a1e)\r\n#22 0x0000000000e0621e llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xe0621e)\r\n#23 0x0000000004e17450 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4e17450)\r\n#24 0x00000000008fce52 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8fce52)\r\n#25 0x00000000008efcdc optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8efcdc)\r\n#26 0x00007955e2229d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)\r\n#27 0x00007955e2229e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)\r\n#28 0x00000000008e77ae _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8e77ae)\r\nProgram terminated with signal: SIGSEGV\r\nCompiler returned: 139\r\n```",
63
+ "author": "dtcxzyw",
64
+ "labels": [
65
+ "llvm:SLPVectorizer",
66
+ "crash-on-valid"
67
+ ],
68
+ "comments": []
69
+ },
70
+ "verified": true
71
+ }