[llvm] r346495 - [MIPS GlobalISel] narrowScalar G_CONSTANT

Petar Avramovic via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 9 06:21:16 PST 2018


Author: petar.avramovic
Date: Fri Nov  9 06:21:16 2018
New Revision: 346495

URL: http://llvm.org/viewvc/llvm-project?rev=346495&view=rev
Log:
[MIPS GlobalISel] narrowScalar G_CONSTANT

Legalize s64 G_CONSTANT using narrowScalar on MIPS 32.

Differential Revision: https://reviews.llvm.org/D54255

Modified:
    llvm/trunk/lib/Target/Mips/MipsLegalizerInfo.cpp

Modified: llvm/trunk/lib/Target/Mips/MipsLegalizerInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsLegalizerInfo.cpp?rev=346495&r1=346494&r2=346495&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/MipsLegalizerInfo.cpp (original)
+++ llvm/trunk/lib/Target/Mips/MipsLegalizerInfo.cpp Fri Nov  9 06:21:16 2018
@@ -41,8 +41,7 @@ MipsLegalizerInfo::MipsLegalizerInfo(con
 
   getActionDefinitionsBuilder(G_CONSTANT)
       .legalFor({s32})
-      .minScalar(0, s32)
-      .customFor({s64});
+      .clampScalar(0, s32, s32);
 
   getActionDefinitionsBuilder(G_GEP)
       .legalFor({{p0, s32}});
@@ -90,27 +89,6 @@ bool MipsLegalizerInfo::legalizeCustom(M
 
     MIRBuilder.buildMerge(MI.getOperand(0).getReg(), {ResLow, ResHigh});
 
-    MI.eraseFromParent();
-    break;
-  }
-  case G_CONSTANT: {
-
-    unsigned Size = MRI.getType(MI.getOperand(0).getReg()).getSizeInBits();
-    const LLT sHalf = LLT::scalar(Size / 2);
-
-    const APInt &CImmValue = MI.getOperand(1).getCImm()->getValue();
-
-    unsigned ResLow = MRI.createGenericVirtualRegister(sHalf);
-    unsigned ResHigh = MRI.createGenericVirtualRegister(sHalf);
-    MIRBuilder.buildConstant(
-        ResLow, *ConstantInt::get(MI.getMF()->getFunction().getContext(),
-                                  CImmValue.trunc(Size / 2)));
-    MIRBuilder.buildConstant(
-        ResHigh, *ConstantInt::get(MI.getMF()->getFunction().getContext(),
-                                   CImmValue.lshr(Size / 2).trunc(Size / 2)));
-
-    MIRBuilder.buildMerge(MI.getOperand(0).getReg(), {ResLow, ResHigh});
-
     MI.eraseFromParent();
     break;
   }




More information about the llvm-commits mailing list