diff options
author | Florian Hahn <flo@fhahn.com> | 2023-11-22 12:48:03 +0000 |
---|---|---|
committer | Florian Hahn <flo@fhahn.com> | 2023-11-22 12:48:04 +0000 |
commit | 32d1197a8faf4c04df5fcd6c0588aa288bc42e35 (patch) | |
tree | 38d0dce5dfe1f4a2083cd68ec29d17a90f5114da /llvm/lib/Transforms/Utils/LoopUtils.cpp | |
parent | eed17dcf76b5aea30348a515e9fddd0789fec054 (diff) | |
download | llvm-32d1197a8faf4c04df5fcd6c0588aa288bc42e35.zip llvm-32d1197a8faf4c04df5fcd6c0588aa288bc42e35.tar.gz llvm-32d1197a8faf4c04df5fcd6c0588aa288bc42e35.tar.bz2 |
[LV] Use SCEV for subtraction of src/sink for diff runtime checks.
Instead of expanding the src/sink SCEV expressions and emitting an IR
sub to compute the difference, the subtraction can be directly be
performed by ScalarEvolution. This allows the subtraction to be
simplified by SCEV, which in turn can reduced the number of redundant
runtime check instructions generated.
It also allows to generate checks that are invariant w.r.t. an outer
loop, if he inner loop AddRecs have the same outer loop AddRec as start.
Diffstat (limited to 'llvm/lib/Transforms/Utils/LoopUtils.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/LoopUtils.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Utils/LoopUtils.cpp b/llvm/lib/Transforms/Utils/LoopUtils.cpp index 8bb4e17..85e28ea 100644 --- a/llvm/lib/Transforms/Utils/LoopUtils.cpp +++ b/llvm/lib/Transforms/Utils/LoopUtils.cpp @@ -1793,9 +1793,9 @@ Value *llvm::addDiffRuntimeChecks( auto *VFTimesUFTimesSize = ChkBuilder.CreateMul(GetVF(ChkBuilder, Ty->getScalarSizeInBits()), ConstantInt::get(Ty, IC * C.AccessSize)); - Value *Sink = Expander.expandCodeFor(C.SinkStart, Ty, Loc); - Value *Src = Expander.expandCodeFor(C.SrcStart, Ty, Loc); - Value *Diff = ChkBuilder.CreateSub(Sink, Src); + auto &SE = *Expander.getSE(); + Value *Diff = Expander.expandCodeFor( + SE.getMinusSCEV(C.SinkStart, C.SrcStart), Ty, Loc); Value *IsConflict = ChkBuilder.CreateICmpULT(Diff, VFTimesUFTimesSize, "diff.check"); if (C.NeedsFreeze) |