1; RUN: opt < %s -instcombine -S | FileCheck %s 2 3%"struct.std::complex" = type { { float, float } } 4@dd = external global %"struct.std::complex", align 4 5@dd2 = external global %"struct.std::complex", align 4 6 7define void @_Z3fooi(i32 signext %n) { 8entry: 9 br label %for.cond 10 11for.cond: 12 %ldd.sroa.0.0 = phi i32 [ 0, %entry ], [ %5, %for.body ] 13 %ldd.sroa.6.0 = phi i32 [ 0, %entry ], [ %7, %for.body ] 14 %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.body ] 15 %cmp = icmp slt i32 %i.0, %n 16 br i1 %cmp, label %for.body, label %for.end 17 18for.body: 19 %0 = load float, float* getelementptr inbounds (%"struct.std::complex", %"struct.std::complex"* @dd, i64 0, i32 0, i32 0), align 4 20 %1 = load float, float* getelementptr inbounds (%"struct.std::complex", %"struct.std::complex"* @dd, i64 0, i32 0, i32 1), align 4 21 %2 = load float, float* getelementptr inbounds (%"struct.std::complex", %"struct.std::complex"* @dd2, i64 0, i32 0, i32 0), align 4 22 %3 = load float, float* getelementptr inbounds (%"struct.std::complex", %"struct.std::complex"* @dd2, i64 0, i32 0, i32 1), align 4 23 %mul.i = fmul float %0, %2 24 %mul4.i = fmul float %1, %3 25 %sub.i = fsub float %mul.i, %mul4.i 26 %mul5.i = fmul float %1, %2 27 %mul6.i = fmul float %0, %3 28 %add.i4 = fadd float %mul5.i, %mul6.i 29 %4 = bitcast i32 %ldd.sroa.0.0 to float 30 %add.i = fadd float %sub.i, %4 31 %5 = bitcast float %add.i to i32 32 %6 = bitcast i32 %ldd.sroa.6.0 to float 33 %add4.i = fadd float %add.i4, %6 34 %7 = bitcast float %add4.i to i32 35 %inc = add nsw i32 %i.0, 1 36 br label %for.cond 37 38for.end: 39 store i32 %ldd.sroa.0.0, i32* bitcast (%"struct.std::complex"* @dd to i32*), align 4 40 store i32 %ldd.sroa.6.0, i32* bitcast (float* getelementptr inbounds (%"struct.std::complex", %"struct.std::complex"* @dd, i64 0, i32 0, i32 1) to i32*), align 4 41 ret void 42 43; CHECK: phi float 44; CHECK: store float 45; CHECK-NOT: bitcast 46} 47 48 49define void @multi_phi(i32 signext %n) { 50entry: 51 br label %for.cond 52 53for.cond: 54 %ldd.sroa.0.0 = phi i32 [ 0, %entry ], [ %9, %odd.bb ] 55 %i.0 = phi i32 [ 0, %entry ], [ %inc, %odd.bb ] 56 %cmp = icmp slt i32 %i.0, %n 57 br i1 %cmp, label %for.body, label %for.end 58 59for.body: 60 %0 = load float, float* getelementptr inbounds (%"struct.std::complex", %"struct.std::complex"* @dd, i64 0, i32 0, i32 0), align 4 61 %1 = load float, float* getelementptr inbounds (%"struct.std::complex", %"struct.std::complex"* @dd, i64 0, i32 0, i32 1), align 4 62 %2 = load float, float* getelementptr inbounds (%"struct.std::complex", %"struct.std::complex"* @dd2, i64 0, i32 0, i32 0), align 4 63 %3 = load float, float* getelementptr inbounds (%"struct.std::complex", %"struct.std::complex"* @dd2, i64 0, i32 0, i32 1), align 4 64 %mul.i = fmul float %0, %2 65 %mul4.i = fmul float %1, %3 66 %sub.i = fsub float %mul.i, %mul4.i 67 %4 = bitcast i32 %ldd.sroa.0.0 to float 68 %add.i = fadd float %sub.i, %4 69 %5 = bitcast float %add.i to i32 70 %inc = add nsw i32 %i.0, 1 71 %bit0 = and i32 %inc, 1 72 %even = icmp slt i32 %bit0, 1 73 br i1 %even, label %even.bb, label %odd.bb 74 75even.bb: 76 %6 = bitcast i32 %5 to float 77 %7 = fadd float %sub.i, %6 78 %8 = bitcast float %7 to i32 79 br label %odd.bb 80 81odd.bb: 82 %9 = phi i32 [ %5, %for.body ], [ %8, %even.bb ] 83 br label %for.cond 84 85for.end: 86 store i32 %ldd.sroa.0.0, i32* bitcast (%"struct.std::complex"* @dd to i32*), align 4 87 ret void 88 89; CHECK-LABEL: @multi_phi( 90; CHECK: phi float 91; CHECK: store float 92; CHECK-NOT: bitcast 93} 94