Skip to content

Commit 9e7d1ec

Browse files
committed
[CVP] Add pre-commit tests. NFC.
1 parent b55fa20 commit 9e7d1ec

File tree

1 file changed

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

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
2+
; RUN: opt < %s -passes=correlated-propagation -S | FileCheck %s
3+
4+
; Make sure that the optimization does not introduce immediate UB.
5+
6+
define i8 @test(i16 %x) {
7+
; CHECK-LABEL: define range(i8 -128, 1) i8 @test(
8+
; CHECK-SAME: i16 [[X:%.*]]) {
9+
; CHECK-NEXT: [[ENTRY:.*]]:
10+
; CHECK-NEXT: [[OR:%.*]] = or i16 [[X]], 1
11+
; CHECK-NEXT: [[CONV:%.*]] = trunc nuw nsw i16 [[OR]] to i8
12+
; CHECK-NEXT: [[MIN:%.*]] = call noundef i8 @llvm.smin.i8(i8 [[CONV]], i8 0)
13+
; CHECK-NEXT: [[COND:%.*]] = icmp eq i16 [[X]], 0
14+
; CHECK-NEXT: br i1 [[COND]], label %[[IF_END:.*]], label %[[IF_THEN:.*]]
15+
; CHECK: [[IF_THEN]]:
16+
; CHECK-NEXT: br label %[[IF_END]]
17+
; CHECK: [[IF_END]]:
18+
; CHECK-NEXT: [[RES:%.*]] = phi i8 [ [[MIN]], %[[ENTRY]] ], [ 0, %[[IF_THEN]] ]
19+
; CHECK-NEXT: ret i8 [[RES]]
20+
;
21+
entry:
22+
%or = or i16 %x, 1
23+
%conv = trunc i16 %or to i8
24+
%min = call noundef i8 @llvm.smin.i8(i8 %conv, i8 0)
25+
%cond = icmp eq i16 %x, 0
26+
br i1 %cond, label %if.end, label %if.then
27+
28+
if.then:
29+
br label %if.end
30+
31+
if.end:
32+
%res = phi i8 [ %min, %entry ], [ 0, %if.then ]
33+
ret i8 %res
34+
}

0 commit comments

Comments
 (0)