diff options
author | Chad Rosier <mcrosier@apple.com> | 2012-06-06 17:22:40 +0000 |
---|---|---|
committer | Chad Rosier <mcrosier@apple.com> | 2012-06-06 17:22:40 +0000 |
commit | faa389462835ab40ed8af86eb32c44abfcf4e48a (patch) | |
tree | 8059f6efe0ab01392ed5fcd1c51aecb46a0a8353 | |
parent | 112ac68d520e7d6eefc9b689831e9114fd4aeb7e (diff) | |
download | bcm5719-llvm-faa389462835ab40ed8af86eb32c44abfcf4e48a.tar.gz bcm5719-llvm-faa389462835ab40ed8af86eb32c44abfcf4e48a.zip |
Fix combine of uno && ord -> false so that the ordering of the fcmps doesn't
matter.
rdar://11579835
llvm-svn: 158084
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp | 4 | ||||
-rw-r--r-- | llvm/test/Transforms/InstCombine/and-fcmp.ll | 10 |
2 files changed, 13 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp index 0f10d7376c3..3bafc6661b0 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp @@ -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 diff --git a/llvm/test/Transforms/InstCombine/and-fcmp.ll b/llvm/test/Transforms/InstCombine/and-fcmp.ll index f6a226e3b58..282e88b53d0 100644 --- a/llvm/test/Transforms/InstCombine/and-fcmp.ll +++ b/llvm/test/Transforms/InstCombine/and-fcmp.ll @@ -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 +} |