[llvm] [NewGVN] Prevent cyclic reference when building phiofops (PR #69418)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Oct 21 09:03:59 PDT 2023
XChy wrote:
I tried performing SCC finding starting from the leader of `OrigInst`.
```C++
TarjanSCC CycleFinder;
DenseMap<const Value *, SmallVector<Value *, 4>> Edges;
Value *OrigInstLeader =
lookupOperandLeader(const_cast<Value *>((const Value *)OrigInst));
auto *LeaderInst = dyn_cast<Instruction>(OrigInstLeader);
SmallVector<Value *, 4> Members(CC->begin(), CC->end());
Edges[OrigInst] = Members;
CycleFinder.Start(OrigInst, Edges);
if (LeaderInst) {
Edges[LeaderInst] = Members;
CycleFinder.Start(LeaderInst, Edges);
}
```
But it would lead to the fact that we could possibly optimize the IR after eliminate all the redundancies. Example:
```llvm
define i64 @test5() {
bb:
%tmp10 = load i64, ptr null, align 16
%tmp12 = mul i64 %tmp10, %tmp10
%tmp13 = icmp eq i64 %tmp12, 0
br label %bb15
bb15: ; preds = %bb15, %bb
%tmp16 = phi i64 [ 0, %bb15 ], [ %tmp10, %bb ]
%tmp19 = mul i64 %tmp16, %tmp10
store i64 %tmp19, ptr null, align 8
br label %bb15
}
```
https://github.com/llvm/llvm-project/pull/69418
More information about the llvm-commits
mailing list