[llvm-commits] [llvm] r48726 - in /llvm/trunk: lib/CodeGen/SelectionDAG/SelectionDAG.cpp test/CodeGen/X86/i128-immediate.ll test/CodeGen/X86/pr1462.ll

Dan Gohman gohman at apple.com
Mon Mar 24 09:38:06 PDT 2008


Author: djg
Date: Mon Mar 24 11:38:05 2008
New Revision: 48726

URL: http://llvm.org/viewvc/llvm-project?rev=48726&view=rev
Log:
APIntify SelectionDAG's EXTRACT_ELEMENT code.

Added:
    llvm/trunk/test/CodeGen/X86/i128-immediate.ll
    llvm/trunk/test/CodeGen/X86/pr1462.ll
Modified:
    llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

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

==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Mon Mar 24 11:38:05 2008
@@ -2119,8 +2119,10 @@
 
     // EXTRACT_ELEMENT of a constant int is also very common.
     if (ConstantSDNode *C = dyn_cast<ConstantSDNode>(N1)) {
-      unsigned Shift = MVT::getSizeInBits(VT) * N2C->getValue();
-      return getConstant(C->getValue() >> Shift, VT);
+      unsigned ElementSize = MVT::getSizeInBits(VT);
+      unsigned Shift = ElementSize * N2C->getValue();
+      APInt ShiftedVal = C->getAPIntValue().lshr(Shift);
+      return getConstant(ShiftedVal.trunc(ElementSize), VT);
     }
     break;
   case ISD::EXTRACT_SUBVECTOR:

Added: llvm/trunk/test/CodeGen/X86/i128-immediate.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/i128-immediate.ll?rev=48726&view=auto

==============================================================================
--- llvm/trunk/test/CodeGen/X86/i128-immediate.ll (added)
+++ llvm/trunk/test/CodeGen/X86/i128-immediate.ll Mon Mar 24 11:38:05 2008
@@ -0,0 +1,5 @@
+; RUN: llvm-as < %s | llc -march=x86-64 | grep movq | count 2
+
+define i128 @__addvti3() {
+          ret i128 -1
+}

Added: llvm/trunk/test/CodeGen/X86/pr1462.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/pr1462.ll?rev=48726&view=auto

==============================================================================
--- llvm/trunk/test/CodeGen/X86/pr1462.ll (added)
+++ llvm/trunk/test/CodeGen/X86/pr1462.ll Mon Mar 24 11:38:05 2008
@@ -0,0 +1,25 @@
+; RUN: llvm-as < %s | llc
+; PR1462
+
+target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-
+v64:64:64-v128:128:128-a0:0:64"
+target triple = "x86_64-unknown-linux-gnu"
+
+define hidden i128 @__addvti3(i128 %a1, i128 %b2) {
+entry:
+        %tmp8 = add i128 %b2, %a1               ; <i128> [#uses=3]
+        %tmp10 = icmp sgt i128 %b2, -1          ; <i1> [#uses=1]
+        %tmp18 = icmp sgt i128 %tmp8, %a1               ; <i1> [#uses=1]
+        %tmp14 = icmp slt i128 %tmp8, %a1               ; <i1> [#uses=1]
+        %iftmp.0.0.in = select i1 %tmp10, i1 %tmp14, i1 %tmp18          ; <i1> [#uses=1]
+        br i1 %iftmp.0.0.in, label %cond_true22, label %cond_next23
+
+cond_true22:            ; preds = %entry
+        tail call void @abort( )
+        unreachable
+
+cond_next23:            ; preds = %entry
+        ret i128 %tmp8
+}
+
+declare void @abort()





More information about the llvm-commits mailing list