1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=correlated-propagation -S | FileCheck %s
4 declare void @use.f32(float)
6 define void @test1(i32 %n) {
9 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[N:%.*]], -1
10 ; CHECK-NEXT: br i1 [[CMP]], label [[BB:%.*]], label [[EXIT:%.*]]
12 ; CHECK-NEXT: [[EXT_WIDE:%.*]] = uitofp nneg i32 [[N]] to float
13 ; CHECK-NEXT: call void @use.f32(float [[EXT_WIDE]])
14 ; CHECK-NEXT: br label [[EXIT]]
16 ; CHECK-NEXT: ret void
19 %cmp = icmp sgt i32 %n, -1
20 br i1 %cmp, label %bb, label %exit
23 %ext.wide = sitofp i32 %n to float
24 call void @use.f32(float %ext.wide)
32 define void @test2_fail(i32 %n) {
33 ; CHECK-LABEL: @test2_fail(
35 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[N:%.*]], -2
36 ; CHECK-NEXT: br i1 [[CMP]], label [[BB:%.*]], label [[EXIT:%.*]]
38 ; CHECK-NEXT: [[EXT_WIDE:%.*]] = sitofp i32 [[N]] to float
39 ; CHECK-NEXT: call void @use.f32(float [[EXT_WIDE]])
40 ; CHECK-NEXT: br label [[EXIT]]
42 ; CHECK-NEXT: ret void
45 %cmp = icmp sgt i32 %n, -2
46 br i1 %cmp, label %bb, label %exit
49 %ext.wide = sitofp i32 %n to float
50 call void @use.f32(float %ext.wide)
57 define float @may_including_undef(i1 %c.1, i1 %c.2) {
58 ; CHECK-LABEL: @may_including_undef(
59 ; CHECK-NEXT: br i1 [[C_1:%.*]], label [[TRUE_1:%.*]], label [[FALSE:%.*]]
61 ; CHECK-NEXT: br i1 [[C_2:%.*]], label [[TRUE_2:%.*]], label [[EXIT:%.*]]
63 ; CHECK-NEXT: br label [[EXIT]]
65 ; CHECK-NEXT: br label [[EXIT]]
67 ; CHECK-NEXT: [[P:%.*]] = phi i32 [ 0, [[TRUE_1]] ], [ 1, [[TRUE_2]] ], [ undef, [[FALSE]] ]
68 ; CHECK-NEXT: [[EXT:%.*]] = sitofp i32 [[P]] to float
69 ; CHECK-NEXT: ret float [[EXT]]
71 br i1 %c.1, label %true.1, label %false
74 br i1 %c.2, label %true.2, label %exit
83 %p = phi i32 [ 0, %true.1 ], [ 1, %true.2], [ undef, %false ]
84 %ext = sitofp i32 %p to float
88 define double @test_infer_at_use(i32 noundef %n) {
89 ; CHECK-LABEL: @test_infer_at_use(
90 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[N:%.*]], -1
91 ; CHECK-NEXT: [[EXT:%.*]] = uitofp nneg i32 [[N]] to double
92 ; CHECK-NEXT: [[SELECT:%.*]] = select i1 [[CMP]], double [[EXT]], double 0.000000e+00
93 ; CHECK-NEXT: ret double [[SELECT]]
95 %cmp = icmp sgt i32 %n, -1
96 %ext = sitofp i32 %n to double
97 %select = select i1 %cmp, double %ext, double 0.0