[PATCH] D48181: [JumpThreading] Ignore nil destionation when determining whether a block only goes to a single destination

Xin Tong via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 22 11:20:40 PDT 2018


Hi Daniel.

This is how i understand this now. Please correct me if i am wrong.
In this example, we can not turn the UNDEF to X unless we know X
dominates the block where Y declared and loaded, the reason we have a
UNDEF there is because Y can be uninitialized. However, if X does not
dominate B2, we can not initialize y = X. Thanks for pointing this
out.

@foo() {
B1:
 z = X
  br Dest
B2:
  int y;
  z = y;
  br Dest
B3
 z = X
  br Dest
Dest;
  %z = phi(X, UNDEF (value of Y because Y is not initialized), X)
  return %z;
}

-Xin
On Fri, Jun 22, 2018 at 10:17 AM Daniel Berlin <dberlin at dberlin.org> wrote:
>
> In particular,  if you have a PHI node like phi(X, undef, X), you cannot say the value is X unless X dominates the phi block.
>
>
> On Fri, Jun 22, 2018 at 10:15 AM, Daniel Berlin <dberlin at dberlin.org> wrote:
>>
>>
>>
>>
>> On Fri, Jun 22, 2018 at 9:41 AM, Xin Tong via Phabricator via llvm-commits <llvm-commits at lists.llvm.org> wrote:
>>>
>>> trentxintong added a comment.
>>>
>>> Hi @brzycki. This is a deficiency in a feature we already have. In jump threading, when we can tell all the predecessors of a block go to the same destination. we do not need to thread, we can just fold the terminator of the block. This has less impact on the CFG and also we do not have the problem of not being able to jump threading because the block can not be duplicated.
>>>
>>> In case we have a Val being UNDEF, we can ignore it as it can be treated as going to any successor, i.e. we should not go to MultipleDestSentinel state because we see  a DestBB==nullptr.
>>
>> This is not generally true.
>> It's only true if the block is unreachable.
>>
>>
>


More information about the llvm-commits mailing list