diff options
author | Manuel Freiberger <manuel.freiberger@gmail.com> | 2019-12-22 10:01:35 -0800 |
---|---|---|
committer | A. Unique TensorFlower <gardener@tensorflow.org> | 2019-12-22 10:02:13 -0800 |
commit | 22954a0e408afde1d8686dffb3a3dcab107a2cd3 (patch) | |
tree | d206709d143fb15efd807a2c601035668fcae7b2 /mlir/lib/Transforms/Utils/LoopUtils.cpp | |
parent | dcc14f08656a82aadd326aeca54b95b5b866fc86 (diff) | |
download | bcm5719-llvm-22954a0e408afde1d8686dffb3a3dcab107a2cd3.tar.gz bcm5719-llvm-22954a0e408afde1d8686dffb3a3dcab107a2cd3.zip |
Add integer bit-shift operations to the standard dialect.
Rename the 'shlis' operation in the standard dialect to 'shift_left'. Add tests
for this operation (these have been missing so far) and add a lowering to the
'shl' operation in the LLVM dialect.
Add also 'shift_right_signed' (lowered to LLVM's 'ashr') and 'shift_right_unsigned'
(lowered to 'lshr').
The original plan was to name these operations 'shift.left', 'shift.right.signed'
and 'shift.right.unsigned'. This works if the operations are prefixed with 'std.'
in MLIR assembly. Unfortunately during import the short form is ambigous with
operations from a hypothetical 'shift' dialect. The best solution seems to omit
dots in standard operations for now.
Closes tensorflow/mlir#226
PiperOrigin-RevId: 286803388
Diffstat (limited to 'mlir/lib/Transforms/Utils/LoopUtils.cpp')
-rw-r--r-- | mlir/lib/Transforms/Utils/LoopUtils.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/mlir/lib/Transforms/Utils/LoopUtils.cpp b/mlir/lib/Transforms/Utils/LoopUtils.cpp index 419df8d2705..3691aee4870 100644 --- a/mlir/lib/Transforms/Utils/LoopUtils.cpp +++ b/mlir/lib/Transforms/Utils/LoopUtils.cpp @@ -850,7 +850,7 @@ static Value *ceilDivPositive(OpBuilder &builder, Location loc, Value *dividend, Value *divisorMinusOneCst = builder.create<ConstantIndexOp>(loc, divisor - 1); Value *divisorCst = builder.create<ConstantIndexOp>(loc, divisor); Value *sum = builder.create<AddIOp>(loc, dividend, divisorMinusOneCst); - return builder.create<DivISOp>(loc, sum, divisorCst); + return builder.create<SignedDivIOp>(loc, sum, divisorCst); } // Build the IR that performs ceil division of a positive value by another @@ -864,7 +864,7 @@ static Value *ceilDivPositive(OpBuilder &builder, Location loc, Value *dividend, Value *cstOne = builder.create<ConstantIndexOp>(loc, 1); Value *divisorMinusOne = builder.create<SubIOp>(loc, divisor, cstOne); Value *sum = builder.create<AddIOp>(loc, dividend, divisorMinusOne); - return builder.create<DivISOp>(loc, sum, divisor); + return builder.create<SignedDivIOp>(loc, sum, divisor); } // Hoist the ops within `outer` that appear before `inner`. @@ -1084,12 +1084,12 @@ void mlir::coalesceLoops(MutableArrayRef<loop::ForOp> loops) { for (unsigned i = 0, e = loops.size(); i < e; ++i) { unsigned idx = loops.size() - i - 1; if (i != 0) - previous = - builder.create<DivISOp>(loc, previous, loops[idx + 1].upperBound()); + previous = builder.create<SignedDivIOp>(loc, previous, + loops[idx + 1].upperBound()); Value *iv = (i == e - 1) ? previous - : builder.create<RemISOp>(loc, previous, - loops[idx].upperBound()); + : builder.create<SignedRemIOp>( + loc, previous, loops[idx].upperBound()); replaceAllUsesInRegionWith(loops[idx].getInductionVar(), iv, loops.back().region()); } |