Skip to content

Commit 549699e

Browse files
committed
Address feedback on comments
1 parent b01dfe5 commit 549699e

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

clang/include/clang/CIR/Dialect/IR/CIROps.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1477,6 +1477,10 @@ def TernaryOp : CIR_Op<"ternary",
14771477
since each region is one block sized and the `cir.yield` closing the block
14781478
scope should have one argument.
14791479

1480+
`cir.ternary` also represents the GNU binary conditional operator ?: which
1481+
reuses the parent operation for both the condition and the true branch to
1482+
evaluate it only once.
1483+
14801484
Example:
14811485

14821486
```mlir

clang/lib/CIR/Dialect/IR/CIRDialect.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,7 +1191,7 @@ LogicalResult cir::BinOp::verify() {
11911191
// TernaryOp
11921192
//===----------------------------------------------------------------------===//
11931193

1194-
/// Given the region at `index`, or the parent operation if `index` is None,
1194+
/// Given the region at `point`, or the parent operation if `point` is None,
11951195
/// return the successor regions. These are the regions that may be selected
11961196
/// during the flow of control. `operands` is a set of optional attributes that
11971197
/// correspond to a constant value for each operand, or null if that operand is
@@ -1204,7 +1204,8 @@ void cir::TernaryOp::getSuccessorRegions(
12041204
return;
12051205
}
12061206

1207-
// If the condition isn't constant, both regions may be executed.
1207+
// When branching from the parent operation, both the true and false
1208+
// regions are considered possible successors
12081209
regions.push_back(RegionSuccessor(&getTrueRegion()));
12091210
regions.push_back(RegionSuccessor(&getFalseRegion()));
12101211
}

0 commit comments

Comments
 (0)