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 = uitofp i32 %n to float
24 call void @use.f32(float %ext.wide)
31 define void @test2_fail(i32 %n) {
32 ; CHECK-LABEL: @test2_fail(
34 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[N:%.*]], -2
35 ; CHECK-NEXT: br i1 [[CMP]], label [[BB:%.*]], label [[EXIT:%.*]]
37 ; CHECK-NEXT: [[EXT_WIDE:%.*]] = uitofp i32 [[N]] to float
38 ; CHECK-NEXT: call void @use.f32(float [[EXT_WIDE]])
39 ; CHECK-NEXT: br label [[EXIT]]
41 ; CHECK-NEXT: ret void
44 %cmp = icmp sgt i32 %n, -2
45 br i1 %cmp, label %bb, label %exit
48 %ext.wide = uitofp i32 %n to float
49 call void @use.f32(float %ext.wide)
56 define float @may_including_undef(i1 %c.1, i1 %c.2) {
57 ; CHECK-LABEL: @may_including_undef(
58 ; CHECK-NEXT: br i1 [[C_1:%.*]], label [[TRUE_1:%.*]], label [[FALSE:%.*]]
60 ; CHECK-NEXT: br i1 [[C_2:%.*]], label [[TRUE_2:%.*]], label [[EXIT:%.*]]
62 ; CHECK-NEXT: br label [[EXIT]]
64 ; CHECK-NEXT: br label [[EXIT]]
66 ; CHECK-NEXT: [[P:%.*]] = phi i32 [ 0, [[TRUE_1]] ], [ 1, [[TRUE_2]] ], [ undef, [[FALSE]] ]
67 ; CHECK-NEXT: [[EXT:%.*]] = uitofp i32 [[P]] to float
68 ; CHECK-NEXT: ret float [[EXT]]
70 br i1 %c.1, label %true.1, label %false
73 br i1 %c.2, label %true.2, label %exit
82 %p = phi i32 [ 0, %true.1 ], [ 1, %true.2], [ undef, %false ]
83 %ext = uitofp i32 %p to float
87 define double @test_infer_at_use(i32 noundef %n) {
88 ; CHECK-LABEL: @test_infer_at_use(
89 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[N:%.*]], -1
90 ; CHECK-NEXT: [[EXT:%.*]] = uitofp nneg i32 [[N]] to double
91 ; CHECK-NEXT: [[SELECT:%.*]] = select i1 [[CMP]], double [[EXT]], double 0.000000e+00
92 ; CHECK-NEXT: ret double [[SELECT]]
94 %cmp = icmp sgt i32 %n, -1
95 %ext = uitofp i32 %n to double
96 %select = select i1 %cmp, double %ext, double 0.0