Skip to content

Commit 064bfdd

Browse files
committed
[IndVarSimplify] Add pre-commit tests. NFC.
1 parent 4f1fe6d commit 064bfdd

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

llvm/test/Transforms/IndVarSimplify/finite-exit-comparisons.ll

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,3 +1052,43 @@ for.end: ; preds = %for.body, %entry
10521052
ret void
10531053
}
10541054

1055+
define i8 @test_drop_icmp_samesign(i1 %cond, i32 range(i32 0, 32) %x) {
1056+
; CHECK-LABEL: @test_drop_icmp_samesign(
1057+
; CHECK-NEXT: entry:
1058+
; CHECK-NEXT: br i1 [[COND:%.*]], label [[FOR_BODY_PREHEADER:%.*]], label [[ELSE:%.*]]
1059+
; CHECK: for.body.preheader:
1060+
; CHECK-NEXT: [[TMP0:%.*]] = trunc i32 [[X:%.*]] to i8
1061+
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
1062+
; CHECK: else:
1063+
; CHECK-NEXT: [[CALL1:%.*]] = call i8 @callee()
1064+
; CHECK-NEXT: br label [[EXIT:%.*]]
1065+
; CHECK: for.body:
1066+
; CHECK-NEXT: [[CALL2:%.*]] = call i8 @callee()
1067+
; CHECK-NEXT: [[COND2:%.*]] = icmp samesign ugt i8 [[TMP0]], [[CALL2]]
1068+
; CHECK-NEXT: br i1 [[COND2]], label [[FOR_BODY]], label [[EXIT_LOOPEXIT:%.*]]
1069+
; CHECK: exit.loopexit:
1070+
; CHECK-NEXT: [[CALL2_LCSSA:%.*]] = phi i8 [ [[CALL2]], [[FOR_BODY]] ]
1071+
; CHECK-NEXT: br label [[EXIT]]
1072+
; CHECK: exit:
1073+
; CHECK-NEXT: [[RES:%.*]] = phi i8 [ [[CALL1]], [[ELSE]] ], [ [[CALL2_LCSSA]], [[EXIT_LOOPEXIT]] ]
1074+
; CHECK-NEXT: ret i8 [[RES]]
1075+
;
1076+
entry:
1077+
br i1 %cond, label %for.body, label %else
1078+
1079+
else:
1080+
%call1 = call i8 @callee()
1081+
br label %exit
1082+
1083+
for.body:
1084+
%call2 = call i8 @callee()
1085+
%ext = zext i8 %call2 to i32
1086+
%cond2 = icmp samesign ugt i32 %x, %ext
1087+
br i1 %cond2, label %for.body, label %exit
1088+
1089+
exit:
1090+
%res = phi i8 [ %call1, %else ], [ %call2, %for.body ]
1091+
ret i8 %res
1092+
}
1093+
1094+
declare i8 @callee()

0 commit comments

Comments
 (0)