Skip to content

Commit e7618a6

Browse files
committed
[GVN] Fix change reporting when removing assume (PR61574)
Report a change when removing a true/false assume. Fixes llvm#61574.
1 parent e4ceb5a commit e7618a6

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

llvm/lib/Transforms/Scalar/GVN.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1908,8 +1908,10 @@ bool GVNPass::processAssumeIntrinsic(AssumeInst *IntrinsicI) {
19081908
MSSAU->insertDef(cast<MemoryDef>(NewDef), /*RenameUses=*/false);
19091909
}
19101910
}
1911-
if (isAssumeWithEmptyBundle(*IntrinsicI))
1911+
if (isAssumeWithEmptyBundle(*IntrinsicI)) {
19121912
markInstructionForDeletion(IntrinsicI);
1913+
return true;
1914+
}
19131915
return false;
19141916
} else if (isa<Constant>(V)) {
19151917
// If it's not false, and constant, it must evaluate to true. This means our

llvm/test/Transforms/GVN/assume.ll

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,26 @@
11
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2-
; RUN: opt < %s -passes=gvn -S | FileCheck %s
2+
; RUN: opt < %s -passes=gvn -verify-analysis-invalidation -S | FileCheck %s
33

44
declare void @llvm.assume(i1)
55
declare void @use(i1)
66

7+
define void @assume_true() {
8+
; CHECK-LABEL: @assume_true(
9+
; CHECK-NEXT: ret void
10+
;
11+
call void @llvm.assume(i1 true)
12+
ret void
13+
}
14+
15+
define void @assume_false() {
16+
; CHECK-LABEL: @assume_false(
17+
; CHECK-NEXT: store i8 poison, ptr null, align 1
18+
; CHECK-NEXT: ret void
19+
;
20+
call void @llvm.assume(i1 false)
21+
ret void
22+
}
23+
724
define void @assume_arg(i1 %x) {
825
; CHECK-LABEL: @assume_arg(
926
; CHECK-NEXT: call void @llvm.assume(i1 [[X:%.*]])

0 commit comments

Comments
 (0)