[PATCH] D71637: [PatternMatch] Add support for matching ConstantExpr.

Huihui Zhang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 17 16:29:07 PST 2019


huihuiz created this revision.
huihuiz added reviewers: sdesmalen, huntergr, spatel, lebedev.ri, apazos, efriedma, willlovett.
huihuiz added a project: LLVM.

Motivated in D71389 <https://reviews.llvm.org/D71389>. For scalable vector type, constant folding
will be applied on ConstantExprs. It would be usefull to support
pattern matcher for ConstantExprs.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71637

Files:
  llvm/include/llvm/IR/PatternMatch.h


Index: llvm/include/llvm/IR/PatternMatch.h
===================================================================
--- llvm/include/llvm/IR/PatternMatch.h
+++ llvm/include/llvm/IR/PatternMatch.h
@@ -1235,6 +1235,9 @@
       return Op1.match(I->getOperand(0)) && Op2.match(I->getOperand(1)) &&
              Op3.match(I->getOperand(2));
     }
+    if (auto *CE = dyn_cast<ConstantExpr>(V))
+      return (CE->getOpcode() == Opcode) && Op1.match(CE->getOperand(0)) &&
+             Op2.match(CE->getOperand(1)) && Op3.match(CE->getOperand(2));
     return false;
   }
 };


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71637.234413.patch
Type: text/x-patch
Size: 567 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191218/701afdb2/attachment.bin>


More information about the llvm-commits mailing list