[llvm-commits] [llvm] r67078 - in /llvm/branches/Apple/Dib: lib/VMCore/ConstantFold.cpp lib/VMCore/Constants.cpp test/Assembler/vector-shift.ll

Bill Wendling isanbard at gmail.com
Tue Mar 17 00:45:15 PDT 2009


Author: void
Date: Tue Mar 17 02:45:15 2009
New Revision: 67078

URL: http://llvm.org/viewvc/llvm-project?rev=67078&view=rev
Log:
--- Merging (from foreign repository) r67010 into '.':
U    test/Assembler/vector-shift.ll
U    lib/VMCore/Constants.cpp
U    lib/VMCore/ConstantFold.cpp


Apply a patch by Micah Villmow to fix AsmParser to accept vector
shift constant expressions, and add support for folding vector
shift constant expressions. This fixes PR3802.

Modified:
    llvm/branches/Apple/Dib/lib/VMCore/ConstantFold.cpp
    llvm/branches/Apple/Dib/lib/VMCore/Constants.cpp
    llvm/branches/Apple/Dib/test/Assembler/vector-shift.ll

Modified: llvm/branches/Apple/Dib/lib/VMCore/ConstantFold.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Dib/lib/VMCore/ConstantFold.cpp?rev=67078&r1=67077&r2=67078&view=diff

==============================================================================
--- llvm/branches/Apple/Dib/lib/VMCore/ConstantFold.cpp (original)
+++ llvm/branches/Apple/Dib/lib/VMCore/ConstantFold.cpp Tue Mar 17 02:45:15 2009
@@ -832,6 +832,12 @@
         return EvalVectorOp(CP1, CP2, VTy, ConstantExpr::getOr);
       case Instruction::Xor: 
         return EvalVectorOp(CP1, CP2, VTy, ConstantExpr::getXor);
+      case Instruction::LShr:
+        return EvalVectorOp(CP1, CP2, VTy, ConstantExpr::getLShr);
+      case Instruction::AShr:
+        return EvalVectorOp(CP1, CP2, VTy, ConstantExpr::getAShr);
+      case Instruction::Shl:
+        return EvalVectorOp(CP1, CP2, VTy, ConstantExpr::getShl);
       }
     }
   }

Modified: llvm/branches/Apple/Dib/lib/VMCore/Constants.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Dib/lib/VMCore/Constants.cpp?rev=67078&r1=67077&r2=67078&view=diff

==============================================================================
--- llvm/branches/Apple/Dib/lib/VMCore/Constants.cpp (original)
+++ llvm/branches/Apple/Dib/lib/VMCore/Constants.cpp Tue Mar 17 02:45:15 2009
@@ -2095,7 +2095,7 @@
   case Instruction::LShr:
   case Instruction::AShr:
     assert(C1->getType() == C2->getType() && "Op types should be identical!");
-    assert(C1->getType()->isInteger() &&
+    assert(C1->getType()->isIntOrIntVector() &&
            "Tried to create a shift operation on a non-integer type!");
     break;
   default:

Modified: llvm/branches/Apple/Dib/test/Assembler/vector-shift.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Dib/test/Assembler/vector-shift.ll?rev=67078&r1=67077&r2=67078&view=diff

==============================================================================
--- llvm/branches/Apple/Dib/test/Assembler/vector-shift.ll (original)
+++ llvm/branches/Apple/Dib/test/Assembler/vector-shift.ll Tue Mar 17 02:45:15 2009
@@ -1,6 +1,6 @@
-; RUN: llvm-as < %s | llvm-dis | llvm-as | llvm-dis | grep shl
-; RUN: llvm-as < %s | llvm-dis | llvm-as | llvm-dis | grep ashr
-; RUN: llvm-as < %s | llvm-dis | llvm-as | llvm-dis | grep lshr
+; RUN: llvm-as < %s | llvm-dis | llvm-as | llvm-dis | grep shl | count 1
+; RUN: llvm-as < %s | llvm-dis | llvm-as | llvm-dis | grep ashr | count 1
+; RUN: llvm-as < %s | llvm-dis | llvm-as | llvm-dis | grep lshr | count 1
 
 define <4 x i32> @foo(<4 x i32> %a, <4 x i32> %b) nounwind  {
 entry:
@@ -19,3 +19,14 @@
 	%cmp = ashr <4 x i32> %a, %b		; <4 x i32> [#uses=1]
 	ret <4 x i32> %cmp
 }
+
+; Constant expressions: these should be folded.
+define <2 x i64> @foo_ce() nounwind {
+  ret <2 x i64> shl (<2 x i64> <i64 5, i64 6>, <2 x i64> <i64 3, i64 5>)
+}
+define <2 x i64> @bar_ce() nounwind {
+  ret <2 x i64> lshr (<2 x i64> <i64 340, i64 380>, <2 x i64> <i64 3, i64 5>)
+}
+define <2 x i64> @baz_ce() nounwind {
+  ret <2 x i64> ashr (<2 x i64> <i64 573, i64 411>, <2 x i64> <i64 3, i64 5>)
+}





More information about the llvm-commits mailing list