[PATCH] D63318: [DAGCombine] Teach DAGCombine to fold the aext + select pattern

Qing Shan Zhang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 13 22:58:31 PDT 2019


steven.zhang created this revision.
steven.zhang added reviewers: craig.topper, jsji, nemanjai, hfinkel, kbarton, RKSimon.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.

Teach the DAGCombine to fold this pattern(c1 and c2 is constant).

  // fold (sext (select cond, c1, c2)) -> (select cond, sext c1, sext c2)
  // fold (zext (select cond, c1, c2)) -> (select cond, zext c1, zext c2)
  // fold (aext (select cond, c1, c2)) -> (select cond, sext c1, sext c2)

Sign extend the operands if it is any_extend, to keep the signess of the operands that, the other combine rule would apply. The any_extend is handled as zero extend for constants. i.e.

  t1: i8 = select t0, Constant:i8<-1>, Constant:i8<0>
  t2: i64 = any_extend t1
   -->
  t3: i64 = select t0, Constant:i64<-1>, Constant:i64<0>
   -->
   t4: i64 = sign_extend_inreg t3

  


https://reviews.llvm.org/D63318

Files:
  llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  llvm/test/CodeGen/PowerPC/bool-math.ll
  llvm/test/CodeGen/PowerPC/select_const.ll
  llvm/test/CodeGen/X86/avx512-insert-extract.ll
  llvm/test/CodeGen/X86/cmov-promotion.ll
  llvm/test/CodeGen/X86/select.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63318.204701.patch
Type: text/x-patch
Size: 24855 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190614/ab40f09f/attachment.bin>


More information about the llvm-commits mailing list