Skip to content

Commit c74e9b6

Browse files
Add Test for Assume
1 parent 703460b commit c74e9b6

File tree

1 file changed

+17
-0
lines changed
  • llvm/test/Transforms/CorrelatedValuePropagation

1 file changed

+17
-0
lines changed

llvm/test/Transforms/CorrelatedValuePropagation/trunc.ll

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,23 @@ define i8 @infer_nuw_nsw(i16 range(i16 -5, -3) %A, i16 range(i16 -5, -3) %B) {
4545
}
4646

4747

48+
define i8 @infer_nsw_from_assume(i16 %x) {
49+
; CHECK-LABEL: define i8 @infer_nsw_from_assume(
50+
; CHECK-SAME: i16 [[X:%.*]]) {
51+
; CHECK-NEXT: [[ADD:%.*]] = add i16 [[X]], 128
52+
; CHECK-NEXT: [[OR_COND_I:%.*]] = icmp ult i16 [[ADD]], 256
53+
; CHECK-NEXT: tail call void @llvm.assume(i1 [[OR_COND_I]])
54+
; CHECK-NEXT: [[CONV1:%.*]] = trunc nsw i16 [[X]] to i8
55+
; CHECK-NEXT: ret i8 [[CONV1]]
56+
;
57+
%add = add i16 %x, 128
58+
%or.cond.i = icmp ult i16 %add, 256
59+
tail call void @llvm.assume(i1 %or.cond.i)
60+
%conv1 = trunc i16 %x to i8
61+
ret i8 %conv1
62+
}
63+
64+
4865
define i1 @rust_issue_122734(i8 range(i8 0, 3) %A, i8 range(i8 0, 3) %B) {
4966
; CHECK-LABEL: define i1 @rust_issue_122734(
5067
; CHECK-SAME: i8 range(i8 0, 3) [[A:%.*]], i8 range(i8 0, 3) [[B:%.*]]) {

0 commit comments

Comments
 (0)