Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[VectorCombine] scalarizeLoadExtract - infinite loop if we scalarize a dead extract waiting to be erased #129373

Open
RKSimon opened this issue Mar 1, 2025 · 1 comment · May be fixed by #129375
Assignees
Labels
bug Indicates an unexpected problem or unintended behavior llvm:hang Compiler hang (infinite loop) llvm:transforms

Comments

@RKSimon
Copy link
Collaborator

RKSimon commented Mar 1, 2025

Reduced test case:

define void @infinite_loop(ptr %p0) {
  %load = load <4 x float>, ptr %p0, align 8
  %shuffle0 = shufflevector <4 x float> zeroinitializer, <4 x float> %load, <4 x i32> <i32 0, i32 4, i32 1, i32 5>
  %shuffle1 = shufflevector <4 x float> %shuffle0, <4 x float> zeroinitializer, <4 x i32> <i32 0, i32 4, i32 poison, i32 poison>
  %extract = extractelement <4 x float> %load, i64 1
  ret void
}

scalarizeLoadExtract iterates across all users of a load, and doesn't account for possible orders in the worklist that prevent unused instructions that use the load from being erased afterward.

Fix incoming

@RKSimon RKSimon self-assigned this Mar 1, 2025
@RKSimon RKSimon added bug Indicates an unexpected problem or unintended behavior llvm:transforms and removed new issue labels Mar 1, 2025
@llvmbot
Copy link
Member

llvmbot commented Mar 1, 2025

@llvm/issue-subscribers-bug

Author: Simon Pilgrim (RKSimon)

Reduced test case:
define void @<!-- -->infinite_loop(ptr %p0) {
  %load = load &lt;4 x float&gt;, ptr %p0, align 8
  %shuffle0 = shufflevector &lt;4 x float&gt; zeroinitializer, &lt;4 x float&gt; %load, &lt;4 x i32&gt; &lt;i32 0, i32 4, i32 1, i32 5&gt;
  %shuffle1 = shufflevector &lt;4 x float&gt; %shuffle0, &lt;4 x float&gt; zeroinitializer, &lt;4 x i32&gt; &lt;i32 0, i32 4, i32 poison, i32 poison&gt;
  %extract = extractelement &lt;4 x float&gt; %load, i64 1
  ret void
}

scalarizeLoadExtract iterates across all users of a load, and doesn't account for possible orders in the worklist that prevent unused instructions that use the load from being erased afterward.

Fix incoming

RKSimon added a commit to RKSimon/llvm-project that referenced this issue Mar 1, 2025
…ny extract is waiting to be erased

If any extract is waiting to be erased, then bail out as this will distort the cost calculation and possibly lead to infinite loops.

Fixes llvm#129373
@dtcxzyw dtcxzyw added the llvm:hang Compiler hang (infinite loop) label Mar 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior llvm:hang Compiler hang (infinite loop) llvm:transforms
Projects
None yet
3 participants