[llvm] [GlobalISel] Fold G_ICMP if possible (PR #86357)

Shilei Tian via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 29 08:11:09 PDT 2024


================
@@ -174,6 +174,20 @@ MachineInstrBuilder CSEMIRBuilder::buildInstr(unsigned Opc,
   switch (Opc) {
   default:
     break;
+  case TargetOpcode::G_ICMP: {
+    assert(SrcOps.size() == 3 && "Invalid sources");
+    assert(DstOps.size() == 1 && "Invalid dsts");
+    LLT SrcTy = SrcOps[1].getLLTTy(*getMRI());
+
+    if (std::optional<SmallVector<APInt>> Cst =
----------------
shiltian wrote:

In that case it would accept `ArrayRef<int64_t>` I suppose, which still needs to have an explicit construction of that array because we can't have implicit cast from, say `ArrayRef<bool>` to `ArrayRef<int64_t>`. That doesn't look too much different from `ArrayRef<APInt>`.

https://github.com/llvm/llvm-project/pull/86357


More information about the llvm-commits mailing list