Skip to content

Commit a632364

Browse files
committed
[InstCombine] Add test for SimplifyDemanded context (NFC)
1 parent db9252b commit a632364

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

llvm/test/Transforms/InstCombine/known-bits.ll

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2008,5 +2008,25 @@ if.else:
20082008
ret i8 %other
20092009
}
20102010

2011+
define i8 @simplifydemanded_context(i8 %x, i8 %y) {
2012+
; CHECK-LABEL: @simplifydemanded_context(
2013+
; CHECK-NEXT: [[AND1:%.*]] = and i8 [[X:%.*]], 1
2014+
; CHECK-NEXT: call void @dummy()
2015+
; CHECK-NEXT: [[X_LOBITS:%.*]] = and i8 [[X]], 3
2016+
; CHECK-NEXT: [[PRECOND:%.*]] = icmp eq i8 [[X_LOBITS]], 0
2017+
; CHECK-NEXT: call void @llvm.assume(i1 [[PRECOND]])
2018+
; CHECK-NEXT: [[AND2:%.*]] = and i8 [[AND1]], [[Y:%.*]]
2019+
; CHECK-NEXT: ret i8 [[AND2]]
2020+
;
2021+
%and1 = and i8 %x, 1
2022+
call void @dummy() ; may unwind
2023+
%x.lobits = and i8 %x, 3
2024+
%precond = icmp eq i8 %x.lobits, 0
2025+
call void @llvm.assume(i1 %precond)
2026+
%and2 = and i8 %and1, %y
2027+
ret i8 %and2
2028+
}
2029+
2030+
declare void @dummy()
20112031
declare void @use(i1)
20122032
declare void @sink(i8)

0 commit comments

Comments
 (0)