================
@@ -2784,6 +2786,59 @@ void LoweringPreparePass::lowerStdOp(cir::StdOpInterface 
typedOp) {
   op->erase();
 }
 
+/// If `cond` is the result of a chain of cir.not ops, sets it to the input of
+/// the innermost cir.not and erases the cir.not ops left without uses.  An
+/// odd number of cir.not ops inverts the condition, so `trueRegion` and
+/// `falseRegion` are swapped.  If one region is empty, the other is empty
+/// after a swap, and the caller restores any region its op requires.  Returns
+/// true if the regions were swapped.
+static bool stripNotsFromCondition(mlir::OpOperand &cond,
+                                   mlir::Region &trueRegion,
+                                   mlir::Region &falseRegion) {
+  llvm::SmallVector<cir::NotOp> notOps;
----------------
adams381 wrote:

Split as suggested: `stripNotsFromCondition` returns whether the condition is 
inverted, and `swapRegions` swaps the bodies.

`std::swap` doesn't work on regions: `iplist::swap` asserts because it doesn't 
update each block's parent region, so `swapRegions` uses `takeBody`.

https://github.com/llvm/llvm-project/pull/233918
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to