aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/LoopUtils.cpp
diff options
context:
space:
mode:
authorFlorian Hahn <flo@fhahn.com>2023-11-21 10:54:35 +0000
committerFlorian Hahn <flo@fhahn.com>2023-11-21 10:54:36 +0000
commitead35564c0136fef0c1efface7b9857ad87af9de (patch)
tree85b88fad8b99f898478c1b8e4e2547ca1d3941ef /llvm/lib/Transforms/Utils/LoopUtils.cpp
parent6a323e7ec3478e633ba85ce6c274f02d0b31299b (diff)
downloadllvm-ead35564c0136fef0c1efface7b9857ad87af9de.zip
llvm-ead35564c0136fef0c1efface7b9857ad87af9de.tar.gz
llvm-ead35564c0136fef0c1efface7b9857ad87af9de.tar.bz2
[LoopUtils] Freeze compare results for diff checks instead of pointers.
THe freezes are introduced to avoid branch on undef/poison, if any of the pointers may be poison. The same can be achieved by just freezing the compare, which reduces the number of freezes needed. See https://alive2.llvm.org/ce/z/NHa_ud Note that the individual compares need to be frozen and it is not sufficient to only freeze the resulting OR: Result OR frozen only (UNSOUND): https://alive2.llvm.org/ce/z/YzFHQY Individual conds frozen (SOUND): https://alive2.llvm.org/ce/z/5L6Z3f
Diffstat (limited to 'llvm/lib/Transforms/Utils/LoopUtils.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/LoopUtils.cpp9
1 files changed, 3 insertions, 6 deletions
diff --git a/llvm/lib/Transforms/Utils/LoopUtils.cpp b/llvm/lib/Transforms/Utils/LoopUtils.cpp
index c03d118..8bb4e17 100644
--- a/llvm/lib/Transforms/Utils/LoopUtils.cpp
+++ b/llvm/lib/Transforms/Utils/LoopUtils.cpp
@@ -1795,15 +1795,12 @@ Value *llvm::addDiffRuntimeChecks(
ConstantInt::get(Ty, IC * C.AccessSize));
Value *Sink = Expander.expandCodeFor(C.SinkStart, Ty, Loc);
Value *Src = Expander.expandCodeFor(C.SrcStart, Ty, Loc);
- if (C.NeedsFreeze) {
- IRBuilder<> Builder(Loc);
- Sink = Builder.CreateFreeze(Sink, Sink->getName() + ".fr");
- Src = Builder.CreateFreeze(Src, Src->getName() + ".fr");
- }
Value *Diff = ChkBuilder.CreateSub(Sink, Src);
Value *IsConflict =
ChkBuilder.CreateICmpULT(Diff, VFTimesUFTimesSize, "diff.check");
-
+ if (C.NeedsFreeze)
+ IsConflict =
+ ChkBuilder.CreateFreeze(IsConflict, IsConflict->getName() + ".fr");
if (MemoryRuntimeCheck) {
IsConflict =
ChkBuilder.CreateOr(MemoryRuntimeCheck, IsConflict, "conflict.rdx");