Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions lib/polygeist/Passes/ForBreakToWhile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,20 @@ struct ForBreakLoweringPattern : public OpRewritePattern<ForOp> {
auto *beforeBlock = rewriter.createBlock(
&whileOp.getBefore(), whileOp.getBefore().begin(), lcvTypes, lcvLocs);
rewriter.setInsertionPointToStart(&whileOp.getBefore().front());
Value cmpOp = rewriter.create<arith::CmpIOp>(
whileOp.getLoc(), arith::CmpIPredicate::slt,
beforeBlock->getArgument(0), forOp.getUpperBound());
Value cmpOp;
if (matchPattern(forOp.getStep(), m_One())) {
cmpOp = rewriter.create<arith::AndIOp>(
whileOp.getLoc(),
rewriter.create<arith::CmpIOp>(
whileOp.getLoc(), arith::CmpIPredicate::ne,
beforeBlock->getArgument(0), forOp.getUpperBound()),
rewriter.create<arith::CmpIOp>(
whileOp.getLoc(), arith::CmpIPredicate::slt,
forOp.getLowerBound(), forOp.getUpperBound()));
} else
cmpOp = rewriter.create<arith::CmpIOp>(
whileOp.getLoc(), arith::CmpIPredicate::slt,
beforeBlock->getArgument(0), forOp.getUpperBound());
Value andOp = rewriter.create<arith::AndIOp>(
whileOp.getLoc(), cmpOp, whileOp.getBeforeArguments()[iterArgPos + 1]);
// TODO: consider not forwarding the condition variable.
Expand Down
10 changes: 5 additions & 5 deletions tools/cgeist/Lib/clang-mlir.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2512,27 +2512,27 @@ ValueCategory MLIRScanner::VisitBinaryOperator(clang::BinaryOperator *BO) {
LLVM::ICmpPredicate LPred;
switch (BO->getOpcode()) {
case clang::BinaryOperator::Opcode::BO_GT:
FPred = CmpFPredicate::UGT;
FPred = CmpFPredicate::OGT;
IPred = signedType ? CmpIPredicate::sgt : CmpIPredicate::ugt,
LPred = LLVM::ICmpPredicate::ugt;
break;
case clang::BinaryOperator::Opcode::BO_GE:
FPred = CmpFPredicate::UGE;
FPred = CmpFPredicate::OGE;
IPred = signedType ? CmpIPredicate::sge : CmpIPredicate::uge,
LPred = LLVM::ICmpPredicate::uge;
break;
case clang::BinaryOperator::Opcode::BO_LT:
FPred = CmpFPredicate::ULT;
FPred = CmpFPredicate::OLT;
IPred = signedType ? CmpIPredicate::slt : CmpIPredicate::ult,
LPred = LLVM::ICmpPredicate::ult;
break;
case clang::BinaryOperator::Opcode::BO_LE:
FPred = CmpFPredicate::ULE;
FPred = CmpFPredicate::OLE;
IPred = signedType ? CmpIPredicate::sle : CmpIPredicate::ule,
LPred = LLVM::ICmpPredicate::ule;
break;
case clang::BinaryOperator::Opcode::BO_EQ:
FPred = CmpFPredicate::UEQ;
FPred = CmpFPredicate::OEQ;
IPred = CmpIPredicate::eq;
LPred = LLVM::ICmpPredicate::eq;
break;
Expand Down