Subzero: Use setcc for most fcmp conditions, instead of control flow.
For C/C++ semantics, this applies to all the FP comparisons except == and != which require two comparisons due to ordered/unordered requirements. For == and !=, two comparisons and control flow are still used.
BUG= https://code.google.com/p/nativeclient/issues/detail?id=4095
TEST= crosstest/test_fcmp
R=jvoung@chromium.org
Review URL: https://codereview.chromium.org/1148023003
diff --git a/src/IceTargetLoweringX8632.cpp b/src/IceTargetLoweringX8632.cpp
index 478a6b6..0896c47 100644
--- a/src/IceTargetLoweringX8632.cpp
+++ b/src/IceTargetLoweringX8632.cpp
@@ -2702,14 +2702,15 @@
// FakeUse(a) /* only if C1 != Br_None */
// mov a, !<default> /* only if C1 != Br_None */
// label: /* only if C1 != Br_None */
+ //
+ // setcc lowering when C1 != Br_None && C2 == Br_None:
+ // ucomiss b, c /* but swap b,c order if SwapOperands==true */
+ // setcc a, C1
InstFcmp::FCond Condition = Inst->getCondition();
size_t Index = static_cast<size_t>(Condition);
assert(Index < TableFcmpSize);
- if (TableFcmp[Index].SwapScalarOperands) {
- Operand *Tmp = Src0;
- Src0 = Src1;
- Src1 = Tmp;
- }
+ if (TableFcmp[Index].SwapScalarOperands)
+ std::swap(Src0, Src1);
bool HasC1 = (TableFcmp[Index].C1 != CondX86::Br_None);
bool HasC2 = (TableFcmp[Index].C2 != CondX86::Br_None);
if (HasC1) {
@@ -2718,6 +2719,11 @@
Variable *T = nullptr;
_mov(T, Src0);
_ucomiss(T, Src1RM);
+ if (!HasC2) {
+ assert(TableFcmp[Index].Default);
+ _setcc(Dest, TableFcmp[Index].C1);
+ return;
+ }
}
Constant *Default = Ctx->getConstantInt32(TableFcmp[Index].Default);
_mov(Dest, Default);