[PATCH] D75799: [JumpThreading] Don't create PHI nodes with "is.constant" values

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 9 02:39:33 PDT 2020


lebedev.ri added a comment.

In D75799#1911874 <https://reviews.llvm.org/D75799#1911874>, @void wrote:

> In D75799#1911594 <https://reviews.llvm.org/D75799#1911594>, @nikic wrote:
>
> > @void From your example, I still don't really get what the problem is / why this has to be done in JumpThreading in particular. The `%6` phi that gets inserted here looks harmless to me -- the phi is trivial and will get eliminated by any simplification pass later in the pipeline (though I'm not entirely sure why a single-arg phi gets created in the first place).
> >
> > What you seem to be really doing here is to move the is.constant lowering from the LowerConstantIntrinsics pass into the JumpThreading pass. It sounds to me like some kind of phase ordering issue where LowerConstantIntrinsics runs too late for the necessary DCE to be performed. Is that right? What does the IR look like at the point where the lowering is (currently) performed?
>
>
> [@lebedev.ri this is in response to your question as well.]
>
> <...>




In D75799#1911874 <https://reviews.llvm.org/D75799#1911874>, @void wrote:

> This is after jump threading:


Are you sure that is the correct snippet? Because if it is, i'm lost completely.

> It turns out that during jump threading, the `if.end616` block has a constant and non-constant value coming into it and are combined in a PHI node. This is why the block is duplicated (a constant block `if.end616.thread` and non-constant `if.end616`). But this messes with the `llvm.is.constant` intrinsic, which looks at that value:
> 
>   if.end616.thread:
>     %len.0204 = phi i32 [ 24, %if.end603 ]
>     %conv617205 = sext i32 %len.0204 to i64 
>     %cmp3.i.i181 = icmp ugt i32 %len.0204, 24 
>     %177 = call i1 @llvm.is.constant.i64(i64 %conv617205)                                                                  
>     br i1 %cmp3.i.i181, label %if.then.i.i182, label %if.end12.i.i185
>   
>   if.end616:                                                                 
>     %len.0 = phi i32 [ %conv592, %if.end603 ]
>     %conv617 = sext i32 %len.0 to i64 
>     %cmp3.i.i181 = icmp ugt i32 %len.0, 24 
>     %178 = call i1 @llvm.is.constant.i64(i64 %conv617)                                                                  
>     br i1 %cmp3.i.i181, label %if.then.i.i182, label %if.end12.i.i185

I'm not seeing `@if.end603` and `@if.end616.thread`, in `This is after jump threading:` snippet.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75799/new/

https://reviews.llvm.org/D75799





More information about the llvm-commits mailing list