Fix combine of uno && ord -> false so that the ordering of the fcmps doesn't

matter.
rdar://11579835


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158084 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chad Rosier 2012-06-06 17:22:40 +00:00
parent 461e7eaa6f
commit 8b421c8eb2
2 changed files with 13 additions and 1 deletions

View File

@ -986,6 +986,9 @@ Value *InstCombiner::FoldAndOfFCmps(FCmpInst *LHS, FCmpInst *RHS) {
bool Op1Ordered;
unsigned Op0Pred = getFCmpCode(Op0CC, Op0Ordered);
unsigned Op1Pred = getFCmpCode(Op1CC, Op1Ordered);
// uno && ord -> false
if (Op0Pred == 0 && Op1Pred == 0 && Op0Ordered != Op1Ordered)
return ConstantInt::get(CmpInst::makeCmpResultType(LHS->getType()), 0);
if (Op1Pred == 0) {
std::swap(LHS, RHS);
std::swap(Op0Pred, Op1Pred);
@ -998,7 +1001,6 @@ Value *InstCombiner::FoldAndOfFCmps(FCmpInst *LHS, FCmpInst *RHS) {
return RHS;
// uno && oeq -> uno && (ord && eq) -> false
// uno && ord -> false
if (!Op0Ordered)
return ConstantInt::get(CmpInst::makeCmpResultType(LHS->getType()), 0);
// ord && ueq -> ord && (uno || eq) -> oeq

View File

@ -56,3 +56,13 @@ define zeroext i8 @t5(float %x, float %y) nounwind {
; CHECK: t5
; CHECK: ret i8 0
}
define zeroext i8 @t6(float %x, float %y) nounwind {
%a = fcmp uno float %x, %y
%b = fcmp ord float %x, %y
%c = and i1 %a, %b
%retval = zext i1 %c to i8
ret i8 %retval
; CHECK: t6
; CHECK: ret i8 0
}