Skip to content

Commit b17f3c6

Browse files
authored
[NFC][MLIR] Add {} for else when if body has {} (llvm#139422)
1 parent 6d11b17 commit b17f3c6

File tree

16 files changed

+34
-20
lines changed

16 files changed

+34
-20
lines changed

mlir/lib/Analysis/Presburger/IntegerRelation.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2398,8 +2398,9 @@ bool IntegerRelation::removeDuplicateConstraints() {
23982398
addEquality(getInequality(k));
23992399
removeInequality(k);
24002400
removeInequality(l);
2401-
} else
2401+
} else {
24022402
*this = getEmpty(getSpace());
2403+
}
24032404
break;
24042405
}
24052406

mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -896,8 +896,9 @@ class VectorReductionOpConversion
896896
} else if (kind == vector::CombiningKind::MAXNUMF) {
897897
result = createFPReductionComparisonOpLowering<LLVM::vector_reduce_fmax>(
898898
rewriter, loc, llvmType, operand, acc, fmf);
899-
} else
899+
} else {
900900
return failure();
901+
}
901902

902903
rewriter.replaceOp(reductionOp, result);
903904
return success();

mlir/lib/Dialect/Affine/Analysis/LoopAnalysis.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,9 @@ std::optional<uint64_t> mlir::affine::getConstantTripCount(AffineForOp forOp) {
233233
std::min(*tripCount, static_cast<uint64_t>(constExpr.getValue()));
234234
else
235235
tripCount = constExpr.getValue();
236-
} else
236+
} else {
237237
return std::nullopt;
238+
}
238239
}
239240
return tripCount;
240241
}

mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4327,8 +4327,9 @@ void ElementwiseOp::regionBuilder(ImplicitLocOpBuilder &b, Block &block,
43274327
result = helper.buildTernaryFn(kind.ternaryFn, block.getArgument(0),
43284328
block.getArgument(1), block.getArgument(2));
43294329

4330-
} else
4330+
} else {
43314331
assert(false && "found unhandled category in elemwise");
4332+
}
43324333

43334334
yields.push_back(result);
43344335
helper.yieldOutputs(yields);

mlir/lib/Dialect/Mesh/Interfaces/ShardingInterface.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,9 @@ checkOperandAffineExprRecursively(AffineExpr expr,
5757
} else if (rhs.getKind() == AffineExprKind::DimId &&
5858
lhs.getKind() == AffineExprKind::Constant) {
5959
dimExpr = rhs;
60-
} else
60+
} else {
6161
return failure();
62+
}
6263
unsigned position = cast<AffineDimExpr>(dimExpr).getPosition();
6364
if ((size_t)position >= seenIds.size() || seenIds[position])
6465
return failure();

mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -662,8 +662,9 @@ static ParseResult parseClauseWithRegionArgs(
662662
parser.parseInteger(mapIndicesVec.emplace_back()) ||
663663
parser.parseRSquare())
664664
return failure();
665-
} else
665+
} else {
666666
mapIndicesVec.push_back(-1);
667+
}
667668
}
668669

669670
return success();

mlir/lib/Dialect/SCF/TransformOps/SCFTransformOps.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,9 +594,10 @@ transform::LoopFuseSiblingOp::apply(transform::TransformRewriter &rewriter,
594594
} else if (isForallWithIdenticalConfiguration(target, source)) {
595595
fusedLoop = fuseIndependentSiblingForallLoops(
596596
cast<scf::ForallOp>(target), cast<scf::ForallOp>(source), rewriter);
597-
} else
597+
} else {
598598
return emitSilenceableFailure(target->getLoc())
599599
<< "operations cannot be fused";
600+
}
600601

601602
assert(fusedLoop && "failed to fuse operations");
602603

mlir/lib/Dialect/SCF/Transforms/LoopPipelining.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,8 +417,9 @@ scf::ForOp LoopPipelinerInternal::createKernelLoop(
417417
[maxStage - defStage->second];
418418
assert(valueVersion);
419419
newLoopArg.push_back(valueVersion);
420-
} else
420+
} else {
421421
newLoopArg.push_back(forOp.getInitArgs()[retVal.index()]);
422+
}
422423
}
423424
for (auto escape : crossStageValues) {
424425
LiverangeInfo &info = escape.second;

mlir/lib/Dialect/SCF/Transforms/ParallelLoopFusion.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,9 @@ static bool haveNoReadsAfterWriteExceptSameIndex(
124124
OperationEquivalence::Flags::IgnoreLocations)) {
125125
return WalkResult::interrupt();
126126
}
127-
} else
127+
} else {
128128
return WalkResult::interrupt();
129+
}
129130
}
130131
}
131132
return WalkResult::advance();

mlir/lib/Dialect/XeGPU/Transforms/XeGPUSubgroupDistribute.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,9 @@ void LayoutInfo::print(raw_ostream &os) const {
157157
laneLayout.print(os);
158158
os << ", lane_data: ";
159159
laneData.print(os);
160-
} else
160+
} else {
161161
os << "Not assigned.";
162+
}
162163
}
163164

164165
LayoutInfo LayoutInfo::meet(const LayoutInfo &lhs, const LayoutInfo &rhs) {

mlir/lib/ExecutionEngine/SyclRuntimeWrappers.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,9 @@ static sycl::device getDefaultDevice() {
6565
return syclDevice;
6666
}
6767
throw std::runtime_error("getDefaultDevice failed");
68-
} else
68+
} else {
6969
return syclDevice;
70+
}
7071
}
7172

7273
static sycl::context getDefaultContext() {

mlir/lib/Target/LLVM/NVVM/Target.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,9 +606,10 @@ NVPTXSerializer::compileToBinaryNVPTX(const std::string &ptxCode) {
606606
nvPTXCompilerGetErrorLog(compiler, log.data()));
607607
emitError(loc) << "NVPTX compiler invocation failed, error log: "
608608
<< log.data();
609-
} else
609+
} else {
610610
emitError(loc) << "NVPTX compiler invocation failed with error code: "
611611
<< status;
612+
}
612613
return std::nullopt;
613614
}
614615

mlir/lib/Target/LLVMIR/ModuleImport.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2680,8 +2680,9 @@ ModuleImport::convertParameterAttribute(llvm::AttributeSet llvmParamAttrs,
26802680
const llvm::ConstantRange &value = llvmAttr.getValueAsConstantRange();
26812681
mlirAttr = builder.getAttr<LLVM::ConstantRangeAttr>(value.getLower(),
26822682
value.getUpper());
2683-
} else
2683+
} else {
26842684
llvm_unreachable("unexpected parameter attribute kind");
2685+
}
26852686
paramAttrs.push_back(builder.getNamedAttr(mlirName, mlirAttr));
26862687
}
26872688

mlir/lib/Transforms/OpStats.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ void PrintOpStatsPass::runOnOperation() {
5151
// Compute the operation statistics for the currently visited operation.
5252
getOperation()->walk(
5353
[&](Operation *op) { ++opCount[op->getName().getStringRef()]; });
54-
if (printAsJSON) {
54+
if (printAsJSON)
5555
printSummaryInJSON();
56-
} else
56+
else
5757
printSummary();
5858
markAllAnalysesPreserved();
5959
}

mlir/test/Dialect/SCF/canonicalize.mlir

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ func.func @one_unused(%cond: i1) -> (index) {
149149
// CHECK: call @side_effect() : () -> ()
150150
// CHECK: [[C1:%.*]] = "test.value1"
151151
// CHECK: scf.yield [[C1]] : index
152-
// CHECK: } else
152+
// CHECK: } else {
153153
// CHECK: [[C3:%.*]] = "test.value3"
154154
// CHECK: scf.yield [[C3]] : index
155155
// CHECK: }
@@ -185,12 +185,12 @@ func.func @nested_unused(%cond1: i1, %cond2: i1) -> (index) {
185185
// CHECK: call @side_effect() : () -> ()
186186
// CHECK: [[C1:%.*]] = "test.value1"
187187
// CHECK: scf.yield [[C1]] : index
188-
// CHECK: } else
188+
// CHECK: } else {
189189
// CHECK: [[C3:%.*]] = "test.value3"
190190
// CHECK: scf.yield [[C3]] : index
191191
// CHECK: }
192192
// CHECK: scf.yield [[V1]] : index
193-
// CHECK: } else
193+
// CHECK: } else {
194194
// CHECK: [[C1_2:%.*]] = "test.value1_2"
195195
// CHECK: scf.yield [[C1_2]] : index
196196
// CHECK: }
@@ -215,7 +215,7 @@ func.func @all_unused(%cond: i1) {
215215
// CHECK-LABEL: func @all_unused
216216
// CHECK: scf.if %{{.*}} {
217217
// CHECK: call @side_effect() : () -> ()
218-
// CHECK: } else
218+
// CHECK: } else {
219219
// CHECK: call @side_effect() : () -> ()
220220
// CHECK: }
221221
// CHECK: return

mlir/test/lib/Dialect/Test/TestOpDefs.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -801,8 +801,9 @@ void TestReflectBoundsOp::inferResultRanges(
801801
unsigned bitwidth = intTy.getWidth();
802802
sIntTy = b.getIntegerType(bitwidth, /*isSigned=*/true);
803803
uIntTy = b.getIntegerType(bitwidth, /*isSigned=*/false);
804-
} else
804+
} else {
805805
sIntTy = uIntTy = type;
806+
}
806807

807808
setUminAttr(b.getIntegerAttr(uIntTy, range.umin()));
808809
setUmaxAttr(b.getIntegerAttr(uIntTy, range.umax()));

0 commit comments

Comments
 (0)