[PATCH] D78682: [mlir][Standard] Add a canonicalization to simplify cond_br when the successors are identical

River Riddle via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 22 15:48:35 PDT 2020


rriddle created this revision.
rriddle added a reviewer: benvanik.
Herald added subscribers: llvm-commits, Kayjukh, frgossen, grosul1, Joonsoo, liufengdb, lucyrfox, mgester, arpith-jacob, nicolasvasilache, antiagainst, shauheen, jpienaar, mehdi_amini, dexonsmith.
Herald added a project: LLVM.
rriddle added a child revision: D78683: [mlir][Standard] Add support for canonicalizing branches to passthrough blocks.

This revision adds support for canonicalizing the following:

  cond_br %cond, ^bb1(A, ..., N), ^bb1(A, ..., N)
  
  br ^bb1(A, ..., N)

If the operands to the successor are different and the cond_br is the only predecessor, we emit selects for the branch operands.

  cond_br %cond, ^bb1(A), ^bb1(B)
  
  %select = select %cond, A, B
  br ^bb1(%select)

Depends On D78681 <https://reviews.llvm.org/D78681>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78682

Files:
  llvm/include/llvm/ADT/STLExtras.h
  mlir/include/mlir/Dialect/StandardOps/IR/Ops.td
  mlir/include/mlir/IR/Block.h
  mlir/lib/Dialect/StandardOps/IR/Ops.cpp
  mlir/lib/IR/Block.cpp
  mlir/test/Dialect/Standard/canonicalize-cf.mlir
  mlir/test/IR/invalid-ops.mlir

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78682.259419.patch
Type: text/x-patch
Size: 12130 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200422/e3d8b28b/attachment.bin>


More information about the llvm-commits mailing list