Lower llvm.isunordered(a, b) into a != a | b != b.
llvm-svn: 20382
diff --git a/llvm/lib/CodeGen/IntrinsicLowering.cpp b/llvm/lib/CodeGen/IntrinsicLowering.cpp
index 85e8ba5..0fe49ec 100644
--- a/llvm/lib/CodeGen/IntrinsicLowering.cpp
+++ b/llvm/lib/CodeGen/IntrinsicLowering.cpp
@@ -206,9 +206,14 @@
break;
}
case Intrinsic::isunordered: {
- static Function *isunorderedFCache = 0;
- ReplaceCallWith("isunordered", CI, CI->op_begin()+1, CI->op_end(),
- Type::BoolTy, isunorderedFCache);
+ Value *L = CI->getOperand(1);
+ Value *R = CI->getOperand(2);
+
+ Value *LIsNan = new SetCondInst(Instruction::SetNE, L, L, "LIsNan", CI);
+ Value *RIsNan = new SetCondInst(Instruction::SetNE, R, R, "RIsNan", CI);
+ CI->replaceAllUsesWith(
+ BinaryOperator::create(Instruction::Or, LIsNan, RIsNan,
+ "isunordered", CI));
break;
}
}