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

Function tryFoldSelectBoolIdentity

lib/Dialect/CudaTile/IR/CudaTile.cpp:5216–5227  ·  view source on GitHub ↗

3) Boolean identity: select c, true, false => c (Safe because we return an existing value; the inverse case `select c, false, true => !c` would require creating an op, so leave that to canonicalization patterns.)

Source from the content-addressed store, hash-verified

5214// `select c, false, true => !c` would require creating an op, so leave
5215// that to canonicalization patterns.)
5216static OpFoldResult tryFoldSelectBoolIdentity(SelectOp op,
5217 SelectOp::FoldAdaptor adaptor) {
5218 // select %x, true, false => %x
5219 Value t = op.getValIfTrue();
5220 Value f = op.getValIfFalse();
5221 Value cond = op.getCond();
5222 auto tileTy = llvm::dyn_cast_or_null<TileType>(op.getType());
5223 if (tileTy && tileTy.getElementType().isSignlessInteger(1) &&
5224 isConstantTrueVal(t) && isConstantFalseVal(f))
5225 return cond;
5226 return {};
5227}
5228
5229static OpFoldResult tryFoldSelectWithCmp(SelectOp op,
5230 SelectOp::FoldAdaptor adaptor) {

Callers

nothing calls this directly

Calls 3

isConstantTrueValFunction · 0.85
isConstantFalseValFunction · 0.85
getTypeMethod · 0.80

Tested by

no test coverage detected