| 5279 | } |
| 5280 | |
| 5281 | static OpFoldResult tryFoldSelectWithSelect(SelectOp op, |
| 5282 | SelectOp::FoldAdaptor adaptor) { |
| 5283 | Value t = op.getValIfTrue(); |
| 5284 | Value f = op.getValIfFalse(); |
| 5285 | Value cond = op.getCond(); |
| 5286 | // ---- Rule: select(pred, select(pred, a, b), c) => select(pred, a, c) |
| 5287 | // "RedundantSelectTrue" |
| 5288 | if (auto innerTrueSel = t.getDefiningOp<SelectOp>()) { |
| 5289 | if (innerTrueSel.getCond() == cond) { |
| 5290 | op.getValIfTrueMutable().assign(innerTrueSel.getValIfTrue()); |
| 5291 | return op.getResult(); // in-place |
| 5292 | } |
| 5293 | } |
| 5294 | |
| 5295 | // ---- Rule: select(pred, a, select(pred, b, c)) => select(pred, a, c) |
| 5296 | // "RedundantSelectFalse" |
| 5297 | if (auto innerFalseSel = f.getDefiningOp<SelectOp>()) { |
| 5298 | if (innerFalseSel.getCond() == cond) { |
| 5299 | op.getValIfFalseMutable().assign(innerFalseSel.getValIfFalse()); |
| 5300 | return op.getResult(); |
| 5301 | } |
| 5302 | } |
| 5303 | |
| 5304 | return {}; |
| 5305 | } |
| 5306 | |
| 5307 | namespace { |
| 5308 | using SelectFoldRuleFn = OpFoldResult (*)(SelectOp, SelectOp::FoldAdaptor); |
nothing calls this directly
no outgoing calls
no test coverage detected