Re: [llvm-commits] [llvm] r46397 - /llvm/trunk/test/CodeGen/PowerPC/2008-01-25-EmptyFunction.ll
On Jan 25, 2008, at 10:56 PM, Bill Wendling wrote: > Author: void > Date: Sat Jan 26 00:56:08 2008 > New Revision: 46397 > > URL: http://llvm.org/viewvc/llvm-project?rev=46397&view=rev > Log: > Need to convert to LLVM code and not C. This should also pass a darwin target triple to llc (or embed it in the .ll file), because ppc linux doesn't need the nop. It would also be nice to put a short comment in the test explaining why we expect a nop in this crazy case :) Thanks Bill, -Chris > > > Modified: >llvm/trunk/test/CodeGen/PowerPC/2008-01-25-EmptyFunction.ll > > Modified: llvm/trunk/test/CodeGen/PowerPC/2008-01-25-EmptyFunction.ll > URL: > http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/2008-01-25-EmptyFunction.ll?rev=46397&r1=46396&r2=46397&view=diff > > = > = > = > = > = > = > = > = > == > --- llvm/trunk/test/CodeGen/PowerPC/2008-01-25-EmptyFunction.ll > (original) > +++ llvm/trunk/test/CodeGen/PowerPC/2008-01-25-EmptyFunction.ll Sat > Jan 26 00:56:08 2008 > @@ -1,7 +1,6 @@ > -// RUN: %llvmgcc -O2 -S -o - -emit-llvm %s | grep llvm.trap > -// RUN: %llvmgcc -O2 -S -o - -emit-llvm %s | grep unreachable > +; RUN: llvm-as < %s | llc -march=ppc32 | grep nop > > -void bork() { > - int *address = 0; > - *address = 0; > +define void @bork() noreturn nounwind { > +entry: > +unreachable > } > > > ___ > llvm-commits mailing list > llvm-commits@cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] [llvm-gcc-4.2] r46373 - /llvm-gcc-4.2/trunk/gcc/llvm-types.cpp
On Jan 25, 2008, at 9:58 PM, Duncan Sands wrote: >> If a function takes a byval parameter, it can't be readnone, we >> have to mark it readonly instead. This fixes >> test/CFrontend/2008-01-25-ByValReadNone.c > > Thanks for doing this! No problem, thanks for pointing out that it needed to be done. It would be nice if globalsmodref inferred that functions which only store to their byval args are really readnone. -Chris ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] [llvm] r46394 - in /llvm/trunk/lib: Target/PowerPC/PPCAsmPrinter.cpp Transforms/Scalar/SimplifyCFG.cpp
On Jan 26, 2008, at 12:21 AM, Chris Lattner wrote: > > On Jan 25, 2008, at 10:51 PM, Bill Wendling wrote: > >> Author: void >> Date: Sat Jan 26 00:51:24 2008 >> New Revision: 46394 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=46394&view=rev >> Log: >> If there are no machine instructions emitted for a function, then >> insert >> a "nop" instruction so that we don't have the function's label >> associated >> with something that it's not supposed to be associated with. > > Thanks Bill, this is looking better. Some thoughts: > >> + // If the function is empty, then we need to emit *something*. >> Otherwise, the >> + // function's label might be associated with something that it >> wasn't meant to >> + // be associated with. We emit a noop in this situation. >> + MachineFunction::iterator I = MF.begin(); >> + >> + if (++I == MF.end()) { >> +MachineBasicBlock &MBB = MF.front(); >> + >> +if (MBB.begin() == MBB.end()) > > You can use MBB.empty() > Good point! >> >> + BuildMI(MBB, MBB.end(), TM.getInstrInfo()->get(PPC::NOP)); >> + } > > Is there any reason to actually make a machineinstr here? It seems > like it would be possible to just emit "nop" to the .s file. The JIT > doesn't need this. > I initially had that, but I thought that it would be better to do things though the "print machine instruction" function just so I got the syntax correct. But nop is probably safe to emit like that. > Also, I think this is required on x86 and arm as well, as they have > the same problem with -fomit-frame-pointer. > There's a nop for X86, but I don't see one for ARM in the .td file. > Thanks for working on this! > No problem. :-) -bw ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r46398 - in /llvm/trunk: lib/Target/PowerPC/PPCAsmPrinter.cpp lib/Target/X86/X86ATTAsmPrinter.cpp test/CodeGen/X86/2008-01-25-EmptyFunction.ll
Author: void Date: Sat Jan 26 03:03:52 2008 New Revision: 46398 URL: http://llvm.org/viewvc/llvm-project?rev=46398&view=rev Log: If there's no instructions being emitted on X86 for a function, emit a nop. Emit the nop directly for PPC. Added: llvm/trunk/test/CodeGen/X86/2008-01-25-EmptyFunction.ll Modified: llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp llvm/trunk/lib/Target/X86/X86ATTAsmPrinter.cpp Modified: llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp?rev=46398&r1=46397&r2=46398&view=diff == --- llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp Sat Jan 26 03:03:52 2008 @@ -819,12 +819,8 @@ // be associated with. We emit a noop in this situation. MachineFunction::iterator I = MF.begin(); - if (++I == MF.end()) { -MachineBasicBlock &MBB = MF.front(); - -if (MBB.begin() == MBB.end()) - BuildMI(MBB, MBB.end(), TM.getInstrInfo()->get(PPC::NOP)); - } + if (++I == MF.end() && MF.front().empty()) +O << "\tnop\n"; // Print out code for the function. for (MachineFunction::const_iterator I = MF.begin(), E = MF.end(); Modified: llvm/trunk/lib/Target/X86/X86ATTAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ATTAsmPrinter.cpp?rev=46398&r1=46397&r2=46398&view=diff == --- llvm/trunk/lib/Target/X86/X86ATTAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ATTAsmPrinter.cpp Sat Jan 26 03:03:52 2008 @@ -165,6 +165,16 @@ DW.BeginFunction(&MF); } + if (Subtarget->isTargetDarwin()) { +// If the function is empty, then we need to emit *something*. Otherwise, +// the function's label might be associated with something that it wasn't +// meant to be associated with. We emit a noop in this situation. +MachineFunction::iterator I = MF.begin(); + +if (++I == MF.end() && MF.front().empty()) + O << "\tnop\n"; + } + // Print out code for the function. for (MachineFunction::const_iterator I = MF.begin(), E = MF.end(); I != E; ++I) { @@ -173,8 +183,8 @@ printBasicBlockLabel(I, true); O << '\n'; } -for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end(); - II != E; ++II) { +for (MachineBasicBlock::const_iterator II = I->begin(), IE = I->end(); + II != IE; ++II) { // Print the assembly for the instruction. O << "\t"; printMachineInstruction(II); Added: llvm/trunk/test/CodeGen/X86/2008-01-25-EmptyFunction.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2008-01-25-EmptyFunction.ll?rev=46398&view=auto == --- llvm/trunk/test/CodeGen/X86/2008-01-25-EmptyFunction.ll (added) +++ llvm/trunk/test/CodeGen/X86/2008-01-25-EmptyFunction.ll Sat Jan 26 03:03:52 2008 @@ -0,0 +1,6 @@ +; RUN: llvm-as < %s | llc -march=x86 | grep nop + +define void @bork() noreturn nounwind { +entry: +unreachable +} ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] [llvm] r46394 - in /llvm/trunk/lib: Target/PowerPC/PPCAsmPrinter.cpp Transforms/Scalar/SimplifyCFG.cpp
On Jan 25, 2008, at 10:51 PM, Bill Wendling wrote: > Author: void > Date: Sat Jan 26 00:51:24 2008 > New Revision: 46394 > > URL: http://llvm.org/viewvc/llvm-project?rev=46394&view=rev > Log: > If there are no machine instructions emitted for a function, then > insert > a "nop" instruction so that we don't have the function's label > associated > with something that it's not supposed to be associated with. Thanks Bill, this is looking better. Some thoughts: > + // If the function is empty, then we need to emit *something*. > Otherwise, the > + // function's label might be associated with something that it > wasn't meant to > + // be associated with. We emit a noop in this situation. > + MachineFunction::iterator I = MF.begin(); > + > + if (++I == MF.end()) { > +MachineBasicBlock &MBB = MF.front(); > + > +if (MBB.begin() == MBB.end()) You can use MBB.empty() > > + BuildMI(MBB, MBB.end(), TM.getInstrInfo()->get(PPC::NOP)); > + } Is there any reason to actually make a machineinstr here? It seems like it would be possible to just emit "nop" to the .s file. The JIT doesn't need this. Also, I think this is required on x86 and arm as well, as they have the same problem with -fomit-frame-pointer. Thanks for working on this! -Chris ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] [llvm] r46393 - in /llvm/trunk: lib/Transforms/Utils/InlineFunction.cpp test/CFrontend/2008-01-26-ReadOnlyByVal.c
On Jan 25, 2008, at 10:41 PM, Duncan Sands wrote: > Author: baldrick > Date: Sat Jan 26 00:41:49 2008 > New Revision: 46393 > > URL: http://llvm.org/viewvc/llvm-project?rev=46393&view=rev > Log: > Create an explicit copy for byval parameters even > when inlining a readonly function. Are you sure this is correct? There is a difference between 'const', 'pure' and readnone/readonly. Further, isn't it always safe to elide the copy for readnone functions? -Chris > > > Added: >llvm/trunk/test/CFrontend/2008-01-26-ReadOnlyByVal.c > Modified: >llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp > > Modified: llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp > URL: > http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp?rev=46393&r1=46392&r2=46393&view=diff > > = > = > = > = > = > = > = > = > == > --- llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp (original) > +++ llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp Sat Jan 26 > 00:41:49 2008 > @@ -240,12 +240,15 @@ > E = CalledFunc->arg_end(); I != E; ++I, ++AI, ++ArgNo) { > Value *ActualArg = *AI; > > - // When byval arguments actually inlined, we need to make the > copy implied > - // by them explicit. However, we don't do this if the callee > is readonly > - // or readnone, because the copy would be unneeded: the > callee doesn't > - // modify the struct. > - if (CalledFunc->paramHasAttr(ArgNo+1, ParamAttr::ByVal) && > - !CalledFunc->onlyReadsMemory()) { > + // When byval arguments are inlined, we need to make the copy > implied > + // by them explicit. It is tempting to think that this is > not needed if > + // the callee is readonly, because the callee doesn't modify > the struct. > + // However this would be wrong: readonly means that any > writes the callee > + // performs are not visible to the caller. But writes by the > callee to > + // an argument passed byval are by definition not visible to > the caller! > + // Since we allow this kind of readonly function, there needs > to be an > + // explicit copy in order to keep the writes invisible after > inlining. > + if (CalledFunc->paramHasAttr(ArgNo+1, ParamAttr::ByVal)) { > const Type *AggTy = cast(I->getType())- > >getElementType(); > const Type *VoidPtrTy = PointerType::getUnqual(Type::Int8Ty); > > > Added: llvm/trunk/test/CFrontend/2008-01-26-ReadOnlyByVal.c > URL: > http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CFrontend/2008-01-26-ReadOnlyByVal.c?rev=46393&view=auto > > = > = > = > = > = > = > = > = > == > --- llvm/trunk/test/CFrontend/2008-01-26-ReadOnlyByVal.c (added) > +++ llvm/trunk/test/CFrontend/2008-01-26-ReadOnlyByVal.c Sat Jan 26 > 00:41:49 2008 > @@ -0,0 +1,19 @@ > +// RUN: %llvmgcc %s -S -O1 -o - | llvm-as | opt -std-compile-opts | > llvm-dis | not grep add > + > +struct S { int A; int B; int C; int D; }; > + > +int f(struct S x) __attribute__ ((const)); > + > +static int __attribute__ ((const)) g(struct S x) { > + x.A = x.B; > + return f(x); > +} > + > +int h(void) { > + struct S x; > + int r; > + x.A = 0; > + x.B = 9; > + r = g(x); > + return r + x.A; > +} > > > ___ > llvm-commits mailing list > llvm-commits@cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] [llvm-gcc-4.2] r46373 - /llvm-gcc-4.2/trunk/gcc/llvm-types.cpp
> No problem, thanks for pointing out that it needed to be done. It > would be nice if globalsmodref inferred that functions which only > store to their byval args are really readnone. I guess you mean readonly, since readnone+byval doesn't really work. D. ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] [llvm] r46393 - in /llvm/trunk: lib/Transforms/Utils/InlineFunction.cpp test/CFrontend/2008-01-26-ReadOnlyByVal.c
> > Create an explicit copy for byval parameters even > > when inlining a readonly function. > > Are you sure this is correct? There is a difference between 'const', > 'pure' and readnone/readonly. Further, isn't it always safe to elide > the copy for readnone functions? A readnone function could write to a byval parameter, using it as local storage (which it is). If you don't make an explicit copy when inlining, these become writes to the storage that the caller passed in. I'm pretty sure this is correct. D. ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r46399 - /llvm/trunk/test/Transforms/Inline/byval2.ll
Author: baldrick Date: Sat Jan 26 06:33:01 2008 New Revision: 46399 URL: http://llvm.org/viewvc/llvm-project?rev=46399&view=rev Log: Invert this test, because it is wrong if we allow readonly functions to use byval parameters as local storage (how much do we want this?). Modified: llvm/trunk/test/Transforms/Inline/byval2.ll Modified: llvm/trunk/test/Transforms/Inline/byval2.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/Inline/byval2.ll?rev=46399&r1=46398&r2=46399&view=diff == --- llvm/trunk/test/Transforms/Inline/byval2.ll (original) +++ llvm/trunk/test/Transforms/Inline/byval2.ll Sat Jan 26 06:33:01 2008 @@ -1,7 +1,7 @@ -; RUN: llvm-as < %s | opt -inline | llvm-dis | not grep {llvm.memcpy} +; RUN: llvm-as < %s | opt -inline | llvm-dis | grep {llvm.memcpy} -; Inlining a byval struct should NOT cause an explicit copy -; into an alloca if the function is readonly +; Inlining a byval struct should cause an explicit copy +; into an alloca even if the function is readonly %struct.ss = type { i32, i64 } @.str = internal constant [10 x i8] c"%d, %lld\0A\00" ; <[10 x i8]*> [#uses=1] ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] [llvm-testresults] Grawp-PIC i386 nightly tester results
On Jan 26, 2008, at 6:16 AM, Apache wrote: > > New Test Failures: > test/Transforms/Inline/byval2.ll [DEJAGNU] Hi Duncan, This is failing because inlining of readonly functions is making the memcpy after your change. Why is the memcpy needed here? Is this because stores to the byval argument are not counted as a write? We really need to pin down the semantics of byval and readonly/none. Getting a copy for this is a big bad change. What do you think? -Chris ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r46401 - in /llvm/trunk: lib/CodeGen/SelectionDAG/DAGCombiner.cpp test/CodeGen/X86/stack-align.ll
Author: lattner Date: Sat Jan 26 13:45:50 2008 New Revision: 46401 URL: http://llvm.org/viewvc/llvm-project?rev=46401&view=rev Log: Infer alignment of loads and increase their alignment when we can tell they are from the stack. This allows us to compile stack-align.ll to: _test: movsd LCPI1_0, %xmm0 movapd %xmm0, %xmm1 *** andpd 4(%esp), %xmm1 andpd _G, %xmm0 addsd %xmm1, %xmm0 movl20(%esp), %eax movsd %xmm0, (%eax) ret instead of: _test: movsd LCPI1_0, %xmm0 ** movsd 4(%esp), %xmm1 ** andpd %xmm0, %xmm1 andpd _G, %xmm0 addsd %xmm1, %xmm0 movl20(%esp), %eax movsd %xmm0, (%eax) ret Added: llvm/trunk/test/CodeGen/X86/stack-align.ll Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=46401&r1=46400&r2=46401&view=diff == --- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Sat Jan 26 13:45:50 2008 @@ -18,6 +18,7 @@ #include "llvm/CodeGen/MachineFrameInfo.h" #include "llvm/Analysis/AliasAnalysis.h" #include "llvm/Target/TargetData.h" +#include "llvm/Target/TargetFrameInfo.h" #include "llvm/Target/TargetLowering.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetOptions.h" @@ -4073,13 +4074,41 @@ static unsigned InferAlignment(SDOperand Ptr, SelectionDAG &DAG) { // If this is a direct reference to a stack slot, use information about the // stack slot's alignment. + int FrameIdx = 1 << 31; + int64_t FrameOffset = 0; if (FrameIndexSDNode *FI = dyn_cast(Ptr)) { -return DAG.getMachineFunction().getFrameInfo()-> - getObjectAlignment(FI->getIndex()); +FrameIdx = FI->getIndex(); + } else if (Ptr.getOpcode() == ISD::ADD && + isa(Ptr.getOperand(1)) && + isa(Ptr.getOperand(0))) { +FrameIdx = cast(Ptr.getOperand(0))->getIndex(); +FrameOffset = Ptr.getConstantOperandVal(1); + } + + if (FrameIdx != (1 << 31)) { +// FIXME: Handle FI+CST. +const MachineFrameInfo &MFI = *DAG.getMachineFunction().getFrameInfo(); +if (MFI.isFixedObjectIndex(FrameIdx)) { + int64_t ObjectOffset = MFI.getObjectOffset(FrameIdx); + + // The alignment of the frame index can be determined from its offset from + // the incoming frame position. If the frame object is at offset 32 and + // the stack is guaranteed to be 16-byte aligned, then we know that the + // object is 16-byte aligned. + unsigned StackAlign = DAG.getTarget().getFrameInfo()->getStackAlignment(); + unsigned Align = MinAlign(ObjectOffset, StackAlign); + + // Finally, the frame object itself may have a known alignment. Factor + // the alignment + offset into a new alignment. For example, if we know + // the FI is 8 byte aligned, but the pointer is 4 off, we really have a + // 4-byte alignment of the resultant pointer. Likewise align 4 + 4-byte + // offset = 4-byte alignment, align 4 + 1-byte offset = align 1, etc. + unsigned FIInfoAlign = MinAlign(MFI.getObjectAlignment(FrameIdx), + FrameOffset); + return std::max(Align, FIInfoAlign); +} } - // FIXME: Handle FI+CST. - return 0; } Added: llvm/trunk/test/CodeGen/X86/stack-align.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/stack-align.ll?rev=46401&view=auto == --- llvm/trunk/test/CodeGen/X86/stack-align.ll (added) +++ llvm/trunk/test/CodeGen/X86/stack-align.ll Sat Jan 26 13:45:50 2008 @@ -0,0 +1,22 @@ +; RUN: llvm-as < %s | llc -relocation-model=static -mcpu=yonah | grep {andpd.*4(%esp), %xmm} + +; The double argument is at 4(esp) which is 16-byte aligned, allowing us to +; fold the load into the andpd. + +target datalayout = "e-p:32:32:32-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-f80:128:128" +target triple = "i686-apple-darwin8" [EMAIL PROTECTED] = external global double + +define void @test({ double, double }* byval %z, double* %P) { +entry: + %tmp = getelementptr { double, double }* %z, i32 0, i32 0 ; [#uses=1] + %tmp1 = load double* %tmp, align 8 ; [#uses=1] + %tmp2 = tail call double @fabs( double %tmp1 ) ; [#uses=1] + %tmp3 = load double* @G, align 16 ; [#uses=1] + %tmp4 = tail call double @fabs( double %tmp3 ) ; [#uses=1] + %tmp6 = add double %tmp4, %tmp2 ; [#uses=1] + store double %tmp6, double* %P, align 8 + ret void +} + +declar
[llvm-commits] [llvm] r46400 - /llvm/trunk/test/CodeGen/X86/2007-08-10-LEA16Use32.ll
Author: lattner Date: Sat Jan 26 13:35:46 2008 New Revision: 46400 URL: http://llvm.org/viewvc/llvm-project?rev=46400&view=rev Log: remove a useless xfailed test. Removed: llvm/trunk/test/CodeGen/X86/2007-08-10-LEA16Use32.ll Removed: llvm/trunk/test/CodeGen/X86/2007-08-10-LEA16Use32.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2007-08-10-LEA16Use32.ll?rev=46399&view=auto == --- llvm/trunk/test/CodeGen/X86/2007-08-10-LEA16Use32.ll (original) +++ llvm/trunk/test/CodeGen/X86/2007-08-10-LEA16Use32.ll (removed) @@ -1,27 +0,0 @@ -; RUN: llvm-as < %s | llc -march=x86 | grep {leal} -; XFAIL: * -; This test is XFAIL'd because strength-reduction was improved to -; avoid emitting the lea, so it longer tests whether the 16-bit -; lea is avoided. - [EMAIL PROTECTED] = global i16 0 ; [#uses=1] [EMAIL PROTECTED] = global i16 0 ; [#uses=1] - -define void @_Z3fooi(i32 %N) { -entry: -%tmp1019 = icmp sgt i32 %N, 0 ; [#uses=1] -br i1 %tmp1019, label %bb, label %return - -bb: ; preds = %bb, %entry -%i.014.0 = phi i32 [ 0, %entry ], [ %indvar.next, %bb ] ; [#uses=2] -%tmp1 = trunc i32 %i.014.0 to i16 ; [#uses=2] -volatile store i16 %tmp1, i16* @X, align 2 -%tmp34 = shl i16 %tmp1, 2 ; [#uses=1] -volatile store i16 %tmp34, i16* @Y, align 2 -%indvar.next = add i32 %i.014.0, 1 ; [#uses=2] -%exitcond = icmp eq i32 %indvar.next, %N; [#uses=1] -br i1 %exitcond, label %return, label %bb - -return: ; preds = %bb, %entry -ret void -} ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r46402 - /llvm/trunk/include/llvm/Support/MathExtras.h
Author: lattner Date: Sat Jan 26 13:50:30 2008 New Revision: 46402 URL: http://llvm.org/viewvc/llvm-project?rev=46402&view=rev Log: make this 64-bit safe Modified: llvm/trunk/include/llvm/Support/MathExtras.h Modified: llvm/trunk/include/llvm/Support/MathExtras.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/MathExtras.h?rev=46402&r1=46401&r2=46402&view=diff == --- llvm/trunk/include/llvm/Support/MathExtras.h (original) +++ llvm/trunk/include/llvm/Support/MathExtras.h Sat Jan 26 13:50:30 2008 @@ -360,11 +360,11 @@ /// MinAlign - A and B are either alignments or offsets. Return the minimum /// alignment that may be assumed after adding the two together. -static inline unsigned MinAlign(unsigned A, unsigned B) { +static inline uint64_t MinAlign(uint64_t A, uint64_t B) { // The largest power of 2 that divides both A and B. return (A | B) & -(A | B); } - + } // End llvm namespace #endif ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r46403 - /llvm/trunk/test/CodeGen/X86/vec_align.ll
Author: lattner Date: Sat Jan 26 14:06:45 2008 New Revision: 46403 URL: http://llvm.org/viewvc/llvm-project?rev=46403&view=rev Log: New test to verify that "merging 4 loads into a vec load" continues to work and continues to infer alignment info. Added: llvm/trunk/test/CodeGen/X86/vec_align.ll Added: llvm/trunk/test/CodeGen/X86/vec_align.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/vec_align.ll?rev=46403&view=auto == --- llvm/trunk/test/CodeGen/X86/vec_align.ll (added) +++ llvm/trunk/test/CodeGen/X86/vec_align.ll Sat Jan 26 14:06:45 2008 @@ -0,0 +1,35 @@ +; RUN: llvm-as < %s | llc -mcpu=yonah -relocation-model=static | grep movaps | count 2 + +target datalayout = "e-p:32:32:32-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-f80:128:128" +target triple = "i686-apple-darwin8" + +%f4 = type <4 x float> + [EMAIL PROTECTED] = external global { float,float,float,float}, align 16 + +define %f4 @test1(float %W, float %X, float %Y, float %Z) { +%tmp = insertelement %f4 undef, float %W, i32 0 +%tmp2 = insertelement %f4 %tmp, float %X, i32 1 +%tmp4 = insertelement %f4 %tmp2, float %Y, i32 2 +%tmp6 = insertelement %f4 %tmp4, float %Z, i32 3 + ret %f4 %tmp6 +} + +define %f4 @test2() { + %Wp = getelementptr { float,float,float,float}* @G, i32 0, i32 0 + %Xp = getelementptr { float,float,float,float}* @G, i32 0, i32 1 + %Yp = getelementptr { float,float,float,float}* @G, i32 0, i32 2 + %Zp = getelementptr { float,float,float,float}* @G, i32 0, i32 3 + + %W = load float* %Wp + %X = load float* %Xp + %Y = load float* %Yp + %Z = load float* %Zp + +%tmp = insertelement %f4 undef, float %W, i32 0 +%tmp2 = insertelement %f4 %tmp, float %X, i32 1 +%tmp4 = insertelement %f4 %tmp2, float %Y, i32 2 +%tmp6 = insertelement %f4 %tmp4, float %Z, i32 3 + ret %f4 %tmp6 +} + ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r46404 - /llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
Author: lattner Date: Sat Jan 26 14:07:42 2008 New Revision: 46404 URL: http://llvm.org/viewvc/llvm-project?rev=46404&view=rev Log: Remove some code for inferring alignment info from the x86 backend now that the dag combiner does it. Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=46404&r1=46403&r2=46404&view=diff == --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Sat Jan 26 14:07:42 2008 @@ -5499,16 +5499,7 @@ int64_t Offset; if (isGAPlusOffset(Base, GV, Offset)) return (GV->getAlignment() >= 16 && (Offset % 16) == 0); - else { -assert(Base->getOpcode() == ISD::FrameIndex && "Unexpected base node!"); -int BFI = cast(Base)->getIndex(); -if (BFI < 0) - // Fixed objects do not specify alignment, however the offsets are known. - return ((Subtarget->getStackAlignment() % 16) == 0 && - (MFI->getObjectOffset(BFI) % 16) == 0); -else - return MFI->getObjectAlignment(BFI) >= 16; - } + // DAG combine handles the stack object case. return false; } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r46405 - /llvm/trunk/lib/Target/X86/README-SSE.txt
Author: lattner Date: Sat Jan 26 14:12:07 2008 New Revision: 46405 URL: http://llvm.org/viewvc/llvm-project?rev=46405&view=rev Log: Add some notes. Modified: llvm/trunk/lib/Target/X86/README-SSE.txt Modified: llvm/trunk/lib/Target/X86/README-SSE.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/README-SSE.txt?rev=46405&r1=46404&r2=46405&view=diff == --- llvm/trunk/lib/Target/X86/README-SSE.txt (original) +++ llvm/trunk/lib/Target/X86/README-SSE.txt Sat Jan 26 14:12:07 2008 @@ -704,3 +704,21 @@ We should use movmskp{s|d} instead. +//===-===// + +CodeGen/X86/vec_align.ll tests whether we can turn 4 scalar loads into a single +(aligned) vector load. This functionality has a couple of problems. + +1. The code to infer alignment from loads of globals is in the X86 backend, + not the dag combiner. This is because dagcombine2 needs to be able to see + through the X86ISD::Wrapper node, which DAGCombine can't really do. +2. The code for turning 4 x load into a single vector load is target + independent and should be moved to the dag combiner. +3. The code for turning 4 x load into a vector load can only handle a direct + load from a global or a direct load from the stack. It should be generalized + to handle any load from P, P+4, P+8, P+12, where P can be anything. +4. The alignment inference code cannot handle loads from globals in non-static + mode because it doesn't look through the extra dyld stub load. If you try + vec_align.ll without -relocation-model=static, you'll see what I mean. + +//===-===// ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] [llvm-gcc-4.2] r46381 - in /llvm-gcc-4.2/trunk/gcc: llvm-abi.h llvm-internal.h llvm-types.cpp
Can you get me a test case? I need to see what gcc is doing. Thanks, Evan On Jan 25, 2008, at 10:25 PM, Duncan Sands <[EMAIL PROTECTED]> wrote: > Hi Evan, dropping zero sized aggregates from types > http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20080121/057570.html > broke the Ada build. A zero-sized aggregate is used in a > COMPONENT_REF, so > llvm-convert barfs because it can't find the corresponding LLVM > field. All gcc > fields should have a corresponding LLVM field - the only exception > we make is > for fields at variable offsets. I would like to keep it that way > unless you > really can't solve this differently. > > Best wishes, > > Duncan. ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r46406 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/fpextend.ll
Author: lattner Date: Sat Jan 26 23:29:54 2008 New Revision: 46406 URL: http://llvm.org/viewvc/llvm-project?rev=46406&view=rev Log: Fold fptrunc(add (fpextend x), (fpextend y)) -> add(x,y), as GCC does. Added: llvm/trunk/test/Transforms/InstCombine/fpextend.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=46406&r1=46405&r2=46406&view=diff == --- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Sat Jan 26 23:29:54 2008 @@ -203,7 +203,7 @@ Instruction *visitTrunc(TruncInst &CI); Instruction *visitZExt(ZExtInst &CI); Instruction *visitSExt(SExtInst &CI); -Instruction *visitFPTrunc(CastInst &CI); +Instruction *visitFPTrunc(FPTruncInst &CI); Instruction *visitFPExt(CastInst &CI); Instruction *visitFPToUI(CastInst &CI); Instruction *visitFPToSI(CastInst &CI); @@ -7141,8 +7141,80 @@ return 0; } -Instruction *InstCombiner::visitFPTrunc(CastInst &CI) { - return commonCastTransforms(CI); +/// FitsInFPType - Return a Constant* for the specified FP constant if it fits +/// in the specified FP type without changing its value. +static Constant *FitsInFPType(ConstantFP *CFP, const Type *FPTy, + const fltSemantics &Sem) { + APFloat F = CFP->getValueAPF(); + if (F.convert(Sem, APFloat::rmNearestTiesToEven) == APFloat::opOK) +return ConstantFP::get(FPTy, F); + return 0; +} + +/// LookThroughFPExtensions - If this is an fp extension instruction, look +/// through it until we get the source value. +static Value *LookThroughFPExtensions(Value *V) { + if (Instruction *I = dyn_cast(V)) +if (I->getOpcode() == Instruction::FPExt) + return LookThroughFPExtensions(I->getOperand(0)); + + // If this value is a constant, return the constant in the smallest FP type + // that can accurately represent it. This allows us to turn + // (float)((double)X+2.0) into x+2.0f. + if (ConstantFP *CFP = dyn_cast(V)) { +if (CFP->getType() == Type::PPC_FP128Ty) + return V; // No constant folding of this. +// See if the value can be truncated to float and then reextended. +if (Value *V = FitsInFPType(CFP, Type::FloatTy, APFloat::IEEEsingle)) + return V; +if (CFP->getType() == Type::DoubleTy) + return V; // Won't shrink. +if (Value *V = FitsInFPType(CFP, Type::DoubleTy, APFloat::IEEEdouble)) + return V; +// Don't try to shrink to various long double types. + } + + return V; +} + +Instruction *InstCombiner::visitFPTrunc(FPTruncInst &CI) { + if (Instruction *I = commonCastTransforms(CI)) +return I; + + // If we have fptrunc(add (fpextend x), (fpextend y)), where x and y are + // smaller than the destination type, we can eliminate the truncate by doing + // the add as the smaller type. This applies to add/sub/mul/div as well as + // many builtins (sqrt, etc). + BinaryOperator *OpI = dyn_cast(CI.getOperand(0)); + if (OpI && OpI->hasOneUse()) { +switch (OpI->getOpcode()) { +default: break; +case Instruction::Add: +case Instruction::Sub: +case Instruction::Mul: +case Instruction::FDiv: +case Instruction::FRem: + const Type *SrcTy = OpI->getType(); + Value *LHSTrunc = LookThroughFPExtensions(OpI->getOperand(0)); + Value *RHSTrunc = LookThroughFPExtensions(OpI->getOperand(1)); + if (LHSTrunc->getType() != SrcTy && + RHSTrunc->getType() != SrcTy) { +unsigned DstSize = CI.getType()->getPrimitiveSizeInBits(); +// If the source types were both smaller than the destination type of +// the cast, do this xform. +if (LHSTrunc->getType()->getPrimitiveSizeInBits() <= DstSize && +RHSTrunc->getType()->getPrimitiveSizeInBits() <= DstSize) { + LHSTrunc = InsertCastBefore(Instruction::FPExt, LHSTrunc, + CI.getType(), CI); + RHSTrunc = InsertCastBefore(Instruction::FPExt, RHSTrunc, + CI.getType(), CI); + return BinaryOperator::create(OpI->getOpcode(), LHSTrunc, RHSTrunc); +} + } + break; +} + } + return 0; } Instruction *InstCombiner::visitFPExt(CastInst &CI) { Added: llvm/trunk/test/Transforms/InstCombine/fpextend.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/fpextend.ll?rev=46406&view=auto == --- llvm/trunk/test/Transforms/InstCombine/fpextend.ll (added) +++ llvm/trunk/test/Transforms/InstCombine/fpextend.ll Sat Jan 26 23:29:54 2008 @@ -0,0 +1,36 @@ +; RUN: llvm-as < %s | opt -instcombine | llvm-dis | not grep fpext
[llvm-commits] [llvm] r46407 - /llvm/trunk/lib/CodeGen/AsmPrinter.cpp
Author: lattner Date: Sun Jan 27 00:09:28 2008 New Revision: 46407 URL: http://llvm.org/viewvc/llvm-project?rev=46407&view=rev Log: For long double constants, print an approximation of their value to the .s file to make it easier to read. Modified: llvm/trunk/lib/CodeGen/AsmPrinter.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter.cpp?rev=46407&r1=46406&r2=46407&view=diff == --- llvm/trunk/lib/CodeGen/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter.cpp Sun Jan 27 00:09:28 2008 @@ -939,10 +939,13 @@ // api needed to prevent premature destruction APInt api = CFP->getValueAPF().convertToAPInt(); const uint64_t *p = api.getRawData(); + APFloat DoubleVal = CFP->getValueAPF(); + DoubleVal.convert(APFloat::IEEEdouble, APFloat::rmNearestTiesToEven); if (TD->isBigEndian()) { O << TAI->getData16bitsDirective() << uint16_t(p[0] >> 48) << "\t" << TAI->getCommentString() - << " long double most significant halfword\n"; + << " long double most significant halfword of ~" + << DoubleVal.convertToDouble() << "\n"; O << TAI->getData16bitsDirective() << uint16_t(p[0] >> 32) << "\t" << TAI->getCommentString() << " long double next halfword\n"; @@ -958,7 +961,8 @@ } else { O << TAI->getData16bitsDirective() << uint16_t(p[1]) << "\t" << TAI->getCommentString() - << " long double least significant halfword\n"; + << " long double least significant halfword of ~" + << DoubleVal.convertToDouble() << "\n"; O << TAI->getData16bitsDirective() << uint16_t(p[0]) << "\t" << TAI->getCommentString() << " long double next halfword\n"; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r46409 - /llvm/trunk/test/Transforms/CorrelatedExprs/
Author: void Date: Sun Jan 27 00:13:32 2008 New Revision: 46409 URL: http://llvm.org/viewvc/llvm-project?rev=46409&view=rev Log: The CorrelatedExpressions pass is now no more. Removed: llvm/trunk/test/Transforms/CorrelatedExprs/ ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r46410 - /llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h
Author: lattner Date: Sun Jan 27 00:19:08 2008 New Revision: 46410 URL: http://llvm.org/viewvc/llvm-project?rev=46410&view=rev Log: make isExactlyValue work for long double. Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h?rev=46410&r1=46409&r2=46410&view=diff == --- llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h (original) +++ llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h Sun Jan 27 00:19:08 2008 @@ -1208,10 +1208,9 @@ /// convenient to write "2.0" and the like. Without this function we'd /// have to duplicate its logic everywhere it's called. bool isExactlyValue(double V) const { -if (getValueType(0)==MVT::f64) - return isExactlyValue(APFloat(V)); -else - return isExactlyValue(APFloat((float)V)); +APFloat Tmp(V); +Tmp.convert(Value.getSemantics(), APFloat::rmNearestTiesToEven); +return isExactlyValue(Tmp); } bool isExactlyValue(const APFloat& V) const; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r46411 - /llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
Author: lattner Date: Sun Jan 27 00:19:31 2008 New Revision: 46411 URL: http://llvm.org/viewvc/llvm-project?rev=46411&view=rev Log: Use fldz and fld1 for long double constants instead of a constant pool load. Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=46411&r1=46410&r2=46411&view=diff == --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Sun Jan 27 00:19:31 2008 @@ -455,7 +455,20 @@ addRegisterClass(MVT::f80, X86::RFP80RegisterClass); setOperationAction(ISD::UNDEF, MVT::f80, Expand); setOperationAction(ISD::FCOPYSIGN, MVT::f80, Expand); - setOperationAction(ISD::ConstantFP, MVT::f80, Expand); + { +setOperationAction(ISD::ConstantFP, MVT::f80, Expand); +APFloat TmpFlt(+0.0); +TmpFlt.convert(APFloat::x87DoubleExtended, APFloat::rmNearestTiesToEven); +addLegalFPImmediate(TmpFlt); // FLD0 +TmpFlt.changeSign(); +addLegalFPImmediate(TmpFlt); // FLD0/FCHS +APFloat TmpFlt2(+1.0); +TmpFlt2.convert(APFloat::x87DoubleExtended, APFloat::rmNearestTiesToEven); +addLegalFPImmediate(TmpFlt2); // FLD1 +TmpFlt2.changeSign(); +addLegalFPImmediate(TmpFlt2); // FLD1/FCHS + } + if (!UnsafeFPMath) { setOperationAction(ISD::FSIN , MVT::f80 , Expand); setOperationAction(ISD::FCOS , MVT::f80 , Expand); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm-gcc-4.2] r46412 - in /llvm-gcc-4.2/trunk/gcc: config/i386/llvm-i386-target.h config/i386/llvm-i386.cpp llvm-abi.h llvm-convert.cpp
Author: lattner Date: Sun Jan 27 01:18:20 2008 New Revision: 46412 URL: http://llvm.org/viewvc/llvm-project?rev=46412&view=rev Log: Change x86-32 aggregate passing code to pass many aggregates "by pieces" instead of passing them with byval. This allows us to get significantly better code without affecting the ABI (because x86-32 passes stuff on the stack). Most significantly, we pass _Complex as a two scalar fp values now. For example, before we compiled ccosf to: _ccosf: pushl %ebp movl%esp, %ebp pushl %edi pushl %esi subl$16, %esp movss 12(%ebp), %xmm0 xorps LCPI1_0, %xmm0 movss 8(%ebp), %xmm1 movss %xmm0, -16(%ebp) movss %xmm1, -12(%ebp) leal-16(%ebp), %esi movl$2, %ecx movl%esp, %edi rep;movsl call_ccoshf addl$16, %esp popl%esi popl%edi popl%ebp ret now we get: _ccosf: pushl %ebp movl%esp, %ebp subl$8, %esp movss 8(%ebp), %xmm0 movss %xmm0, 4(%esp) movss 12(%ebp), %xmm0 xorps LCPI1_0, %xmm0 movss %xmm0, (%esp) call_ccoshf addl$8, %esp popl%ebp ret Evan, please review this. Thanks! Modified: llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386-target.h llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp llvm-gcc-4.2/trunk/gcc/llvm-abi.h llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Modified: llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386-target.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386-target.h?rev=46412&r1=46411&r2=46412&view=diff == --- llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386-target.h (original) +++ llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386-target.h Sun Jan 27 01:18:20 2008 @@ -62,20 +62,24 @@ } \ } -extern bool llvm_x86_should_pass_aggregate_in_memory(tree); +#ifdef LLVM_ABI_H +extern bool llvm_x86_should_pass_aggregate_in_memory(tree, const Type *); -#define LLVM_SHOULD_PASS_AGGREGATE_USING_BYVAL_ATTR(X) \ - llvm_x86_should_pass_aggregate_in_memory(X) +#define LLVM_SHOULD_PASS_AGGREGATE_USING_BYVAL_ATTR(X, TY) \ + llvm_x86_should_pass_aggregate_in_memory(X, TY) -#ifdef LLVM_ABI_H extern bool -llvm_x86_64_should_pass_aggregate_in_mixed_regs(tree, +llvm_x86_64_should_pass_aggregate_in_mixed_regs(tree, const Type *Ty, +std::vector&); +extern bool +llvm_x86_32_should_pass_aggregate_in_mixed_regs(tree, const Type *Ty, std::vector&); -#define LLVM_SHOULD_PASS_AGGREGATE_IN_MIXED_REGS(T, E) \ - (TARGET_64BIT && \ - llvm_x86_64_should_pass_aggregate_in_mixed_regs((T), (E))) +#define LLVM_SHOULD_PASS_AGGREGATE_IN_MIXED_REGS(T, TY, E)\ + (TARGET_64BIT ? \ + llvm_x86_64_should_pass_aggregate_in_mixed_regs((T), (TY), (E)) : \ + llvm_x86_32_should_pass_aggregate_in_mixed_regs((T), (TY), (E))) #endif /* LLVM_ABI_H */ /* LLVM LOCAL end (ENTIRE FILE!) */ Modified: llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp?rev=46412&r1=46411&r2=46412&view=diff == --- llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp Sun Jan 27 01:18:20 2008 @@ -691,7 +691,7 @@ /* Target hook for llvm-abi.h. It returns true if an aggregate of the specified type should be passed in memory. */ -bool llvm_x86_should_pass_aggregate_in_memory(tree TreeType) { +bool llvm_x86_should_pass_aggregate_in_memory(tree TreeType, const Type *Ty) { enum machine_mode Mode = ix86_getNaturalModeForType(TreeType); HOST_WIDE_INT Bytes = (Mode == BLKmode) ? int_size_in_bytes(TreeType) : (int) GET_MODE_SIZE(Mode); @@ -706,8 +706,10 @@ if (llvm_x86_is_all_integer_types(Ty)) return false; } - if (!TARGET_64BIT) -return true; + if (!TARGET_64BIT) { +std::vector Elts; +return !llvm_x86_32_should_pass_aggregate_in_mixed_regs(TreeType, Ty, Elts); + } return llvm_x86_64_should_pass_aggregate_in_memory(TreeType, Mode); } @@ -716,7 +718,7 @@ It also returns a vector of types that correspond to the registers used for parameter passing. This is only called for x86-64. */ bool -llvm_x86_64_should_pass_aggregate_in_mixed_regs(tree TreeType, +llvm_x86_64_should_pass_aggregate_in_mixed_regs(tree TreeType, const Type *Ty, std::vector &Elts){ enum
[llvm-commits] [llvm] r46413 - /llvm/trunk/lib/Target/X86/README-SSE.txt
Author: lattner Date: Sun Jan 27 01:31:41 2008 New Revision: 46413 URL: http://llvm.org/viewvc/llvm-project?rev=46413&view=rev Log: add a note Modified: llvm/trunk/lib/Target/X86/README-SSE.txt Modified: llvm/trunk/lib/Target/X86/README-SSE.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/README-SSE.txt?rev=46413&r1=46412&r2=46413&view=diff == --- llvm/trunk/lib/Target/X86/README-SSE.txt (original) +++ llvm/trunk/lib/Target/X86/README-SSE.txt Sun Jan 27 01:31:41 2008 @@ -722,3 +722,42 @@ vec_align.ll without -relocation-model=static, you'll see what I mean. //===-===// + +We should lower store(fneg(load p), q) into an integer load+xor+store, which +eliminates a constant pool load. For example, consider: + +define i64 @ccosf(float %z.0, float %z.1) nounwind readonly { +entry: + %tmp6 = sub float -0.00e+00, %z.1 ; [#uses=1] + %tmp20 = tail call i64 @ccoshf( float %tmp6, float %z.0 ) nounwind readonly ; [#uses=1] + ret i64 %tmp20 +} + +This currently compiles to: + +LCPI1_0: # <4 x float> + .long 2147483648 # float -0 + .long 2147483648 # float -0 + .long 2147483648 # float -0 + .long 2147483648 # float -0 +_ccosf: + subl$12, %esp + movss 16(%esp), %xmm0 + movss %xmm0, 4(%esp) + movss 20(%esp), %xmm0 + xorps LCPI1_0, %xmm0 + movss %xmm0, (%esp) + callL_ccoshf$stub + addl$12, %esp + ret + +Note the load into xmm0, then xor (to negate), then store. In PIC mode, +this code computes the pic base and does two loads to do the constant pool +load, so the improvement is much bigger. + +The tricky part about this xform is that the argument load/store isn't exposed +until post-legalize, and at that point, the fneg has been custom expanded into +an X86 fxor. This means that we need to handle this case in the x86 backend +instead of in target independent code. + +//===-===// ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits