[llvm] [GlobalISel] Fold G_ICMP if possible (PR #86357)
Shilei Tian via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 29 07:25:56 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:
There is a type check in `MachineIRBuilder::buildConstant` to make sure their bits are same. The use of `APInt` is to unify the `ConstantFoldICmp` interface to make it support both vector and scalar value.
https://github.com/llvm/llvm-project/pull/86357
More information about the llvm-commits
mailing list