[llvm-commits] [dragonegg] r131195 - /dragonegg/trunk/src/Convert.cpp
Duncan Sands
baldrick at free.fr
Wed May 11 12:40:30 PDT 2011
Author: baldrick
Date: Wed May 11 14:40:30 2011
New Revision: 131195
URL: http://llvm.org/viewvc/llvm-project?rev=131195&view=rev
Log:
Simplify handling of MAX_EXPR and MIN_EXPR: modern GCC is much more careful
about types of operands and no longer needs all this heavy converting. Also,
ensure vectors of float are handled, partially fixing PR9717.
Modified:
dragonegg/trunk/src/Convert.cpp
Modified: dragonegg/trunk/src/Convert.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Convert.cpp?rev=131195&r1=131194&r2=131195&view=diff
==============================================================================
--- dragonegg/trunk/src/Convert.cpp (original)
+++ dragonegg/trunk/src/Convert.cpp Wed May 11 14:40:30 2011
@@ -6445,25 +6445,12 @@
Value *TreeToLLVM::EmitReg_MinMaxExpr(tree type, tree op0, tree op1,
unsigned UIPred, unsigned SIPred,
unsigned FPPred, bool isMax) {
- Value *LHS = EmitRegister(op0);
- Value *RHS = EmitRegister(op1);
-
const Type *Ty = getRegType(type);
-
- // The LHS, RHS and Ty could be integer, floating or pointer typed. We need
- // to convert the LHS and RHS into the destination type before doing the
- // comparison. Use CastInst::getCastOpcode to get this right.
- bool TyIsSigned = !TYPE_UNSIGNED(type);
- bool LHSIsSigned = !TYPE_UNSIGNED(TREE_TYPE(op0));
- bool RHSIsSigned = !TYPE_UNSIGNED(TREE_TYPE(op1));
- Instruction::CastOps opcode =
- CastInst::getCastOpcode(LHS, LHSIsSigned, Ty, TyIsSigned);
- LHS = Builder.CreateCast(opcode, LHS, Ty);
- opcode = CastInst::getCastOpcode(RHS, RHSIsSigned, Ty, TyIsSigned);
- RHS = Builder.CreateCast(opcode, RHS, Ty);
+ Value *LHS = UselesslyTypeConvert(EmitRegister(op0), Ty);
+ Value *RHS = UselesslyTypeConvert(EmitRegister(op1), Ty);
Value *Compare;
- if (LHS->getType()->isFloatingPointTy())
+ if (FLOAT_TYPE_P(type))
Compare = Builder.CreateFCmp(FCmpInst::Predicate(FPPred), LHS, RHS);
else if (TYPE_UNSIGNED(type))
Compare = Builder.CreateICmp(ICmpInst::Predicate(UIPred), LHS, RHS);
More information about the llvm-commits
mailing list