From 1120279ae6f2a502093a0c20c1b8d5d4dfd44e4c Mon Sep 17 00:00:00 2001 From: Evan Cheng Date: Tue, 13 May 2008 08:35:03 +0000 Subject: Instead of a vector load, shuffle and then extract an element. Load the element from address with an offset. pshufd $1, (%rdi), %xmm0 movd %xmm0, %eax => movl 4(%rdi), %eax llvm-svn: 51026 --- llvm/lib/Target/X86/README-SSE.txt | 29 ----------------------------- llvm/lib/Target/X86/X86ISelLowering.cpp | 22 +--------------------- 2 files changed, 1 insertion(+), 50 deletions(-) (limited to 'llvm/lib/Target') diff --git a/llvm/lib/Target/X86/README-SSE.txt b/llvm/lib/Target/X86/README-SSE.txt index c78e13b8a8b..5c681e06e0c 100644 --- a/llvm/lib/Target/X86/README-SSE.txt +++ b/llvm/lib/Target/X86/README-SSE.txt @@ -545,35 +545,6 @@ swizzle: //===---------------------------------------------------------------------===// -These functions should produce the same code: - -#include - -typedef long long __m128i __attribute__ ((__vector_size__ (16))); - -int foo(__m128i* val) { - return __builtin_ia32_vec_ext_v4si(*val, 1); -} -int bar(__m128i* val) { - union vs { - __m128i *_v; - int* _s; - } v = {val}; - return v._s[1]; -} - -We currently produce (with -m64): - -_foo: - pshufd $1, (%rdi), %xmm0 - movd %xmm0, %eax - ret -_bar: - movl 4(%rdi), %eax - ret - -//===---------------------------------------------------------------------===// - We should materialize vector constants like "all ones" and "signbit" with code like: diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp index 806b626456a..4cc3f270222 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -6182,26 +6182,6 @@ void X86TargetLowering::computeMaskedBitsForTargetNode(const SDOperand Op, } } -/// getShuffleScalarElt - Returns the scalar element that will make up the ith -/// element of the result of the vector shuffle. -static SDOperand getShuffleScalarElt(SDNode *N, unsigned i, SelectionDAG &DAG) { - MVT::ValueType VT = N->getValueType(0); - SDOperand PermMask = N->getOperand(2); - unsigned NumElems = PermMask.getNumOperands(); - SDOperand V = (i < NumElems) ? N->getOperand(0) : N->getOperand(1); - i %= NumElems; - if (V.getOpcode() == ISD::SCALAR_TO_VECTOR) { - return (i == 0) - ? V.getOperand(0) : DAG.getNode(ISD::UNDEF, MVT::getVectorElementType(VT)); - } else if (V.getOpcode() == ISD::VECTOR_SHUFFLE) { - SDOperand Idx = PermMask.getOperand(i); - if (Idx.getOpcode() == ISD::UNDEF) - return DAG.getNode(ISD::UNDEF, MVT::getVectorElementType(VT)); - return getShuffleScalarElt(V.Val,cast(Idx)->getValue(),DAG); - } - return SDOperand(); -} - /// isGAPlusOffset - Returns true (and the GlobalValue and the offset) if the /// node is a GlobalAddress + offset. bool X86TargetLowering::isGAPlusOffset(SDNode *N, @@ -6240,7 +6220,7 @@ static bool EltsFromConsecutiveLoads(SDNode *N, SDOperand PermMask, } unsigned Index = cast(Idx)->getValue(); - SDOperand Elt = getShuffleScalarElt(N, Index, DAG); + SDOperand Elt = DAG.getShuffleScalarElt(N, Index); if (!Elt.Val || (Elt.getOpcode() != ISD::UNDEF && !ISD::isNON_EXTLoad(Elt.Val))) return false; -- cgit v1.2.3