[PATCH] D124967: [SROA] Avoid postponing rewriting load/store by ignoring lifetime intrinsics in partition's promotability checking

Dmitry Vassiliev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 6 07:22:10 PDT 2022


slydiman added a comment.

In D124967#3496117 <https://reviews.llvm.org/D124967#3496117>, @nikic wrote:

> If I take your example with and without lifetime intrinsics, then with current SROA, the variant without intrinsics produces a worse result: https://llvm.godbolt.org/z/oPMKWzaMq
> Results of SROA should be the same with an without lifetime intrinsics, but I'm not sure your patch achieves that -- it looks like it produces a third variant that is better than both?

Here is the result after this patch

  define i16 @foo(i32* nocapture readonly %loop) #1 {
  entry:
    br label %while_cond
  
  while_cond:                                       ; preds = %while_body, %entry
    %arr.sroa.6.0 = phi i32 [ 0, %entry ], [ %res1, %while_body ]
    %arr.sroa.0.0 = phi i32 [ 0, %entry ], [ %res0, %while_body ]
    %loopi = load i32, i32* %loop, align 4
    %loopb = icmp eq i32 %loopi, 0
    br i1 %loopb, label %while_end, label %while_body
  
  while_body:                                       ; preds = %while_cond
    %x = call { i32, i32 } @bar(i32 %arr.sroa.0.0, i32 %arr.sroa.6.0) #0
    %res0 = extractvalue { i32, i32 } %x, 0
    %res1 = extractvalue { i32, i32 } %x, 1
    br label %while_cond
  
  while_end:                                        ; preds = %while_cond
    %arr.sroa.0.0.extract.trunc = trunc i32 %arr.sroa.0.0 to i16
    %arr.sroa.6.4.extract.trunc = trunc i32 %arr.sroa.6.0 to i16
    %ret = add i16 %arr.sroa.0.0.extract.trunc, %arr.sroa.6.4.extract.trunc
    ret i16 %ret
  }


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124967



More information about the llvm-commits mailing list