[PATCH] D48828: [InstSimplify] fold extracting from std::pair (1/2)

Hiroshi Inoue via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 30 04:59:40 PDT 2018


inouehrs added inline comments.


================
Comment at: lib/Analysis/InstructionSimplify.cpp:1289-1291
+  const APInt *ShAmt;
+  if (match(Op1, m_APInt(ShAmt)) &&
+      match(Op0, m_c_Or(m_NUWShl(m_Value(X), m_Specific(Op1)), m_Value(Y)))) {
----------------
lebedev.ri wrote:
> I'm not sure this is better, or the full fix (tests needed.)
> I would think you'd need
> ```
>   const APInt *ShAmt0, *ShAmt1;
>   if (match(Op1, m_APInt(ShAmt2)) &&
>       match(Op0, m_c_Or(m_NUWShl(m_Value(X), m_APInt(ShAmt1)), m_Value(Y))) &&
>       *ShAmt0 == *ShAmt1) {
>     const APInt *ShAmt = ShAmt1;
> ```
Sorry but I cannot catch why you use `m_APInt` in the matcher and then compare the values instead of using `m_Specific`. What kind of code sequences you want to cover with this?


https://reviews.llvm.org/D48828





More information about the llvm-commits mailing list