[llvm-commits] [llvm] r60945 - /llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp

Duncan Sands baldrick at free.fr
Fri Dec 12 00:13:38 PST 2008


Author: baldrick
Date: Fri Dec 12 02:13:38 2008
New Revision: 60945

URL: http://llvm.org/viewvc/llvm-project?rev=60945&view=rev
Log:
When using a 4 byte jump table on a 64 bit machine,
do an extending load of the 4 bytes rather than a
potentially illegal (type) i32 load followed by a
sign extend.

Modified:
    llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp?rev=60945&r1=60944&r2=60945&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Fri Dec 12 02:13:38 2008
@@ -1951,23 +1951,15 @@
       unsigned EntrySize = MF.getJumpTableInfo()->getEntrySize();
       Index= DAG.getNode(ISD::MUL, PTy, Index, DAG.getConstant(EntrySize, PTy));
       SDValue Addr = DAG.getNode(ISD::ADD, PTy, Index, Table);
-      
-      SDValue LD;
-      switch (EntrySize) {
-      default: assert(0 && "Size of jump table not supported yet."); break;
-      case 4: LD = DAG.getLoad(MVT::i32, Chain, Addr,
-                               PseudoSourceValue::getJumpTable(), 0); break;
-      case 8: LD = DAG.getLoad(MVT::i64, Chain, Addr,
-                               PseudoSourceValue::getJumpTable(), 0); break;
-      }
 
+      MVT MemVT = MVT::getIntegerVT(EntrySize * 8);
+      SDValue LD = DAG.getExtLoad(ISD::SEXTLOAD, PTy, Chain, Addr,
+                                  PseudoSourceValue::getJumpTable(), 0, MemVT);
       Addr = LD;
       if (TLI.getTargetMachine().getRelocationModel() == Reloc::PIC_) {
         // For PIC, the sequence is:
         // BRIND(load(Jumptable + index) + RelocBase)
         // RelocBase can be JumpTable, GOT or some sort of global base.
-        if (PTy != MVT::i32)
-          Addr = DAG.getNode(ISD::SIGN_EXTEND, PTy, Addr);
         Addr = DAG.getNode(ISD::ADD, PTy, Addr,
                            TLI.getPICJumpTableRelocBase(Table, DAG));
       }





More information about the llvm-commits mailing list