
Cyclic dependencies in NewGVN can result in miscompilation and termination issues. This patch ensures that the Class Leader is always the member with the lowest RPO number. This ensures that the Class Leader is processed before all other members, making the cyclic dependence impossible. This fixes #35683. Regressions: - 'simp-to-self.ll' regresses due to a known limitation in the way NewGVN and InstSimplify interact. With the new leader, InstSimplify does not know that %conv is 1 and fails to simplify.
32 lines
785 B
LLVM
32 lines
785 B
LLVM
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
|
; RUN: opt -passes=newgvn -S %s | FileCheck %s
|
|
|
|
declare void @foo(i32)
|
|
|
|
define void @main(i1 %c1, i1 %c2, i32 %x) {
|
|
; CHECK-LABEL: @main(
|
|
; CHECK-NEXT: entry:
|
|
; CHECK-NEXT: br i1 [[C1:%.*]], label [[L:%.*]], label [[END:%.*]]
|
|
; CHECK: L:
|
|
; CHECK-NEXT: [[XOR:%.*]] = xor i32 [[X:%.*]], -1
|
|
; CHECK-NEXT: [[NEG:%.*]] = xor i32 [[XOR]], -1
|
|
; CHECK-NEXT: call void @foo(i32 [[NEG]])
|
|
; CHECK-NEXT: br label [[L]]
|
|
; CHECK: end:
|
|
; CHECK-NEXT: ret void
|
|
;
|
|
entry:
|
|
br i1 %c1, label %L, label %end
|
|
|
|
L:
|
|
%d.1 = phi i8 [ undef, %entry ], [ -1, %L ]
|
|
%conv = sext i8 %d.1 to i32
|
|
%xor = xor i32 %x, %conv
|
|
%neg = xor i32 %xor, -1
|
|
call void @foo(i32 %neg)
|
|
br label %L
|
|
|
|
end:
|
|
ret void
|
|
}
|