Commit Graph

89 Commits

Author SHA1 Message Date
Chris Lattner
e9c35e7309 Implement expansion of unsigned i64 -> FP.
Note that this probably only works for little endian targets, but is enough
to get siod working :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21280 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-13 05:09:42 +00:00
Chris Lattner
ffe284c651 Make expansion of uint->fp cast assert out instead of infinitely recurse.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21275 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-13 03:42:14 +00:00
Chris Lattner
23993561e2 Instead of making ZERO_EXTEND_INREG nodes, use the helper method in
SelectionDAG to do the job with AND.  Don't legalize Z_E_I anymore as
it is gone


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21266 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-13 02:38:47 +00:00
Chris Lattner
1c51c6ac13 promote extload i1 -> extload i8
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21258 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-12 20:30:10 +00:00
Chris Lattner
5b95ed652f Emit comparisons against the sign bit better. Codegen this:
bool %test1(long %X) {
        %A = setlt long %X, 0
        ret bool %A
}

like this:

test1:
        cmpl $0, 8(%esp)
        setl %al
        movzbl %al, %eax
        ret

instead of:

test1:
        movl 8(%esp), %ecx
        cmpl $0, %ecx
        setl %al
        movzbw %al, %ax
        cmpl $0, 4(%esp)
        setb %dl
        movzbw %dl, %dx
        cmpl $0, %ecx
        cmove %dx, %ax
        movzbl %al, %eax
        ret


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21243 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-12 02:19:10 +00:00
Chris Lattner
08b698e38d Emit long comparison against -1 better. Instead of this (x86):
test2:
        movl 8(%esp), %eax
        notl %eax
        movl 4(%esp), %ecx
        notl %ecx
        orl %eax, %ecx
        cmpl $0, %ecx
        sete %al
        movzbl %al, %eax
        ret

or this (PPC):

_test2:
        nor r2, r4, r4
        nor r3, r3, r3
        or r2, r2, r3
        cntlzw r2, r2
        srwi r3, r2, 5
        blr

Emit this:

test2:
        movl 8(%esp), %eax
        andl 4(%esp), %eax
        cmpl $-1, %eax
        sete %al
        movzbl %al, %eax
        ret

or this:

_test2:
.LBB_test2_0:   ;
        and r2, r4, r3
        cmpwi cr0, r2, -1
        li r3, 1
        li r2, 0
        beq .LBB_test2_2        ;
.LBB_test2_1:   ;
        or r3, r2, r2
.LBB_test2_2:   ;
        blr

it seems like the PPC isel could do better for R32 == -1 case.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21242 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-12 01:46:05 +00:00
Chris Lattner
bd0781ed12 Teach the dag mechanism that this:
long long test2(unsigned A, unsigned B) {
        return ((unsigned long long)A << 32) + B;
}

is equivalent to this:

long long test1(unsigned A, unsigned B) {
        return ((unsigned long long)A << 32) | B;
}

Now they are both codegen'd to this on ppc:

_test2:
        blr

or this on x86:

test2:
        movl 4(%esp), %edx
        movl 8(%esp), %eax
        ret


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21231 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-11 20:29:59 +00:00
Chris Lattner
ee27f57a6a Fix expansion of shifts by exactly NVT bits on arch's (like X86) that have
masking shifts.

This fixes the miscompilation of this:

long long test1(unsigned A, unsigned B) {
        return ((unsigned long long)A << 32) | B;
}

into this:

test1:
        movl 4(%esp), %edx
        movl %edx, %eax
        orl 8(%esp), %eax
        ret

allowing us to generate this instead:

test1:
        movl 4(%esp), %edx
        movl 8(%esp), %eax
        ret


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21230 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-11 20:08:52 +00:00
Nate Begeman
c7c16575fe Fix libcall code to not pass a NULL Chain to LowerCallTo
Fix libcall code to not crash or assert looking for an ADJCALLSTACKUP node
  when it is known that there is no ADJCALLSTACKDOWN to match.
Expand i64 multiply when ISD::MULHU is legal for the target.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21214 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-11 03:01:51 +00:00
Chris Lattner
01ff7216dd Teach legalize to deal with targets that don't support some SEXTLOAD/ZEXTLOADs
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21212 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-10 22:54:25 +00:00
Chris Lattner
6841dec8c1 don't zextload fp values!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21209 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-10 17:40:35 +00:00
Chris Lattner
232ee95a09 Until we have a dag combiner, promote using zextload's instead of extloads.
This gives the optimizer a bit of information about the top-part of the
value.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21205 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-10 04:33:47 +00:00
Chris Lattner
dea29e25c3 Fix a thinko. If the operand is promoted, pass the promoted value into
the new zero extend, not the original operand.  This fixes cast bool -> long
on ppc.

Add an unrelated fixme


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21196 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-10 01:13:15 +00:00
Chris Lattner
411e888c1b Legalize BRCONDTWOWAY into a BRCOND/BR pair if a target doesn't support it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21166 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-09 03:30:19 +00:00
Nate Begeman
f1fe32e337 Teach ExpandShift how to handle shifts by a constant. This allows targets
like PowerPC to codegen long shifts in many fewer instructions.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21122 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-06 21:13:14 +00:00
Nate Begeman
c105e19864 Expand SREM and UREM for targets that claim not to have them, like PowerPC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21103 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-06 00:23:54 +00:00
Nate Begeman
79e46acd35 Handle expanding arguments to ISD::TRUNCATE. This happens on PowerPC when
you have something like i16 = truncate i64.  This fixes Regression/C/casts


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21073 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-04 00:57:08 +00:00
Chris Lattner
06098e0e9b Fix sign_extend and zero_extend of promoted value types to expanded value
types.  This occurs when casting short to long on PPC for example.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21072 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-03 23:41:52 +00:00
Chris Lattner
4af6e0d783 Expand fabs into fneg
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21013 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-02 05:26:37 +00:00
Chris Lattner
2c8086f4b9 Several changes mixed up here. First when legalizing a DAG with pcmarker,
dont' regen the whole dag if unneccesary.  Second, fix and ugly bug with
the _PARTS nodes that caused legalize to produce multiples of them.
Finally, implement initial support for FABS and FNEG.  Currently FNEG is
the only one to be trusted though.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21009 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-02 05:00:07 +00:00
Chris Lattner
5b359c6c4f fix some bugs in the implementation of SHL_PARTS and friends.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21004 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-02 04:00:59 +00:00
Chris Lattner
4759982a2d Turn expanded shift operations into (e.g.) SHL_PARTS if the target supports it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21002 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-02 03:38:53 +00:00
Chris Lattner
f4b457987f Fix a bug when inserting a libcall into a function with no other calls.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20999 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-02 03:22:40 +00:00
Nate Begeman
ea19cd51aa Fix a warning about an unhandled switch case
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20994 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-02 00:41:14 +00:00
Nate Begeman
fc1b1dad88 Add ISD::UNDEF node
Teach the SelectionDAG code how to expand and promote it
Have PPC32 LowerCallTo generate ISD::UNDEF for int arg regs used up by fp
  arguments, but not shadowing their value.  This allows us to do the right
  thing with both fixed and vararg floating point arguments.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20988 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-01 22:34:39 +00:00
Andrew Lenharth
95762124a1 PCMarker support for DAG and Alpha
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20965 91177308-0d34-0410-b5e6-96231b3b80d8
2005-03-31 21:24:06 +00:00
Chris Lattner
d4e50bb2e2 implement legalization of build_pair for nate
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20901 91177308-0d34-0410-b5e6-96231b3b80d8
2005-03-28 22:03:13 +00:00
Nate Begeman
8e21e71b24 Change interface to LowerCallTo to take a boolean isVarArg argument.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20842 91177308-0d34-0410-b5e6-96231b3b80d8
2005-03-26 01:29:23 +00:00
Chris Lattner
84734ce8ef Fix a bug in the 'store fpimm, ptr' -> 'store intimm, ptr' handling code.
Changing 'op' here caused us to not enter the store into a map, causing
reemission of the code!!  In practice, a simple loop like this:

no_exit:                ; preds = %no_exit, %entry
        %indvar = phi uint [ %indvar.next, %no_exit ], [ 0, %entry ]            ; <uint> [#uses=3]
        %tmp.4 = getelementptr "complex long double"* %P, uint %indvar, uint 0          ; <double*> [#uses=1]
        store double 0.000000e+00, double* %tmp.4
        %indvar.next = add uint %indvar, 1              ; <uint> [#uses=2]
        %exitcond = seteq uint %indvar.next, %N         ; <bool> [#uses=1]
        br bool %exitcond, label %return, label %no_exit

was being code gen'd to:

.LBBtest_1:     # no_exit
        movl %edx, %esi
        shll $4, %esi
        movl $0, 4(%eax,%esi)
        movl $0, (%eax,%esi)
        incl %edx
        movl $0, (%eax,%esi)
        movl $0, 4(%eax,%esi)
        cmpl %ecx, %edx
        jne .LBBtest_1  # no_exit

Note that we are doing 4 32-bit stores instead of 2.  Now we generate:

.LBBtest_1:     # no_exit
        movl %edx, %esi
        incl %esi
        shll $4, %edx
        movl $0, (%eax,%edx)
        movl $0, 4(%eax,%edx)
        cmpl %ecx, %esi
        movl %esi, %edx
        jne .LBBtest_1  # no_exit

This is much happier, though it would be even better if the increment of ESI
was scheduled after the compare :-/


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20265 91177308-0d34-0410-b5e6-96231b3b80d8
2005-02-22 07:23:39 +00:00
Chris Lattner
595dc5408a Fix a case where were incorrectly compiled cast from short to int on 64-bit
targets.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20030 91177308-0d34-0410-b5e6-96231b3b80d8
2005-02-04 18:39:19 +00:00
Chris Lattner
272455b404 Fix yet another memset issue.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19986 91177308-0d34-0410-b5e6-96231b3b80d8
2005-02-02 03:44:41 +00:00
Chris Lattner
deb692e756 Fix some bugs andrew noticed legalizing memset for alpha
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19969 91177308-0d34-0410-b5e6-96231b3b80d8
2005-02-01 18:38:28 +00:00
Chris Lattner
99939d39c9 Alpha doesn't have a native f32 extload instruction.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19880 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-28 22:58:25 +00:00
Chris Lattner
e76ad6de40 implement legalization of truncates whose results and sources need to be
truncated, e.g. (truncate:i8 something:i16) on a 32 or 64-bit RISC.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19879 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-28 22:52:50 +00:00
Chris Lattner
e560521f1a Get alpha working with memset/memcpy/memmove
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19878 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-28 22:29:18 +00:00
Chris Lattner
13c184de29 CopyFromReg produces two values. Make sure that we remember that both are
legalized, and actually return the correct result when we legalize the chain first.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19866 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-28 06:27:38 +00:00
Chris Lattner
fed5577066 Silence optimized warnings.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19797 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-23 23:19:44 +00:00
Chris Lattner
9c32d3b798 Adjust to changes in SelectionDAG interfaces
The first half of correct chain insertion for libcalls. This is not enough
to fix Fhourstones yet though.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19781 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-23 04:42:50 +00:00
Chris Lattner
27ff112948 Fix problems with non-x86 targets.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19738 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-22 00:31:52 +00:00
Chris Lattner
77e77a6aa0 Refactor libcall code a bit. Initial implementation of expanding int -> FP
operations for 64-bit integers.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19724 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-21 06:05:23 +00:00
Chris Lattner
e5544f851a Simplify the shift-expansion code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19721 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-20 20:29:23 +00:00
Chris Lattner
84f6788044 Expand add/sub into ADD_PARTS/SUB_PARTS instead of a non-existant libcall.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19715 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-20 18:52:28 +00:00
Chris Lattner
3d9dffc586 Add support for targets that pass args in registers to calls.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19703 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-19 20:24:35 +00:00
Chris Lattner
1e81b9e511 Fold single use token factor nodes into other token factor nodes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19701 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-19 19:10:54 +00:00
Chris Lattner
ec39a45bdb Realize the individual pieces of an expanded copytoreg/store/load are
independent of each other.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19700 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-19 18:02:17 +00:00
Chris Lattner
e34b396ab7 Implement a way of expanding shifts. This applies to targets that offer
select operations or to shifts that are by a constant.  This automatically
implements (with no special code) all of the special cases for shift by 32,
shift by < 32 and shift by > 32.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19679 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-19 04:19:40 +00:00
Chris Lattner
d5d5682512 Zero is cheaper than sign extend.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19675 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-18 21:57:59 +00:00
Chris Lattner
47e9223e06 Fix some fixmes (promoting bools for select and brcond), fix promotion
of zero and sign extends.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19671 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-18 19:27:06 +00:00
Chris Lattner
ef5cd1d3cf Teach legalize to promote copy(from|to)reg, instead of making the isel pass
do it.  This results in better code on X86 for floats (because if strict
precision is not required, we can elide some more expensive double -> float
conversions like the old isel did), and allows other targets to emit
CopyFromRegs that are not legal for arguments.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19668 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-18 17:54:55 +00:00
Chris Lattner
82fbfb6984 Teach legalize to promote SetCC results.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19657 91177308-0d34-0410-b5e6-96231b3b80d8
2005-01-18 02:59:52 +00:00