[PATCH] D71053: [LV] Take overhead of run-time checks into account during vectorization.

Evgeniy via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 5 19:02:59 PST 2019


ebrevnov added a comment.

In D71053#1770322 <https://reviews.llvm.org/D71053#1770322>, @rengolin wrote:

> Is this change inspired by a real world case? If so, how relevant / pervasive is this case?


Yes, this case came from the real world benchmark. This change gives +15% on it.

> Also, how different are the run time checks from each other?
> 
> If we assume most of them end up being an additional comparison, sometimes with pointer dereference, and assuming the values will be already in registers (as they're about to be looped over), I think their costs end up being roughly the same, no?
> 
> Or am I missing something obvious?

Run-time checks may involve much more than just comparison and some pointer arithmetic. Here is an example how typical overflow check looks like:

vector.scevcheck:                                 ; preds = %tc.check

  %mul = call { i32, i1 } @llvm.umul.with.overflow.i32(i32 %1, i32 %indvar)
  %mul.result = extractvalue { i32, i1 } %mul, 0
  %mul.overflow = extractvalue { i32, i1 } %mul, 1
  %54 = add i32 %loop-predication.iv, %mul.result
  %55 = sub i32 %loop-predication.iv, %mul.result
  %56 = icmp ugt i32 %55, %loop-predication.iv
  %57 = icmp ult i32 %54, %loop-predication.iv
  %58 = select i1 false, i1 %56, i1 %57
  %59 = or i1 %58, %mul.overflow
  %60 = or i1 false, %59
  %mul268 = call { i32, i1 } @llvm.umul.with.overflow.i32(i32 %2, i32 %indvar)
  %mul.result269 = extractvalue { i32, i1 } %mul268, 0
  %mul.overflow270 = extractvalue { i32, i1 } %mul268, 1
  %61 = add i32 %arg4, %mul.result269
  %62 = sub i32 %arg4, %mul.result269
  %63 = icmp ugt i32 %62, %arg4
  %64 = icmp ult i32 %61, %arg4
  %65 = select i1 false, i1 %63, i1 %64
  %66 = or i1 %65, %mul.overflow270
  %67 = or i1 %60, %66
  br i1 %67, label %scalar.ph, label %vector.memcheck

Thanks
Evgeniy

> Thanks!
> --renato




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71053





More information about the llvm-commits mailing list