[Beignet] [PATCH] Refine the FCMP_ORD and FCMP_UNO.
Yang Rong
rong.r.yang at intel.com
Mon Mar 24 02:21:40 PDT 2014
If there is a constant between src0 and src1 of FCMP_ORD/FCMP_UNO, the constant
value must be ordered, otherwise, llvm will optimize the instruction to ture/false.
So discard this constant value, only compare the other src.
Signed-off-by: Yang Rong <rong.r.yang at intel.com>
---
backend/src/llvm/llvm_gen_backend.cpp | 22 +++++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
diff --git a/backend/src/llvm/llvm_gen_backend.cpp b/backend/src/llvm/llvm_gen_backend.cpp
index c459f25..2904037 100644
--- a/backend/src/llvm/llvm_gen_backend.cpp
+++ b/backend/src/llvm/llvm_gen_backend.cpp
@@ -1653,10 +1653,26 @@ namespace gbe
case ICmpInst::FCMP_OGE: ctx.GE(type, dst, src0, src1); break;
case ICmpInst::FCMP_OLT: ctx.LT(type, dst, src0, src1); break;
case ICmpInst::FCMP_OGT: ctx.GT(type, dst, src0, src1); break;
- case ICmpInst::FCMP_ORD: ctx.ORD(type, dst, src0, src1); break;
+ case ICmpInst::FCMP_ORD:
+ //If there is a constant between src0 and src1, this constant value
+ //must ordered, otherwise, llvm will optimize the instruction to ture.
+ //So discard this constant value, only compare the other src.
+ if(isa<ConstantFP>(I.getOperand(0)))
+ ctx.EQ(type, dst, src1, src1);
+ else if(isa<ConstantFP>(I.getOperand(1)))
+ ctx.EQ(type, dst, src0, src0);
+ else
+ ctx.ORD(type, dst, src0, src1);
+ break;
case ICmpInst::FCMP_UNO:
- ctx.ORD(type, tmp, src0, src1);
- ctx.XOR(insnType, dst, tmp, getRegister(cv)); //TODO: Use NOT directly
+ if(isa<ConstantFP>(I.getOperand(0)))
+ ctx.NE(type, dst, src1, src1);
+ else if(isa<ConstantFP>(I.getOperand(1)))
+ ctx.NE(type, dst, src0, src0);
+ else {
+ ctx.ORD(type, tmp, src0, src1);
+ ctx.XOR(insnType, dst, tmp, getRegister(cv)); //TODO: Use NOT directly
+ }
break;
case ICmpInst::FCMP_UEQ:
ctx.NE(type, tmp, src0, src1);
--
1.8.3.2
More information about the Beignet
mailing list