[PATCH] D57053: Extra processing for BitCast + PHI in InstCombine
Igor Tsimbalist via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 8 07:40:59 PST 2019
itsimbal added a comment.
There are two issues:
1. Extra redundant phi nodes are created. If you look at the test output (without proposed changes) you will see
%4 = phi float [ %21, %.bb12 ], [ %conv.i, %.bb2 ]
%5 = phi float [ %22, %.bb12 ], [ %conv.i, %.bb2 ]
%rA.sroa.8.0 = phi i32 [ %rA.sroa.8.2, %.bb12 ], [ %1, %.bb2 ]
%6 = phi float [ %23, %.bb12 ], [ %conv.i, %.bb2 ]
%7 = phi float [ %24, %.bb12 ], [ %conv.i, %.bb2 ]
%rA.sroa.0.0 = phi i32 [ %rA.sroa.0.2, %.bb12 ], [ %1, %.bb2 ]
and
%13 = phi float [ %add33.1, %.bb4 ], [ %4, %.bb3 ]
%14 = phi float [ %add33.1, %.bb4 ], [ %5, %.bb3 ]
%rA.sroa.8.1 = phi i32 [ %11, %.bb4 ], [ %rA.sroa.8.0, %.bb3 ]
%15 = phi float [ %add33.2, %.bb4 ], [ %6, %.bb3 ]
%16 = phi float [ %add33.2, %.bb4 ], [ %7, %.bb3 ]
%rA.sroa.0.1 = phi i32 [ %12, %.bb4 ], [ %rA.sroa.0.0, %.bb3 ]
Here %5, %7, %14, %16 are redundant. These insns are created as not all bitcast insns are removed when we first hit the needed pattern. Depending on a loop unroll factor there will be (factor-1) redundant phi nodes. In the attached test case for simplicity unroll the factor is 2. In my real test the unroll factor is 16 and I got 15 redundant phi nodes for each original phi node.
2. Not all bitcast insns are removed while they could be. The optimizeBitCastFromPhi removes only **one ** bitcast, which triggers it. Due to this the old phi nodes are also not removed. The fix tries to remove all bitcast insns which are reachable from found phi closure. The test output (with the fix applied) doesn't have any bitcast insns and old phi nodes as well.
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D57053/new/
https://reviews.llvm.org/D57053
More information about the llvm-commits
mailing list