[polly] r218044 - Allow the IslExprBuilder to compare pointers
Johannes Doerfert
doerfert at cs.uni-saarland.de
Thu Sep 18 04:14:07 PDT 2014
Author: jdoerfert
Date: Thu Sep 18 06:14:07 2014
New Revision: 218044
URL: http://llvm.org/viewvc/llvm-project?rev=218044&view=rev
Log:
Allow the IslExprBuilder to compare pointers
Modified:
polly/trunk/lib/CodeGen/IslExprBuilder.cpp
Modified: polly/trunk/lib/CodeGen/IslExprBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/IslExprBuilder.cpp?rev=218044&r1=218043&r2=218044&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/IslExprBuilder.cpp (original)
+++ polly/trunk/lib/CodeGen/IslExprBuilder.cpp Thu Sep 18 06:14:07 2014
@@ -264,35 +264,38 @@ Value *IslExprBuilder::createOpICmp(__is
LHS = create(isl_ast_expr_get_op_arg(Expr, 0));
RHS = create(isl_ast_expr_get_op_arg(Expr, 1));
- Type *MaxType = LHS->getType();
- MaxType = getWidestType(MaxType, RHS->getType());
+ bool IsPtrType = LHS->getType()->isPointerTy();
+ assert((!IsPtrType || RHS->getType()->isPointerTy()) &&
+ "Both ICmp operators should be pointer types or none of them");
- if (MaxType != RHS->getType())
- RHS = Builder.CreateSExt(RHS, MaxType);
+ if (!IsPtrType) {
+ Type *MaxType = LHS->getType();
+ MaxType = getWidestType(MaxType, RHS->getType());
- if (MaxType != LHS->getType())
- LHS = Builder.CreateSExt(LHS, MaxType);
+ if (MaxType != RHS->getType())
+ RHS = Builder.CreateSExt(RHS, MaxType);
- switch (isl_ast_expr_get_op_type(Expr)) {
- default:
- llvm_unreachable("Unsupported ICmp isl ast expression");
- case isl_ast_op_eq:
- Res = Builder.CreateICmpEQ(LHS, RHS);
- break;
- case isl_ast_op_le:
- Res = Builder.CreateICmpSLE(LHS, RHS);
- break;
- case isl_ast_op_lt:
- Res = Builder.CreateICmpSLT(LHS, RHS);
- break;
- case isl_ast_op_ge:
- Res = Builder.CreateICmpSGE(LHS, RHS);
- break;
- case isl_ast_op_gt:
- Res = Builder.CreateICmpSGT(LHS, RHS);
- break;
+ if (MaxType != LHS->getType())
+ LHS = Builder.CreateSExt(LHS, MaxType);
}
+ isl_ast_op_type OpType = isl_ast_expr_get_op_type(Expr);
+ assert(OpType >= isl_ast_op_eq && OpType <= isl_ast_op_gt &&
+ "Unsupported ICmp isl ast expression");
+ assert(isl_ast_op_eq + 4 == isl_ast_op_gt &&
+ "Isl ast op type interface changed");
+
+ CmpInst::Predicate Predicates[5][2] = {
+ {CmpInst::ICMP_EQ, CmpInst::ICMP_EQ},
+ {CmpInst::ICMP_SLE, CmpInst::ICMP_ULE},
+ {CmpInst::ICMP_SLT, CmpInst::ICMP_ULT},
+ {CmpInst::ICMP_SGE, CmpInst::ICMP_UGE},
+ {CmpInst::ICMP_SGT, CmpInst::ICMP_UGT},
+ };
+
+ Res = Builder.CreateICmp(Predicates[OpType - isl_ast_op_eq][IsPtrType], LHS,
+ RHS);
+
isl_ast_expr_free(Expr);
return Res;
}
More information about the llvm-commits
mailing list