[PATCH] D88687: [InstCombine] visitTrunc - pass through undefs for trunc(shift(trunc/ext(x),c)) patterns

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 13 05:49:29 PDT 2020


lebedev.ri accepted this revision.
lebedev.ri added a comment.
This revision is now accepted and ready to land.

Perfect, LGTM.



================
Comment at: llvm/include/llvm/IR/Constant.h:208
+
+  /// Merges any undefined constant or elements in Other into C, along with the
+  /// undefs already present. Other doesn't have to be the same type as C, but
----------------
I'm having trouble parsing the first line.
I guess it talks about vector element undefs and scalar undefs, but it's hard go get that.


================
Comment at: llvm/lib/IR/Constants.cpp:743
+  Type *Ty = C->getType();
+  if (match(Other, m_Undef())) {
+    return UndefValue::get(Ty);
----------------
Nit: drop braces


================
Comment at: llvm/lib/IR/Constants.cpp:763-766
+    if (match(OtherEltC, m_Undef())) {
+      NewC[I] = UndefValue::get(EltTy);
+      FoundExtraUndef = true;
+    }
----------------
You probably want
```
    if (!match(NewC[I], m_Undef()) && match(OtherEltC, m_Undef())) {
      NewC[I] = OtherEltC;
      FoundExtraUndef = true;
    }
```
otherwise you set `FoundExtraUndef` even if LHS already was `undef`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88687/new/

https://reviews.llvm.org/D88687



More information about the llvm-commits mailing list