[PATCH] D41578: [SCEV] Do not cache S -> V if S is not equivalent of V

Evgeny Astigeevich via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 10 09:59:58 PST 2018


eastig added a comment.

Hi Sergey,

The patch caused 4% regression in one of our benchmarks. It affected LoopStrength Reduction. I don't have a full reproducer yet but maybe the following will be enough to figure out the issue:

IR before the patch

  while.end83.i:                                    ; preds = %while.end83.isplit, %while.body76.3.i.while.end83.i_crit_edge
    ...
    %mul86.i = mul nuw nsw i32 %phitmp280.i, %phitmp.i
    %sub.ptr.lhs.cast.i = ptrtoint i8* %incdec.ptr70.lcssa.i to i32
    %mul88.i = mul i32 %mul86.i, 3
    %sub.ptr.sub.i = add i32 %mul88.i, %sub.ptr.lhs.cast.i
    %add89.i = sub i32 %sub.ptr.sub.i, ptrtoint (...)
    %cmp90.i = icmp eq i32 %add89.i, 230416
    br i1 %cmp90.i, label %if.end94.i, label %if.then92.i
  
  
  if.end94.i:                                       ; preds = %while.end83.i
    ...
    %cmp97.i = icmp eq i8* %call96.i, null
    br i1 %cmp97.i, label %if.then99.i, label %if.end100.i
  
  if.then99.i:                                      ; preds = %if.end94.i
    ...
    br label %if.end100.i
  
  if.end100.i:                                      ; preds = %if.then99.i, %if.end94.i
    ...
    %cmp101247.i = icmp eq i32 %13, 0
    br i1 %cmp101247.i, label %for.end147.i, label %for.body.lr.ph.i
  
  for.body.lr.ph.i:                                 ; preds = %if.end100.i
    %cmp104243.i = icmp eq i32 %mul86.i, 0
    br i1 %cmp104243.i, label %for.body.preheader.i, label %for.body.us.preheader.i
  
  for.body.us.preheader.i:                          ; preds = %for.body.lr.ph.i
    %14 = add nsw i32 %mul86.i, -1
    %xtraiter289.i = and i32 %mul86.i, 3
    %15 = icmp ult i32 %14, 3
    %lcmp.mod292.i = icmp eq i32 %xtraiter289.i, 0
    %epil.iter.cmp291.i = icmp eq i32 %xtraiter289.i, 1
    %epil.iter.cmp291.1.i = icmp eq i32 %xtraiter289.i, 2
    %16 = sub i32 %xtraiter289.i, %mul86.i

IR after the patch

  while.end83.i:                                    ; preds = %while.end83.isplit, %while.body76.3.i.while.end83.i_crit_edge
    ...
    %mul86.i = mul nuw nsw i32 %phitmp280.i, %phitmp.i
    %sub.ptr.lhs.cast.i = ptrtoint i8* %incdec.ptr70.lcssa.i to i32
    %mul88.i = mul i32 %mul86.i, 3
    %sub.ptr.sub.i = add i32 %mul88.i, %sub.ptr.lhs.cast.i
    %add89.i = sub i32 %sub.ptr.sub.i, ptrtoint (...)
    %cmp90.i = icmp eq i32 %add89.i, 230416
    br i1 %cmp90.i, label %if.end94.i, label %if.then92.i
  
  if.end94.i:                                       ; preds = %while.end83.i
    ...
    %cmp97.i = icmp eq i8* %call96.i, null
    br i1 %cmp97.i, label %if.then99.i, label %if.end100.i
  
  if.then99.i:                                      ; preds = %if.end94.i
    ...
    br label %if.end100.i
  
  if.end100.i:                                      ; preds = %if.then99.i, %if.end94.i
    ...
    %cmp101247.i = icmp eq i32 %13, 0
    br i1 %cmp101247.i, label %for.end147.i, label %for.body.lr.ph.i
  
  for.body.lr.ph.i:                                 ; preds = %if.end100.i
    %cmp104243.i = icmp eq i32 %mul86.i, 0
    br i1 %cmp104243.i, label %for.body.preheader.i, label %for.body.us.preheader.i
  
  for.body.us.preheader.i:                          ; preds = %for.body.lr.ph.i
    %14 = add nsw i32 %mul86.i, -1
    %xtraiter289.i = and i32 %mul86.i, 3
    %15 = icmp ult i32 %14, 3
    %lcmp.mod292.i = icmp eq i32 %xtraiter289.i, 0
    %epil.iter.cmp291.i = icmp eq i32 %xtraiter289.i, 1
    %epil.iter.cmp291.1.i = icmp eq i32 %xtraiter289.i, 2
    %16 = mul i32 %phitmp280.i, %phitmp.i
    %17 = sub i32 %xtraiter289.i, %16

The patch caused '%16 = mul i32 %phitmp280.i, %phitmp.i' to appear in the loop.

Any idea what to look at?

Thanks,
Evgeny Astigeevich


Repository:
  rL LLVM

https://reviews.llvm.org/D41578





More information about the llvm-commits mailing list