[PATCH] D95645: [AArch64][GlobalISel] Add a combine to fold away truncate in: G_ICMP EQ/NE (G_TRUNC(v), 0)

Jessica Paquette via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 28 16:04:57 PST 2021


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

This LGTM. Seems like it could be useful on other targets in general though.



================
Comment at: llvm/lib/Target/AArch64/GISel/AArch64PreLegalizerCombiner.cpp:67
+  auto Pred = (CmpInst::Predicate)MI.getOperand(1).getPredicate();
+  if (Pred != ICmpInst::ICMP_NE && Pred != llvm::CmpInst::ICMP_EQ)
+    return false;
----------------
Nit: `ICmpInst` has a helper for this


================
Comment at: llvm/lib/Target/AArch64/GISel/AArch64PreLegalizerCombiner.cpp:78
+
+  if (!mi_match(LHS, MRI, m_GTrunc(m_Reg(WideReg))))
+    return false;
----------------
Minor nit: maybe slightly nicer to pull the other `mi_match` into here

```
if (!mi_match(...) || !mi_match(...))
  return false;
```



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95645



More information about the llvm-commits mailing list