Assertion `DT.dominates(RHead, LHead) && "No dominance between recurrences used by one SCEV?"
- Dominant language
- LLVM
- Stars
- 1.7k
- Forks
- 188
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 26
Description
Another regression, but I didn't manage to bisect it down. I guess that Enzyme always generated invalid IR, but it by coincidence didn't missbehave? Now that I rebuild LLVM with assertions enabled to minimize other bugs this one showed up as well.
It doesn't trigger on llvm-21, and 22 or 23 are not avaialble in the enzyme explorer.
Any naive attempt at fixing it also runs into the other regression in https://github.com/EnzymeAD/Enzyme/issues/3040
`opt e17-reduced.ll -load-pass-plugin=/path/to/enzyme.so -passes=enzyme -enzyme-strict-aliasing=0`
```lllvm
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"
target triple = "x86_64-unknown-linux-gnu"
define void @f(ptr %p, i1 %c) {
entry:
br i1 %c, label %outer, label %load.loop
load.loop: ; preds = %load.loop, %entry
%i = phi i64 [ %i.next, %load.loop ], [ 0, %entry ]
%i.next = add i64 %i, 1
%i.gep = getelementptr double, ptr %p, i64 %i
%i.val = load double, ptr %i.gep, align 8
br i1 %c, label %outer, label %load.loop
outer: ; preds = %body, %load.loop, %entry
%j = phi i64 [ %j.next, %body ], [ 0, %load.loop ], [ 0, %entry ]
%j.next = add i64 %j, 1
br label %inner
inner: ; preds = %body, %outer
%k = phi i64 [ %k.next, %body ], [ %j, %outer ]
%k.next = add i64 %k, 1
%k.cond = icmp ult i64 %k, 100
br i1 %k.cond, label %body, label %exit
body: ; preds = %inner
%k.gep = getelementptr double, ptr %p, i64 %k
store double 0.000000e+00, ptr %k.gep, align 8
br i1 %c, label %outer, label %inner
exit: ; preds = %inner
ret void
}
define void @entry() {
call void (...) @__enzyme_autodiff_f(ptr @f, ptr null, ptr null, i1 false)
ret void
}
declare void @__enzyme_autodiff_f(...)
```
Contributor guide
Research direction
Run the provided opt command with e17-reduced.ll, LLVM assertions enabled, and the Enzyme pass loaded to reproduce the DT.dominates assertion. Trace the recurrence and dominance handling involved in the failure, while checking the related regression in issue 3040. Done means the supplied reproducer no longer triggers this assertion.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100