MCPcopy Create free account
hub / github.com/NVIDIA/cuda-tile / tryFoldSelectWithSelect

Function tryFoldSelectWithSelect

lib/Dialect/CudaTile/IR/CudaTile.cpp:5281–5305  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5279}
5280
5281static 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
5307namespace {
5308using SelectFoldRuleFn = OpFoldResult (*)(SelectOp, SelectOp::FoldAdaptor);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected