Cf
cf
¶
AssertTrue
¶
Bases: RewritePattern
Erase assertion if argument is constant true.
Source code in xdsl/transforms/canonicalization_patterns/cf.py
match_and_rewrite(op: cf.AssertOp, rewriter: PatternRewriter)
¶
Source code in xdsl/transforms/canonicalization_patterns/cf.py
SimplifyBrToBlockWithSinglePred
¶
Bases: RewritePattern
Simplify a branch to a block that has a single predecessor. This effectively merges the two blocks.
Source code in xdsl/transforms/canonicalization_patterns/cf.py
match_and_rewrite(op: cf.BranchOp, rewriter: PatternRewriter)
¶
Source code in xdsl/transforms/canonicalization_patterns/cf.py
SimplifyPassThroughBr
¶
Bases: RewritePattern
br ^bb1 ^bb1 br ^bbN(...)
-> br ^bbN(...)
Source code in xdsl/transforms/canonicalization_patterns/cf.py
match_and_rewrite(op: cf.BranchOp, rewriter: PatternRewriter)
¶
Source code in xdsl/transforms/canonicalization_patterns/cf.py
SimplifyConstCondBranchPred
¶
Bases: RewritePattern
cf.cond_br true, ^bb1, ^bb2 -> br ^bb1 cf.cond_br false, ^bb1, ^bb2 -> br ^bb2
Source code in xdsl/transforms/canonicalization_patterns/cf.py
match_and_rewrite(op: cf.ConditionalBranchOp, rewriter: PatternRewriter)
¶
Source code in xdsl/transforms/canonicalization_patterns/cf.py
SimplifyPassThroughCondBranch
¶
Bases: RewritePattern
cf.cond_br %cond, ^bb1, ^bb2 ^bb1 br ^bbN(...) ^bb2 br ^bbK(...)
-> cf.cond_br %cond, ^bbN(...), ^bbK(...)
Source code in xdsl/transforms/canonicalization_patterns/cf.py
match_and_rewrite(op: cf.ConditionalBranchOp, rewriter: PatternRewriter)
¶
Source code in xdsl/transforms/canonicalization_patterns/cf.py
SimplifyCondBranchIdenticalSuccessors
¶
Bases: RewritePattern
cf.cond_br %cond, ^bb1(A, ..., N), ^bb1(A, ..., N) -> br ^bb1(A, ..., N)
cf.cond_br %cond, ^bb1(A), ^bb1(B) -> %select = arith.select %cond, A, B br ^bb1(%select)
Source code in xdsl/transforms/canonicalization_patterns/cf.py
match_and_rewrite(op: cf.ConditionalBranchOp, rewriter: PatternRewriter)
¶
Source code in xdsl/transforms/canonicalization_patterns/cf.py
CondBranchTruthPropagation
¶
Bases: RewritePattern
cf.cond_br %arg0, ^trueB, ^falseB
^trueB: "test.consumer1"(%arg0) : (i1) -> () ...
^falseB: "test.consumer2"(%arg0) : (i1) -> () ...
->
cf.cond_br %arg0, ^trueB, ^falseB ^trueB: "test.consumer1"(%true) : (i1) -> () ...
^falseB: "test.consumer2"(%false) : (i1) -> () ...
Source code in xdsl/transforms/canonicalization_patterns/cf.py
match_and_rewrite(op: cf.ConditionalBranchOp, rewriter: PatternRewriter)
¶
Source code in xdsl/transforms/canonicalization_patterns/cf.py
SimplifySwitchWithOnlyDefault
¶
Bases: RewritePattern
switch %flag : i32, [ default: ^bb1 ] -> br ^bb1
Source code in xdsl/transforms/canonicalization_patterns/cf.py
match_and_rewrite(op: cf.SwitchOp, rewriter: PatternRewriter)
¶
DropSwitchCasesThatMatchDefault
¶
Bases: RewritePattern
switch %flag : i32, [ default: ^bb1, 42: ^bb1, 43: ^bb2 ] -> switch %flag : i32, [ default: ^bb1, 43: ^bb2 ]
Source code in xdsl/transforms/canonicalization_patterns/cf.py
match_and_rewrite(op: cf.SwitchOp, rewriter: PatternRewriter)
¶
Source code in xdsl/transforms/canonicalization_patterns/cf.py
SimplifyConstSwitchValue
¶
Bases: RewritePattern
switch %c_42 : i32, [ default: ^bb1, 42: ^bb2, 43: ^bb3 ] -> br ^bb2
Source code in xdsl/transforms/canonicalization_patterns/cf.py
match_and_rewrite(op: cf.SwitchOp, rewriter: PatternRewriter)
¶
SimplifyPassThroughSwitch
¶
Bases: RewritePattern
switch %c_42 : i32, [ default: ^bb1, 42: ^bb2, ] ^bb2: br ^bb3 -> switch %c_42 : i32, [ default: ^bb1, 42: ^bb3, ]
Source code in xdsl/transforms/canonicalization_patterns/cf.py
match_and_rewrite(op: cf.SwitchOp, rewriter: PatternRewriter)
¶
Source code in xdsl/transforms/canonicalization_patterns/cf.py
SimplifySwitchFromSwitchOnSameCondition
¶
Bases: RewritePattern
switch %flag : i32, [ default: ^bb1, 42: ^bb2, ] ^bb2: switch %flag : i32, [ default: ^bb3, 42: ^bb4 ] -> switch %flag : i32, [ default: ^bb1, 42: ^bb2, ] ^bb2: br ^bb4
and
switch %flag : i32, [ default: ^bb1, 42: ^bb2, ] ^bb2: switch %flag : i32, [ default: ^bb3, 43: ^bb4 ] -> switch %flag : i32, [ default: ^bb1, 42: ^bb2, ] ^bb2: br ^bb3
and
switch %flag : i32, [ default: ^bb1, 42: ^bb2 ] ^bb1: switch %flag : i32, [ default: ^bb3, 42: ^bb4, 43: ^bb5 ] -> switch %flag : i32, [ default: ^bb1, 42: ^bb2, ] ^bb1: switch %flag : i32, [ default: ^bb3, 43: ^bb5 ]
Source code in xdsl/transforms/canonicalization_patterns/cf.py
455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 | |
match_and_rewrite(op: cf.SwitchOp, rewriter: PatternRewriter)
¶
Source code in xdsl/transforms/canonicalization_patterns/cf.py
collapse_branch(successor: Block, successor_operands: Sequence[SSAValue]) -> tuple[Block, Sequence[SSAValue]] | None
¶
Given a successor, try to collapse it to a new destination if it only
contains a passthrough unconditional branch. If the successor is
collapsable, successor and successorOperands are updated to reference
the new destination and values. argStorage is used as storage if operands
to the collapsed successor need to be remapped. It must outlive uses of
successorOperands.
Source code in xdsl/transforms/canonicalization_patterns/cf.py
drop_case_helper(rewriter: PatternRewriter, op: cf.SwitchOp, predicate: Callable[[IntegerAttr, Block, Sequence[Operation | SSAValue]], bool])
¶
Source code in xdsl/transforms/canonicalization_patterns/cf.py
fold_switch(switch: cf.SwitchOp, rewriter: PatternRewriter, flag: int)
¶
Helper for folding a switch with a constant value. switch %c_42 : i32, [ default: ^bb1 , 42: ^bb2, 43: ^bb3 ] -> br ^bb2