Index: llvm/test/CodeGen/PowerPC/use-cr-result-of-dom-icmp-st.ll =================================================================== --- llvm/test/CodeGen/PowerPC/use-cr-result-of-dom-icmp-st.ll +++ llvm/test/CodeGen/PowerPC/use-cr-result-of-dom-icmp-st.ll @@ -574,3 +574,121 @@ %retval.0 = sext i32 %retval.0.in to i64 ret i64 %retval.0 } + +; Please note the following functions are not generated from c code but +; modified from tests above manually. However, the naming convention of +; function name is the same. + +define i64 @ll_a_op_b_c(i64 %a, i64 %b, i64 %c) { +; PPC64LE-LABEL: ll_a_op_b_c: +; PPC64LE: # %bb.0: # %entry +; PPC64LE-NEXT: sld 6, 3, 4 +; PPC64LE-NEXT: cmpd 6, 5 +; PPC64LE-NEXT: ble 0, .LBB20_2 +; PPC64LE-NEXT: # %bb.1: # %return +; PPC64LE-NEXT: mr 3, 4 +; PPC64LE-NEXT: blr +; PPC64LE-NEXT: .LBB20_2: # %if.end +; PPC64LE-NEXT: cmpld 6, 5 +; PPC64LE-NEXT: li 5, 1 +; PPC64LE-NEXT: isel 4, 4, 5, 2 +; PPC64LE-NEXT: mulld 3, 4, 3 +; PPC64LE-NEXT: blr +entry: + %shl = shl i64 %a, %b + %cmp = icmp sgt i64 %shl, %c + br i1 %cmp, label %return, label %if.end + +if.end: ; preds = %entry + %cmp2 = icmp eq i64 %shl, %c + %mul = select i1 %cmp2, i64 %b, i64 1 + %spec.select = mul nsw i64 %mul, %a + ret i64 %spec.select + +return: ; preds = %entry + ret i64 %b +} + +define i64 @ll_a_c(i64 %a, i64 %b, i64 %c) { +; PPC64LE-LABEL: ll_a_c: +; PPC64LE: # %bb.0: # %entry +; PPC64LE-NEXT: cmpd 3, 5 +; PPC64LE-NEXT: ble 0, .LBB21_2 +; PPC64LE-NEXT: # %bb.1: # %return +; PPC64LE-NEXT: mr 3, 4 +; PPC64LE-NEXT: blr +; PPC64LE-NEXT: .LBB21_2: # %if.end +; PPC64LE-NEXT: cmpld 3, 5 +; PPC64LE-NEXT: li 5, 1 +; PPC64LE-NEXT: isel 4, 4, 5, 2 +; PPC64LE-NEXT: mulld 3, 4, 3 +; PPC64LE-NEXT: blr +entry: + %cmp = icmp sgt i64 %a, %c + br i1 %cmp, label %return, label %if.end + +if.end: ; preds = %entry + %cmp1 = icmp eq i64 %a, %c + %mul = select i1 %cmp1, i64 %b, i64 1 + %spec.select = mul nsw i64 %mul, %a + ret i64 %spec.select + +return: ; preds = %entry + ret i64 %b +} + +define i64 @i_a_op_b_c(i32 signext %a, i32 signext %b, i32 signext %c) { +; PPC64LE-LABEL: i_a_op_b_c: +; PPC64LE: # %bb.0: # %entry +; PPC64LE-NEXT: slw 7, 3, 4 +; PPC64LE-NEXT: li 6, 1 +; PPC64LE-NEXT: cmplw 7, 5 +; PPC64LE-NEXT: isel 6, 4, 6, 2 +; PPC64LE-NEXT: cmpw 0, 7, 5 +; PPC64LE-NEXT: mullw 3, 6, 3 +; PPC64LE-NEXT: isel 3, 4, 3, 1 +; PPC64LE-NEXT: extsw 3, 3 +; PPC64LE-NEXT: blr +entry: + %shl = shl i32 %a, %b + %cmp = icmp sgt i32 %shl, %c + br i1 %cmp, label %return, label %if.end + +if.end: ; preds = %entry + %cmp2 = icmp eq i32 %shl, %c + %mul = select i1 %cmp2, i32 %b, i32 1 + %spec.select = mul nsw i32 %mul, %a + br label %return + +return: ; preds = %if.end, %entry + %retval.0.in = phi i32 [ %b, %entry ], [ %spec.select, %if.end ] + %retval.0 = sext i32 %retval.0.in to i64 + ret i64 %retval.0 +} + +define i64 @i_a_c(i32 signext %a, i32 signext %b, i32 signext %c) { +; PPC64LE-LABEL: i_a_c: +; PPC64LE: # %bb.0: # %entry +; PPC64LE-NEXT: li 6, 1 +; PPC64LE-NEXT: cmplw 3, 5 +; PPC64LE-NEXT: isel 6, 4, 6, 2 +; PPC64LE-NEXT: cmpw 0, 3, 5 +; PPC64LE-NEXT: mullw 6, 6, 3 +; PPC64LE-NEXT: isel 3, 4, 6, 1 +; PPC64LE-NEXT: extsw 3, 3 +; PPC64LE-NEXT: blr +entry: + %cmp = icmp sgt i32 %a, %c + br i1 %cmp, label %return, label %if.end + +if.end: ; preds = %entry + %cmp1 = icmp eq i32 %a, %c + %mul = select i1 %cmp1, i32 %b, i32 1 + %spec.select = mul nsw i32 %mul, %a + br label %return + +return: ; preds = %if.end, %entry + %retval.0.in = phi i32 [ %b, %entry ], [ %spec.select, %if.end ] + %retval.0 = sext i32 %retval.0.in to i64 + ret i64 %retval.0 +}