forked from OSchip/llvm-project
90 lines
3.2 KiB
LLVM
90 lines
3.2 KiB
LLVM
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
|
; RUN: opt < %s -passes=instcombine -S | FileCheck %s
|
|
|
|
define void @matching_phi(i64 %a, float* %b, i1 %cond) {
|
|
; CHECK-LABEL: @matching_phi(
|
|
; CHECK-NEXT: entry:
|
|
; CHECK-NEXT: [[ADD_INT:%.*]] = add i64 [[A:%.*]], 1
|
|
; CHECK-NEXT: [[ADD:%.*]] = inttoptr i64 [[ADD_INT]] to float*
|
|
; CHECK-NEXT: br i1 [[COND:%.*]], label [[BBB:%.*]], label [[A:%.*]]
|
|
; CHECK: A:
|
|
; CHECK-NEXT: [[ADDB:%.*]] = getelementptr inbounds float, float* [[B:%.*]], i64 2
|
|
; CHECK-NEXT: br label [[C:%.*]]
|
|
; CHECK: Bbb:
|
|
; CHECK-NEXT: store float 1.000000e+01, float* [[ADD]], align 4
|
|
; CHECK-NEXT: br label [[C]]
|
|
; CHECK: C:
|
|
; CHECK-NEXT: [[A_ADDR_03:%.*]] = phi float* [ [[ADDB]], [[A]] ], [ [[ADD]], [[BBB]] ]
|
|
; CHECK-NEXT: [[I1:%.*]] = load float, float* [[A_ADDR_03]], align 4
|
|
; CHECK-NEXT: [[MUL_I:%.*]] = fmul float [[I1]], 4.200000e+01
|
|
; CHECK-NEXT: store float [[MUL_I]], float* [[A_ADDR_03]], align 4
|
|
; CHECK-NEXT: ret void
|
|
;
|
|
entry:
|
|
%cmp1 = icmp eq i1 %cond, 0
|
|
%add.int = add i64 %a, 1
|
|
%add = inttoptr i64 %add.int to float *
|
|
|
|
%addb = getelementptr inbounds float, float* %b, i64 2
|
|
%addb.int = ptrtoint float* %addb to i64
|
|
br i1 %cmp1, label %A, label %Bbb
|
|
A:
|
|
br label %C
|
|
Bbb:
|
|
store float 1.0e+01, float* %add, align 4
|
|
br label %C
|
|
|
|
C:
|
|
%a.addr.03 = phi float* [ %addb, %A ], [ %add, %Bbb ]
|
|
%b.addr.02 = phi i64 [ %addb.int, %A ], [ %add.int, %Bbb ]
|
|
%i0 = inttoptr i64 %b.addr.02 to float*
|
|
%i1 = load float, float* %i0, align 4
|
|
%mul.i = fmul float %i1, 4.200000e+01
|
|
store float %mul.i, float* %a.addr.03, align 4
|
|
ret void
|
|
}
|
|
|
|
define void @no_matching_phi(i64 %a, float* %b, i1 %cond) {
|
|
; CHECK-LABEL: @no_matching_phi(
|
|
; CHECK-NEXT: entry:
|
|
; CHECK-NEXT: [[ADD_INT:%.*]] = add i64 [[A:%.*]], 1
|
|
; CHECK-NEXT: [[ADD:%.*]] = inttoptr i64 [[ADD_INT]] to float*
|
|
; CHECK-NEXT: [[ADDB:%.*]] = getelementptr inbounds float, float* [[B:%.*]], i64 2
|
|
; CHECK-NEXT: br i1 [[COND:%.*]], label [[B:%.*]], label [[A:%.*]]
|
|
; CHECK: A:
|
|
; CHECK-NEXT: br label [[C:%.*]]
|
|
; CHECK: B:
|
|
; CHECK-NEXT: store float 1.000000e+01, float* [[ADD]], align 4
|
|
; CHECK-NEXT: br label [[C]]
|
|
; CHECK: C:
|
|
; CHECK-NEXT: [[A_ADDR_03:%.*]] = phi float* [ [[ADDB]], [[A]] ], [ [[ADD]], [[B]] ]
|
|
; CHECK-NEXT: [[B_ADDR_02_PTR:%.*]] = phi float* [ [[ADD]], [[A]] ], [ [[ADDB]], [[B]] ]
|
|
; CHECK-NEXT: [[I1:%.*]] = load float, float* [[B_ADDR_02_PTR]], align 4
|
|
; CHECK-NEXT: [[MUL_I:%.*]] = fmul float [[I1]], 4.200000e+01
|
|
; CHECK-NEXT: store float [[MUL_I]], float* [[A_ADDR_03]], align 4
|
|
; CHECK-NEXT: ret void
|
|
;
|
|
entry:
|
|
%cmp1 = icmp eq i1 %cond, 0
|
|
%add.int = add i64 %a, 1
|
|
%add = inttoptr i64 %add.int to float *
|
|
|
|
%addb = getelementptr inbounds float, float* %b, i64 2
|
|
%addb.int = ptrtoint float* %addb to i64
|
|
br i1 %cmp1, label %A, label %B
|
|
A:
|
|
br label %C
|
|
B:
|
|
store float 1.0e+01, float* %add, align 4
|
|
br label %C
|
|
|
|
C:
|
|
%a.addr.03 = phi float* [ %addb, %A ], [ %add, %B ]
|
|
%b.addr.02 = phi i64 [ %addb.int, %B ], [ %add.int, %A ]
|
|
%i0 = inttoptr i64 %b.addr.02 to float*
|
|
%i1 = load float, float* %i0, align 4
|
|
%mul.i = fmul float %i1, 4.200000e+01
|
|
store float %mul.i, float* %a.addr.03, align 4
|
|
ret void
|
|
}
|