[llvm-commits] [llvm] r41017 - /llvm/trunk/lib/Target/X86/X86InstrSSE.td
Author: void Date: Sat Aug 11 04:52:53 2007 New Revision: 41017 URL: http://llvm.org/viewvc/llvm-project?rev=41017&view=rev Log: 64-bit SSSE3 ops that use MMX registers don't require 16-byte alignment. Make a 'memop' pattern just for them. Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrSSE.td?rev=41017&r1=41016&r2=41017&view=diff == --- llvm/trunk/lib/Target/X86/X86InstrSSE.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrSSE.td Sat Aug 11 04:52:53 2007 @@ -128,14 +128,25 @@ def memopfsf64 : PatFrag<(ops node:$ptr), (f64 (memop node:$ptr))>; def memopv4f32 : PatFrag<(ops node:$ptr), (v4f32 (memop node:$ptr))>; def memopv2f64 : PatFrag<(ops node:$ptr), (v2f64 (memop node:$ptr))>; -def memopv8i8 : PatFrag<(ops node:$ptr), (v8i8 (memop node:$ptr))>; -def memopv16i8 : PatFrag<(ops node:$ptr), (v16i8 (memop node:$ptr))>; -def memopv4i16 : PatFrag<(ops node:$ptr), (v4i16 (memop node:$ptr))>; -def memopv8i16 : PatFrag<(ops node:$ptr), (v8i16 (memop node:$ptr))>; -def memopv2i32 : PatFrag<(ops node:$ptr), (v2i32 (memop node:$ptr))>; def memopv4i32 : PatFrag<(ops node:$ptr), (v4i32 (memop node:$ptr))>; def memopv2i64 : PatFrag<(ops node:$ptr), (v2i64 (memop node:$ptr))>; +// SSSE3 uses MMX registers for some instructions. They aren't aligned on a +// 16-byte boundary. +def memop64 : PatFrag<(ops node:$ptr), (ld node:$ptr), [{ + if (LoadSDNode *LD = dyn_cast(N)) +return LD->getExtensionType() == ISD::NON_EXTLOAD && + LD->getAddressingMode() == ISD::UNINDEXED && + LD->getAlignment() >= 8; + return false; +}]>; + +def memopv8i8 : PatFrag<(ops node:$ptr), (v8i8 (memop64 node:$ptr))>; +def memopv16i8 : PatFrag<(ops node:$ptr), (v16i8 (memop64 node:$ptr))>; +def memopv4i16 : PatFrag<(ops node:$ptr), (v4i16 (memop64 node:$ptr))>; +def memopv8i16 : PatFrag<(ops node:$ptr), (v8i16 (memop64 node:$ptr))>; +def memopv2i32 : PatFrag<(ops node:$ptr), (v2i32 (memop64 node:$ptr))>; + def bc_v4f32 : PatFrag<(ops node:$in), (v4f32 (bitconvert node:$in))>; def bc_v2f64 : PatFrag<(ops node:$in), (v2f64 (bitconvert node:$in))>; def bc_v16i8 : PatFrag<(ops node:$in), (v16i8 (bitconvert node:$in))>; @@ -2284,10 +2295,14 @@ // SSSE3 Instructions //===--===// -// SSE3 Instruction Templates: +// SSSE3 Instruction Templates: // // SS38I - SSSE3 instructions with T8 prefix. // SS3AI - SSSE3 instructions with TA prefix. +// +// Note: SSSE3 instructions have 64-bit and 128-bit versions. The 64-bit version +// uses the MMX registers. We put those instructions here because they better +// fit into the SSSE3 instruction category rather than the MMX category. class SS38I o, Format F, dag outs, dag ins, string asm, list pattern> ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r41018 - /llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp
Author: reid Date: Sat Aug 11 10:57:56 2007 New Revision: 41018 URL: http://llvm.org/viewvc/llvm-project?rev=41018&view=rev Log: Fix a comment typo noticed by Sandro Magi. Modified: llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp Modified: llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp?rev=41018&r1=41017&r2=41018&view=diff == --- llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp Sat Aug 11 10:57:56 2007 @@ -336,7 +336,7 @@ /// This function converts a Constant* into a GenericValue. The interesting /// part is if C is a ConstantExpr. -/// @brief Get a GenericValue for a Constnat* +/// @brief Get a GenericValue for a Constant* GenericValue ExecutionEngine::getConstantValue(const Constant *C) { // If its undefined, return the garbage. if (isa(C)) ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r41019 - /llvm/trunk/utils/findmisopt
Author: reid Date: Sat Aug 11 11:11:22 2007 New Revision: 41019 URL: http://llvm.org/viewvc/llvm-project?rev=41019&view=rev Log: Now that llvm-ld can accept - as input from stdin, use this feature to extract the pass arguments that it supports. Modified: llvm/trunk/utils/findmisopt Modified: llvm/trunk/utils/findmisopt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/findmisopt?rev=41019&r1=41018&r2=41019&view=diff == --- llvm/trunk/utils/findmisopt (original) +++ llvm/trunk/utils/findmisopt Sat Aug 11 11:11:22 2007 @@ -95,8 +95,8 @@ # Define the list of optimizations to run. This comprises the same set of # optimizations that opt -std-compile-opts and gccld run, in the same order. opt_switches=`llvm-as < /dev/null -o - | opt -std-compile-opts -disable-output -debug-pass=Arguments 2>&1 | sed 's/Pass Arguments: //'` -gccld_switches="-internalize -ipsccp -globalopt -constmerge -deadargelim -inline -prune-eh -globalopt -globaldce -argpromotion -instcombine -predsimplify -scalarrepl -globalsmodref-aa -licm -load-vn -gcse -dse -instcombine -simplifycfg -verify" -all_switches="$opt_switches $gccld_switches" +ld_switches=`llvm-as < /dev/null -o - | llvm-ld - -std-link-opts -disable-output -debug-pass=Arguments 2>&1 | sed 's/Pass Arguments: //'` +all_switches="$opt_switches $ld_switches" echo "Passes : $all_switches" # Current set of switches is empty ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r41020 - /llvm/trunk/lib/Target/X86/README.txt
Author: lattner Date: Sat Aug 11 13:16:46 2007 New Revision: 41020 URL: http://llvm.org/viewvc/llvm-project?rev=41020&view=rev Log: With evan's explicit flag representation, hopefully we will finally be able to 3-addressify away stuff like this: movl%ecx, %eax decl%eax Modified: llvm/trunk/lib/Target/X86/README.txt Modified: llvm/trunk/lib/Target/X86/README.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/README.txt?rev=41020&r1=41019&r2=41020&view=diff == --- llvm/trunk/lib/Target/X86/README.txt (original) +++ llvm/trunk/lib/Target/X86/README.txt Sat Aug 11 13:16:46 2007 @@ -959,7 +959,7 @@ //===-===// We need to teach the codegen to convert two-address INC instructions to LEA -when the flags are dead. For example, on X86-64, compile: +when the flags are dead (likewise dec). For example, on X86-64, compile: int foo(int A, int B) { return A+1; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r41021 - /llvm/trunk/lib/Target/X86/README.txt
Author: lattner Date: Sat Aug 11 13:19:07 2007 New Revision: 41021 URL: http://llvm.org/viewvc/llvm-project?rev=41021&view=rev Log: expand a note Modified: llvm/trunk/lib/Target/X86/README.txt Modified: llvm/trunk/lib/Target/X86/README.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/README.txt?rev=41021&r1=41020&r2=41021&view=diff == --- llvm/trunk/lib/Target/X86/README.txt (original) +++ llvm/trunk/lib/Target/X86/README.txt Sat Aug 11 13:19:07 2007 @@ -559,7 +559,25 @@ //===-===// -Implement CTTZ, CTLZ with bsf and bsr. +Implement CTTZ, CTLZ with bsf and bsr. GCC produces: + +int ctz_(unsigned X) { return __builtin_ctz(X); } +int clz_(unsigned X) { return __builtin_clz(X); } +int ffs_(unsigned X) { return __builtin_ffs(X); } + +_ctz_: +bsfl4(%esp), %eax +ret +_clz_: +bsrl4(%esp), %eax +xorl$31, %eax +ret +_ffs_: +movl$-1, %edx +bsfl4(%esp), %eax +cmove %edx, %eax +addl$1, %eax +ret //===-===// @@ -1077,8 +1095,9 @@ define <4 x float> @test1(<4 x float> %V) { entry: -%tmp8 = shufflevector <4 x float> %V, <4 x float> undef, <4 x i32> < i32 3, i32 2, i32 1, i32 0 > ; <<4 x float>> [#uses=1] -%add = add <4 x float> %tmp8, %V; <<4 x float>> [#uses=1] +%tmp8 = shufflevector <4 x float> %V, <4 x float> undef, +<4 x i32> < i32 3, i32 2, i32 1, i32 0 > +%add = add <4 x float> %tmp8, %V ret <4 x float> %add } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r41022 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/load2.ll
Author: lattner Date: Sat Aug 11 13:48:48 2007 New Revision: 41022 URL: http://llvm.org/viewvc/llvm-project?rev=41022&view=rev Log: Transform a load from an undef/zero global into an undef/global even if we have complex pointer manipulation going on. This allows us to compile stuff like this: __m128i foo(__m128i x){ static const unsigned int c_0[4] = { 0, 0, 0, 0 }; __m128i v_Zero = _mm_loadu_si128((__m128i*)c_0); x = _mm_unpacklo_epi8(x, v_Zero); return x; } into: _foo: xorps %xmm1, %xmm1 punpcklbw %xmm1, %xmm0 ret Added: llvm/trunk/test/Transforms/InstCombine/load2.ll Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=41022&r1=41021&r2=41022&view=diff == --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Sat Aug 11 13:48:48 2007 @@ -8782,6 +8782,28 @@ return false; } +/// GetUnderlyingObject - Trace through a series of getelementptrs and bitcasts +/// until we find the underlying object a pointer is referring to or something +/// we don't understand. Note that the returned pointer may be offset from the +/// input, because we ignore GEP indices. +static Value *GetUnderlyingObject(Value *Ptr) { + while (1) { +if (ConstantExpr *CE = dyn_cast(Ptr)) { + if (CE->getOpcode() == Instruction::BitCast || + CE->getOpcode() == Instruction::GetElementPtr) +Ptr = CE->getOperand(0); + else +return Ptr; +} else if (BitCastInst *BCI = dyn_cast(Ptr)) { + Ptr = BCI->getOperand(0); +} else if (GetElementPtrInst *GEP = dyn_cast(Ptr)) { + Ptr = GEP->getOperand(0); +} else { + return Ptr; +} + } +} + Instruction *InstCombiner::visitLoadInst(LoadInst &LI) { Value *Op = LI.getOperand(0); @@ -8860,6 +8882,17 @@ return Res; } } + + // If this load comes from anywhere in a constant global, and if the global + // is all undef or zero, we know what it loads. + if (GlobalVariable *GV = dyn_cast(GetUnderlyingObject(Op))) { +if (GV->isConstant() && GV->hasInitializer()) { + if (GV->getInitializer()->isNullValue()) +return ReplaceInstUsesWith(LI, Constant::getNullValue(LI.getType())); + else if (isa(GV->getInitializer())) +return ReplaceInstUsesWith(LI, UndefValue::get(LI.getType())); +} + } if (Op->hasOneUse()) { // Change select and PHI nodes to select values instead of addresses: this Added: llvm/trunk/test/Transforms/InstCombine/load2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/load2.ll?rev=41022&view=auto == --- llvm/trunk/test/Transforms/InstCombine/load2.ll (added) +++ llvm/trunk/test/Transforms/InstCombine/load2.ll Sat Aug 11 13:48:48 2007 @@ -0,0 +1,11 @@ +; RUN: llvm-as < %s | opt -instcombine | llvm-dis | not grep load + [EMAIL PROTECTED] = internal constant [4 x i32] zeroinitializer + + +define <16 x i8> @foo(<2 x i64> %x) { +entry: + %tmp = load <16 x i8> * bitcast ([4 x i32]* @GLOBAL to <16 x i8>*) + ret <16 x i8> %tmp +} + ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r41023 - /llvm/trunk/lib/Analysis/ConstantFolding.cpp
Author: lattner Date: Sat Aug 11 18:49:01 2007 New Revision: 41023 URL: http://llvm.org/viewvc/llvm-project?rev=41023&view=rev Log: constant fold ptrtoint(inttoptr) with target data when available. This allows us to fold the entry block of PR1602 to false instead of: br i1 icmp eq (i32 and (i32 ptrtoint (void (%struct.S*)* inttoptr (i64 1 to void (%struct.S*)*) to i32), i32 1), i32 0), label %cond_next, label %cond_true Modified: llvm/trunk/lib/Analysis/ConstantFolding.cpp Modified: llvm/trunk/lib/Analysis/ConstantFolding.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ConstantFolding.cpp?rev=41023&r1=41022&r2=41023&view=diff == --- llvm/trunk/lib/Analysis/ConstantFolding.cpp (original) +++ llvm/trunk/lib/Analysis/ConstantFolding.cpp Sat Aug 11 18:49:01 2007 @@ -217,6 +217,23 @@ case Instruction::FCmp: return ConstantExpr::getCompare(cast(I)->getPredicate(), Ops[0], Ops[1]); + case Instruction::PtrToInt: +// If the input is a inttoptr, eliminate the pair. This requires knowing +// the width of a pointer, so it can't be done in ConstantExpr::getCast. +if (ConstantExpr *CE = dyn_cast(Ops[0])) { + if (TD && CE->getOpcode() == Instruction::IntToPtr) { +Constant *Input = CE->getOperand(0); +unsigned InWidth = Input->getType()->getPrimitiveSizeInBits(); +Constant *Mask = + ConstantInt::get(APInt::getLowBitsSet(InWidth, +TD->getPointerSizeInBits())); +Input = ConstantExpr::getAnd(Input, Mask); +// Do a zext or trunc to get to the dest size. +return ConstantExpr::getIntegerCast(Input, I->getType(), false); + } +} +// FALL THROUGH. + case Instruction::IntToPtr: case Instruction::Trunc: case Instruction::ZExt: case Instruction::SExt: @@ -226,8 +243,6 @@ case Instruction::SIToFP: case Instruction::FPToUI: case Instruction::FPToSI: - case Instruction::PtrToInt: - case Instruction::IntToPtr: case Instruction::BitCast: return ConstantExpr::getCast(Opc, Ops[0], DestTy); case Instruction::Select: ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r41024 - /llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp
Author: evancheng Date: Sat Aug 11 20:26:19 2007 New Revision: 41024 URL: http://llvm.org/viewvc/llvm-project?rev=41024&view=rev Log: No need to remove dead range from soon-to-be-dead live interval. Its val# may be out of whack. Modified: llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp Modified: llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp?rev=41024&r1=41023&r2=41024&view=diff == --- llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp (original) +++ llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp Sat Aug 11 20:26:19 2007 @@ -316,9 +316,9 @@ } if (isShorten || isDead) { - // Shorten the live interval. - LiveInterval &LiveInInt = (repSrcReg == DstInt.reg) ? DstInt : SrcInt; - LiveInInt.removeRange(RemoveStart, RemoveEnd); + // Shorten the destination live interval. + if (repSrcReg == DstInt.reg) +DstInt.removeRange(RemoveStart, RemoveEnd); } } else { // Coalescing failed. ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r41028 - /llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp
Author: reid Date: Sat Aug 11 23:45:36 2007 New Revision: 41028 URL: http://llvm.org/viewvc/llvm-project?rev=41028&view=rev Log: Remove unused variables. Modified: llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp Modified: llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp?rev=41028&r1=41027&r2=41028&view=diff == --- llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp Sat Aug 11 23:45:36 2007 @@ -621,12 +621,12 @@ if (L->contains(ExitDest)) ExitDest = ExitInsn->getSuccessor(0); assert (!L->contains(ExitDest) && " Unable to find exit edge destination"); - BasicBlock *ExitSplitBlock = SplitEdge(ExitBlock, ExitDest, this); + SplitEdge(ExitBlock, ExitDest, this); //[*] Clone loop. Avoid true destination of split condition and //the blocks dominated by true destination. DenseMap ValueMap; - Loop *FalseLoop = CloneLoop(L, LPM, LI, ValueMap, this); + CloneLoop(L, LPM, LI, ValueMap, this); //[*] True loops exit edge enters False loop. //[*] Eliminate split condition's false branch from True loop. ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits