diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp index d25eec1a947f..b12063592475 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp @@ -1148,9 +1148,9 @@ Value *InstCombiner::FoldAndOfFCmps(FCmpInst *LHS, FCmpInst *RHS) { if (Op0CC == FCmpInst::FCMP_FALSE || Op1CC == FCmpInst::FCMP_FALSE) return ConstantInt::get(CmpInst::makeCmpResultType(LHS->getType()), 0); if (Op0CC == FCmpInst::FCMP_TRUE) - return RHS; + return Builder->CreateFCmp(Op1CC, Op0LHS, Op0RHS); if (Op1CC == FCmpInst::FCMP_TRUE) - return LHS; + return Builder->CreateFCmp(Op0CC, Op0LHS, Op0RHS); bool Op0Ordered; bool Op1Ordered; @@ -1168,9 +1168,9 @@ Value *InstCombiner::FoldAndOfFCmps(FCmpInst *LHS, FCmpInst *RHS) { // uno && ueq -> uno && (uno || eq) -> uno // ord && olt -> ord && (ord && lt) -> olt if (!Op0Ordered && (Op0Ordered == Op1Ordered)) - return LHS; + return Builder->CreateFCmp(Op0CC, Op0LHS, Op0RHS); if (Op0Ordered && (Op0Ordered == Op1Ordered)) - return RHS; + return Builder->CreateFCmp(Op1CC, Op0LHS, Op0RHS); // uno && oeq -> uno && (ord && eq) -> false if (!Op0Ordered) @@ -2036,9 +2036,9 @@ Value *InstCombiner::FoldOrOfFCmps(FCmpInst *LHS, FCmpInst *RHS) { if (Op0CC == FCmpInst::FCMP_TRUE || Op1CC == FCmpInst::FCMP_TRUE) return ConstantInt::get(CmpInst::makeCmpResultType(LHS->getType()), 1); if (Op0CC == FCmpInst::FCMP_FALSE) - return RHS; + return Builder->CreateFCmp(Op1CC, Op0LHS, Op0RHS); if (Op1CC == FCmpInst::FCMP_FALSE) - return LHS; + return Builder->CreateFCmp(Op0CC, Op0LHS, Op0RHS); bool Op0Ordered; bool Op1Ordered; unsigned Op0Pred = getFCmpCode(Op0CC, Op0Ordered); diff --git a/llvm/test/Transforms/InstCombine/and-fcmp.ll b/llvm/test/Transforms/InstCombine/and-fcmp.ll index 31a71c317073..e6574461f685 100644 --- a/llvm/test/Transforms/InstCombine/and-fcmp.ll +++ b/llvm/test/Transforms/InstCombine/and-fcmp.ll @@ -371,8 +371,8 @@ define i1 @auto_gen_28(double %a, double %b) { define i1 @auto_gen_29(double %a, double %b) { ; CHECK-LABEL: @auto_gen_29( -; CHECK-NEXT: [[CMP1:%.*]] = fcmp oeq double %a, %b -; CHECK-NEXT: ret i1 [[CMP1]] +; CHECK-NEXT: [[TMP1:%.*]] = fcmp oeq double %a, %b +; CHECK-NEXT: ret i1 [[TMP1]] ; %cmp = fcmp ord double %a, %b %cmp1 = fcmp oeq double %a, %b @@ -382,8 +382,8 @@ define i1 @auto_gen_29(double %a, double %b) { define i1 @auto_gen_30(double %a, double %b) { ; CHECK-LABEL: @auto_gen_30( -; CHECK-NEXT: [[CMP1:%.*]] = fcmp ogt double %a, %b -; CHECK-NEXT: ret i1 [[CMP1]] +; CHECK-NEXT: [[TMP1:%.*]] = fcmp ogt double %a, %b +; CHECK-NEXT: ret i1 [[TMP1]] ; %cmp = fcmp ord double %a, %b %cmp1 = fcmp ogt double %a, %b @@ -393,8 +393,8 @@ define i1 @auto_gen_30(double %a, double %b) { define i1 @auto_gen_31(double %a, double %b) { ; CHECK-LABEL: @auto_gen_31( -; CHECK-NEXT: [[CMP1:%.*]] = fcmp oge double %a, %b -; CHECK-NEXT: ret i1 [[CMP1]] +; CHECK-NEXT: [[TMP1:%.*]] = fcmp oge double %a, %b +; CHECK-NEXT: ret i1 [[TMP1]] ; %cmp = fcmp ord double %a, %b %cmp1 = fcmp oge double %a, %b @@ -404,8 +404,8 @@ define i1 @auto_gen_31(double %a, double %b) { define i1 @auto_gen_32(double %a, double %b) { ; CHECK-LABEL: @auto_gen_32( -; CHECK-NEXT: [[CMP1:%.*]] = fcmp olt double %a, %b -; CHECK-NEXT: ret i1 [[CMP1]] +; CHECK-NEXT: [[TMP1:%.*]] = fcmp olt double %a, %b +; CHECK-NEXT: ret i1 [[TMP1]] ; %cmp = fcmp ord double %a, %b %cmp1 = fcmp olt double %a, %b @@ -415,8 +415,8 @@ define i1 @auto_gen_32(double %a, double %b) { define i1 @auto_gen_33(double %a, double %b) { ; CHECK-LABEL: @auto_gen_33( -; CHECK-NEXT: [[CMP1:%.*]] = fcmp ole double %a, %b -; CHECK-NEXT: ret i1 [[CMP1]] +; CHECK-NEXT: [[TMP1:%.*]] = fcmp ole double %a, %b +; CHECK-NEXT: ret i1 [[TMP1]] ; %cmp = fcmp ord double %a, %b %cmp1 = fcmp ole double %a, %b @@ -426,8 +426,8 @@ define i1 @auto_gen_33(double %a, double %b) { define i1 @auto_gen_34(double %a, double %b) { ; CHECK-LABEL: @auto_gen_34( -; CHECK-NEXT: [[CMP1:%.*]] = fcmp one double %a, %b -; CHECK-NEXT: ret i1 [[CMP1]] +; CHECK-NEXT: [[TMP1:%.*]] = fcmp one double %a, %b +; CHECK-NEXT: ret i1 [[TMP1]] ; %cmp = fcmp ord double %a, %b %cmp1 = fcmp one double %a, %b @@ -1385,8 +1385,8 @@ define i1 @auto_gen_112(double %a, double %b) { define i1 @auto_gen_113(double %a, double %b) { ; CHECK-LABEL: @auto_gen_113( -; CHECK-NEXT: [[CMP:%.*]] = fcmp uno double %a, %b -; CHECK-NEXT: ret i1 [[CMP]] +; CHECK-NEXT: [[TMP1:%.*]] = fcmp uno double %a, %b +; CHECK-NEXT: ret i1 [[TMP1]] ; %cmp = fcmp uno double %a, %b %cmp1 = fcmp ueq double %a, %b @@ -1396,8 +1396,8 @@ define i1 @auto_gen_113(double %a, double %b) { define i1 @auto_gen_114(double %a, double %b) { ; CHECK-LABEL: @auto_gen_114( -; CHECK-NEXT: [[CMP:%.*]] = fcmp uno double %a, %b -; CHECK-NEXT: ret i1 [[CMP]] +; CHECK-NEXT: [[TMP1:%.*]] = fcmp uno double %a, %b +; CHECK-NEXT: ret i1 [[TMP1]] ; %cmp = fcmp uno double %a, %b %cmp1 = fcmp ugt double %a, %b @@ -1407,8 +1407,8 @@ define i1 @auto_gen_114(double %a, double %b) { define i1 @auto_gen_115(double %a, double %b) { ; CHECK-LABEL: @auto_gen_115( -; CHECK-NEXT: [[CMP:%.*]] = fcmp uno double %a, %b -; CHECK-NEXT: ret i1 [[CMP]] +; CHECK-NEXT: [[TMP1:%.*]] = fcmp uno double %a, %b +; CHECK-NEXT: ret i1 [[TMP1]] ; %cmp = fcmp uno double %a, %b %cmp1 = fcmp uge double %a, %b @@ -1418,8 +1418,8 @@ define i1 @auto_gen_115(double %a, double %b) { define i1 @auto_gen_116(double %a, double %b) { ; CHECK-LABEL: @auto_gen_116( -; CHECK-NEXT: [[CMP:%.*]] = fcmp uno double %a, %b -; CHECK-NEXT: ret i1 [[CMP]] +; CHECK-NEXT: [[TMP1:%.*]] = fcmp uno double %a, %b +; CHECK-NEXT: ret i1 [[TMP1]] ; %cmp = fcmp uno double %a, %b %cmp1 = fcmp ult double %a, %b @@ -1429,8 +1429,8 @@ define i1 @auto_gen_116(double %a, double %b) { define i1 @auto_gen_117(double %a, double %b) { ; CHECK-LABEL: @auto_gen_117( -; CHECK-NEXT: [[CMP:%.*]] = fcmp uno double %a, %b -; CHECK-NEXT: ret i1 [[CMP]] +; CHECK-NEXT: [[TMP1:%.*]] = fcmp uno double %a, %b +; CHECK-NEXT: ret i1 [[TMP1]] ; %cmp = fcmp uno double %a, %b %cmp1 = fcmp ule double %a, %b @@ -1440,8 +1440,8 @@ define i1 @auto_gen_117(double %a, double %b) { define i1 @auto_gen_118(double %a, double %b) { ; CHECK-LABEL: @auto_gen_118( -; CHECK-NEXT: [[CMP:%.*]] = fcmp uno double %a, %b -; CHECK-NEXT: ret i1 [[CMP]] +; CHECK-NEXT: [[TMP1:%.*]] = fcmp uno double %a, %b +; CHECK-NEXT: ret i1 [[TMP1]] ; %cmp = fcmp uno double %a, %b %cmp1 = fcmp une double %a, %b