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

[LoopUnrollAndJam] Instruction does not dominate all uses! #58565

Closed
JonPsson opened this issue Oct 24, 2022 · 2 comments
Closed

[LoopUnrollAndJam] Instruction does not dominate all uses! #58565

JonPsson opened this issue Oct 24, 2022 · 2 comments

Comments

@JonPsson
Copy link
Contributor

JonPsson commented Oct 24, 2022

Not sure if this is the loop pass unroll-and-jam or a later optimization that messes up...

clang-16 -cc1 -triple s390x-ibm-linux -S -O2 -w -mllvm -enable-unroll-and-jam -mllvm -allow-unroll-and-jam -mllvm -unroll-and-jam-count=8 -o crash0_aftercreduce.s -x ir  tc_crash0_aftercreduce.ll

testcase.tar.gz

Instruction does not dominate all uses!
  %i9.i = and i64 %i8.i, %i4017
  %i10.not.i = icmp eq i64 %i9.i, 0
Instruction does not dominate all uses!
  %i4017 = zext i16 %i10 to i64
...
@fhahn
Copy link
Contributor

fhahn commented Nov 22, 2022

Looks like this is caused by LoopUnrollAndJam: https://llvm.godbolt.org/z/PWovdoWrx, possibly the same issue as #50005

@fhahn fhahn changed the title Instruction does not dominate all uses! [LoopUnrollAndJam] Instruction does not dominate all uses! Nov 22, 2022
@caojoshua
Copy link
Contributor

fix submitted for review https://reviews.llvm.org/D140255

caojoshua added a commit to caojoshua/llvm-project that referenced this issue Jan 5, 2023
Fixes llvm#58565

The previous implementation visits operands in pre-order, but this does
not guarantee an instruction is visited before its uses. This can cause
instructions to be copied in the incorrect order. For example:

```
a = ...
b = add a, 1
c = add a, b
d = add b, a
```

Pre-order visits does not guarantee the order in which `a` and `b` are
visited. LoopUnrollAndJam may incorrectly insert `b` before `a`.

This patch implements post-order visits. By visiting dependencies first,
we guarantee that an instruction's dependencies are visited first.

Differential Revision: https://reviews.llvm.org/D140255
CarlosAlbertoEnciso pushed a commit to SNSystems/llvm-debuginfo-analyzer that referenced this issue Jan 6, 2023
Fixes llvm/llvm-project#58565

The previous implementation visits operands in pre-order, but this does
not guarantee an instruction is visited before its uses. This can cause
instructions to be copied in the incorrect order. For example:

```
a = ...
b = add a, 1
c = add a, b
d = add b, a
```

Pre-order visits does not guarantee the order in which `a` and `b` are
visited. LoopUnrollAndJam may incorrectly insert `b` before `a`.

This patch implements post-order visits. By visiting dependencies first,
we guarantee that an instruction's dependencies are visited first.

Differential Revision: https://reviews.llvm.org/D140255
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants