Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions llvm/lib/Transforms/Utils/LoopUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2032,6 +2032,7 @@ Value *llvm::addRuntimeChecks(
MemoryRuntimeCheck = IsConflict;
}

Exp.eraseDeadInstructions(MemoryRuntimeCheck);
return MemoryRuntimeCheck;
}

Expand Down Expand Up @@ -2077,6 +2078,7 @@ Value *llvm::addDiffRuntimeChecks(
MemoryRuntimeCheck = IsConflict;
}

Expander.eraseDeadInstructions(MemoryRuntimeCheck);
return MemoryRuntimeCheck;
}

Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/Transforms/Utils/LoopVersioning.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ void LoopVersioning::versionLoop(
} else
RuntimeCheck = MemRuntimeCheck ? MemRuntimeCheck : SCEVRuntimeCheck;

Exp.eraseDeadInstructions(SCEVRuntimeCheck);

assert(RuntimeCheck && "called even though we don't need "
"any runtime checks");

Expand Down
1 change: 0 additions & 1 deletion llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1849,7 +1849,6 @@ class GeneratedRTChecks {
}

SCEVExp.eraseDeadInstructions(SCEVCheckCond);
MemCheckExp.eraseDeadInstructions(MemRuntimeCheckCond);

if (!MemCheckBlock && !SCEVCheckBlock)
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ define void @f(ptr noalias %a, ptr noalias %b, ptr noalias %c, ptr noalias %d, p
; CHECK-NEXT: [[TMP0:%.*]] = add i64 [[N:%.*]], -1
; CHECK-NEXT: [[TMP2:%.*]] = trunc i64 [[TMP0]] to i32
; CHECK-NEXT: [[MUL1:%.*]] = call { i32, i1 } @llvm.umul.with.overflow.i32(i32 2, i32 [[TMP2]])
; CHECK-NEXT: [[MUL_RESULT:%.*]] = extractvalue { i32, i1 } [[MUL1]], 0
; CHECK-NEXT: [[MUL_OVERFLOW:%.*]] = extractvalue { i32, i1 } [[MUL1]], 1
; CHECK-NEXT: [[TMP1:%.*]] = icmp ugt i64 [[TMP0]], 4294967295
; CHECK-NEXT: [[TMP3:%.*]] = or i1 [[MUL_OVERFLOW]], [[TMP1]]
Expand Down Expand Up @@ -142,7 +141,6 @@ define void @f_with_offset(ptr noalias %b, ptr noalias %c, ptr noalias %d, ptr n
; CHECK-NEXT: [[TMP0:%.*]] = add i64 [[N:%.*]], -1
; CHECK-NEXT: [[TMP2:%.*]] = trunc i64 [[TMP0]] to i32
; CHECK-NEXT: [[MUL1:%.*]] = call { i32, i1 } @llvm.umul.with.overflow.i32(i32 2, i32 [[TMP2]])
; CHECK-NEXT: [[MUL_RESULT:%.*]] = extractvalue { i32, i1 } [[MUL1]], 0
; CHECK-NEXT: [[MUL_OVERFLOW:%.*]] = extractvalue { i32, i1 } [[MUL1]], 1
; CHECK-NEXT: [[TMP1:%.*]] = icmp ugt i64 [[TMP0]], 4294967295
; CHECK-NEXT: [[TMP3:%.*]] = or i1 [[MUL_OVERFLOW]], [[TMP1]]
Expand Down
18 changes: 5 additions & 13 deletions llvm/test/Transforms/LoopVersioning/incorrect-phi.ll
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 --check-globals none
; RUN: opt -passes=loop-versioning -S < %s | FileCheck %s

; Make sure all PHIs are properly updated in the exit block. Based on
Expand All @@ -9,10 +9,6 @@
define void @phi_with_poison() {
; CHECK-LABEL: define void @phi_with_poison() {
; CHECK-NEXT: [[BB6_LVER_CHECK:.*:]]
; CHECK-NEXT: [[MUL:%.*]] = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 10, i64 0)
; CHECK-NEXT: [[MUL_RESULT:%.*]] = extractvalue { i64, i1 } [[MUL]], 0
; CHECK-NEXT: [[MUL_OVERFLOW:%.*]] = extractvalue { i64, i1 } [[MUL]], 1
; CHECK-NEXT: [[TMP0:%.*]] = sub i64 0, [[MUL_RESULT]]
; CHECK-NEXT: br i1 poison, label %[[BB6_PH_LVER_ORIG:.*]], label %[[BB6_PH:.*]]
; CHECK: [[BB6_PH_LVER_ORIG]]:
; CHECK-NEXT: br label %[[BB6_LVER_ORIG:.*]]
Expand All @@ -32,8 +28,8 @@ define void @phi_with_poison() {
; CHECK-NEXT: [[_TMP123:%.*]] = getelementptr [2 x [3 x [5 x i16]]], ptr @x, i16 0, i64 poison
; CHECK-NEXT: [[_TMP126:%.*]] = getelementptr [3 x [5 x i16]], ptr [[_TMP123]], i16 0, i64 [[_TMP1423]]
; CHECK-NEXT: [[_TMP129:%.*]] = getelementptr [5 x i16], ptr [[_TMP126]], i16 0, i64 poison
; CHECK-NEXT: [[_TMP130:%.*]] = load i16, ptr [[_TMP129]], align 2
; CHECK-NEXT: store i16 poison, ptr @x, align 2
; CHECK-NEXT: [[_TMP130:%.*]] = load i16, ptr [[_TMP129]], align 2, !alias.scope [[META0:![0-9]+]]
; CHECK-NEXT: store i16 poison, ptr @x, align 2, !alias.scope [[META3:![0-9]+]]
; CHECK-NEXT: [[_TMP142]] = add i64 [[_TMP1423]], 1
; CHECK-NEXT: br i1 false, label %[[BB6]], label %[[LOOP_EXIT_LOOPEXIT1:.*]]
; CHECK: [[LOOP_EXIT_LOOPEXIT]]:
Expand Down Expand Up @@ -77,10 +73,6 @@ define void @phi_with_non_loop_defined_value() {
; CHECK-LABEL: define void @phi_with_non_loop_defined_value() {
; CHECK-NEXT: [[BB6_LVER_CHECK:.*:]]
; CHECK-NEXT: [[T:%.*]] = add i16 1, 1
; CHECK-NEXT: [[MUL:%.*]] = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 10, i64 0)
; CHECK-NEXT: [[MUL_RESULT:%.*]] = extractvalue { i64, i1 } [[MUL]], 0
; CHECK-NEXT: [[MUL_OVERFLOW:%.*]] = extractvalue { i64, i1 } [[MUL]], 1
; CHECK-NEXT: [[TMP0:%.*]] = sub i64 0, [[MUL_RESULT]]
; CHECK-NEXT: br i1 poison, label %[[BB6_PH_LVER_ORIG:.*]], label %[[BB6_PH:.*]]
; CHECK: [[BB6_PH_LVER_ORIG]]:
; CHECK-NEXT: br label %[[BB6_LVER_ORIG:.*]]
Expand All @@ -100,8 +92,8 @@ define void @phi_with_non_loop_defined_value() {
; CHECK-NEXT: [[_TMP123:%.*]] = getelementptr [2 x [3 x [5 x i16]]], ptr @x, i16 0, i64 poison
; CHECK-NEXT: [[_TMP126:%.*]] = getelementptr [3 x [5 x i16]], ptr [[_TMP123]], i16 0, i64 [[_TMP1423]]
; CHECK-NEXT: [[_TMP129:%.*]] = getelementptr [5 x i16], ptr [[_TMP126]], i16 0, i64 poison
; CHECK-NEXT: [[_TMP130:%.*]] = load i16, ptr [[_TMP129]], align 2
; CHECK-NEXT: store i16 poison, ptr @x, align 2
; CHECK-NEXT: [[_TMP130:%.*]] = load i16, ptr [[_TMP129]], align 2, !alias.scope [[META5:![0-9]+]]
; CHECK-NEXT: store i16 poison, ptr @x, align 2, !alias.scope [[META8:![0-9]+]]
; CHECK-NEXT: [[_TMP142]] = add i64 [[_TMP1423]], 1
; CHECK-NEXT: br i1 false, label %[[BB6]], label %[[LOOP_EXIT_LOOPEXIT1:.*]]
; CHECK: [[LOOP_EXIT_LOOPEXIT]]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,12 @@ define void @f1(ptr noalias %a,
; LV-NEXT: [[TMP0:%.*]] = add i64 [[N:%.*]], -1
; LV-NEXT: [[TMP5:%.*]] = trunc i64 [[TMP0]] to i32
; LV-NEXT: [[MUL2:%.*]] = call { i32, i1 } @llvm.umul.with.overflow.i32(i32 2, i32 [[TMP5]])
; LV-NEXT: [[MUL_RESULT1:%.*]] = extractvalue { i32, i1 } [[MUL2]], 0
; LV-NEXT: [[MUL_OVERFLOW1:%.*]] = extractvalue { i32, i1 } [[MUL2]], 1
; LV-NEXT: [[TMP1:%.*]] = icmp ugt i64 [[TMP0]], 4294967295
; LV-NEXT: [[TMP8:%.*]] = or i1 [[MUL_OVERFLOW1]], [[TMP1]]
; LV-NEXT: [[MUL1:%.*]] = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 4, i64 [[TMP0]])
; LV-NEXT: [[MUL_RESULT:%.*]] = extractvalue { i64, i1 } [[MUL1]], 0
; LV-NEXT: [[MUL_OVERFLOW:%.*]] = extractvalue { i64, i1 } [[MUL1]], 1
; LV-NEXT: [[TMP2:%.*]] = sub i64 0, [[MUL_RESULT]]
; LV-NEXT: [[TMP3:%.*]] = getelementptr i8, ptr [[A:%.*]], i64 [[MUL_RESULT]]
; LV-NEXT: [[TMP4:%.*]] = icmp ult ptr [[TMP3]], [[A]]
; LV-NEXT: [[TMP6:%.*]] = or i1 [[TMP4]], [[MUL_OVERFLOW]]
Expand Down Expand Up @@ -264,7 +262,6 @@ define void @f3(ptr noalias %a,
; LV-NEXT: [[MUL2:%.*]] = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 4, i64 [[TMP0]])
; LV-NEXT: [[MUL_RESULT3:%.*]] = extractvalue { i64, i1 } [[MUL2]], 0
; LV-NEXT: [[MUL_OVERFLOW4:%.*]] = extractvalue { i64, i1 } [[MUL2]], 1
; LV-NEXT: [[TMP6:%.*]] = sub i64 0, [[MUL_RESULT3]]
; LV-NEXT: [[TMP7:%.*]] = getelementptr i8, ptr [[A:%.*]], i64 [[MUL_RESULT3]]
; LV-NEXT: [[TMP8:%.*]] = icmp ult ptr [[TMP7]], [[A]]
; LV-NEXT: [[TMP9:%.*]] = or i1 [[TMP8]], [[MUL_OVERFLOW4]]
Expand Down