Commit Graph

1815 Commits

Author SHA1 Message Date
Chris Lattner
495a0b5191 Add a new beta option for critical edge splitting, to avoid a problem that
Nate noticed in yacr2 (and I know occurs in other places as well).

This is still rough, as the critical edge blocks are not intelligently placed
but is added to get some idea to see if this improves performance.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22825 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-17 06:37:43 +00:00
Chris Lattner
fae59b99b8 Fix a regression on X86, where FP values can be promoted too.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22822 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-17 06:06:25 +00:00
Jim Laskey
6269ed125f Added generic code expansion for [signed|unsigned] i32 to [f32|f64] casts in the
legalizer.  PowerPC now uses this expansion instead of ISel version.

Example:

// signed integer to double conversion
double f1(signed x) {
  return (double)x;
}

// unsigned integer to double conversion
double f2(unsigned x) {
  return (double)x;
}

// signed integer to float conversion
float f3(signed x) {
  return (float)x;
}

// unsigned integer to float conversion
float f4(unsigned x) {
  return (float)x;
}


Byte Code:

internal fastcc double %_Z2f1i(int %x) {
entry:
        %tmp.1 = cast int %x to double          ; <double> [#uses=1]
        ret double %tmp.1
}

internal fastcc double %_Z2f2j(uint %x) {
entry:
        %tmp.1 = cast uint %x to double         ; <double> [#uses=1]
        ret double %tmp.1
}

internal fastcc float %_Z2f3i(int %x) {
entry:
        %tmp.1 = cast int %x to float           ; <float> [#uses=1]
        ret float %tmp.1
}

internal fastcc float %_Z2f4j(uint %x) {
entry:
        %tmp.1 = cast uint %x to float          ; <float> [#uses=1]
        ret float %tmp.1
}

internal fastcc double %_Z2g1i(int %x) {
entry:
        %buffer = alloca [2 x uint]             ; <[2 x uint]*> [#uses=3]
        %tmp.0 = getelementptr [2 x uint]* %buffer, int 0, int 0                ; <uint*> [#uses=1]
        store uint 1127219200, uint* %tmp.0
        %tmp.2 = cast int %x to uint            ; <uint> [#uses=1]
        %tmp.3 = xor uint %tmp.2, 2147483648            ; <uint> [#uses=1]
        %tmp.5 = getelementptr [2 x uint]* %buffer, int 0, int 1                ; <uint*> [#uses=1]
        store uint %tmp.3, uint* %tmp.5
        %tmp.9 = cast [2 x uint]* %buffer to double*            ; <double*> [#uses=1]
        %tmp.10 = load double* %tmp.9           ; <double> [#uses=1]
        %tmp.13 = load double* cast (long* %signed_bias to double*)             ; <double> [#uses=1]
        %tmp.14 = sub double %tmp.10, %tmp.13           ; <double> [#uses=1]
        ret double %tmp.14
}

internal fastcc double %_Z2g2j(uint %x) {
entry:
        %buffer = alloca [2 x uint]             ; <[2 x uint]*> [#uses=3]
        %tmp.0 = getelementptr [2 x uint]* %buffer, int 0, int 0                ; <uint*> [#uses=1]
        store uint 1127219200, uint* %tmp.0
        %tmp.1 = getelementptr [2 x uint]* %buffer, int 0, int 1                ; <uint*> [#uses=1]
        store uint %x, uint* %tmp.1
        %tmp.4 = cast [2 x uint]* %buffer to double*            ; <double*> [#uses=1]
        %tmp.5 = load double* %tmp.4            ; <double> [#uses=1]
        %tmp.8 = load double* cast (long* %unsigned_bias to double*)            ; <double> [#uses=1]
        %tmp.9 = sub double %tmp.5, %tmp.8              ; <double> [#uses=1]
        ret double %tmp.9
}

internal fastcc float %_Z2g3i(int %x) {
entry:
        %buffer = alloca [2 x uint]             ; <[2 x uint]*> [#uses=3]
        %tmp.0 = getelementptr [2 x uint]* %buffer, int 0, int 0                ; <uint*> [#uses=1]
        store uint 1127219200, uint* %tmp.0
        %tmp.2 = cast int %x to uint            ; <uint> [#uses=1]
        %tmp.3 = xor uint %tmp.2, 2147483648            ; <uint> [#uses=1]
        %tmp.5 = getelementptr [2 x uint]* %buffer, int 0, int 1                ; <uint*> [#uses=1]
        store uint %tmp.3, uint* %tmp.5
        %tmp.9 = cast [2 x uint]* %buffer to double*            ; <double*> [#uses=1]
        %tmp.10 = load double* %tmp.9           ; <double> [#uses=1]
        %tmp.13 = load double* cast (long* %signed_bias to double*)             ; <double> [#uses=1]
        %tmp.14 = sub double %tmp.10, %tmp.13           ; <double> [#uses=1]
        %tmp.16 = cast double %tmp.14 to float          ; <float> [#uses=1]
        ret float %tmp.16
}

internal fastcc float %_Z2g4j(uint %x) {
entry:
        %buffer = alloca [2 x uint]             ; <[2 x uint]*> [#uses=3]
        %tmp.0 = getelementptr [2 x uint]* %buffer, int 0, int 0                ; <uint*> [#uses=1]
        store uint 1127219200, uint* %tmp.0
        %tmp.1 = getelementptr [2 x uint]* %buffer, int 0, int 1                ; <uint*> [#uses=1]
        store uint %x, uint* %tmp.1
        %tmp.4 = cast [2 x uint]* %buffer to double*            ; <double*> [#uses=1]
        %tmp.5 = load double* %tmp.4            ; <double> [#uses=1]
        %tmp.8 = load double* cast (long* %unsigned_bias to double*)            ; <double> [#uses=1]
        %tmp.9 = sub double %tmp.5, %tmp.8              ; <double> [#uses=1]
        %tmp.11 = cast double %tmp.9 to float           ; <float> [#uses=1]
        ret float %tmp.11
}


PowerPC Code:

        .machine ppc970


        .const
        .align  2
.CPIl1__Z2f1i_0:                                        ; float 0x4330000080000000
        .long   1501560836      ; float 4.5036e+15
        .text
        .align  2
        .globl  l1__Z2f1i
l1__Z2f1i:
.LBBl1__Z2f1i_0:        ; entry
        xoris r2, r3, 32768
        stw r2, -4(r1)
        lis r2, 17200
        stw r2, -8(r1)
        lfd f0, -8(r1)
        lis r2, ha16(.CPIl1__Z2f1i_0)
        lfs f1, lo16(.CPIl1__Z2f1i_0)(r2)
        fsub f1, f0, f1
        blr


        .const
        .align  2
.CPIl2__Z2f2j_0:                                        ; float 0x4330000000000000
        .long   1501560832      ; float 4.5036e+15
        .text
        .align  2
        .globl  l2__Z2f2j
l2__Z2f2j:
.LBBl2__Z2f2j_0:        ; entry
        stw r3, -4(r1)
        lis r2, 17200
        stw r2, -8(r1)
        lfd f0, -8(r1)
        lis r2, ha16(.CPIl2__Z2f2j_0)
        lfs f1, lo16(.CPIl2__Z2f2j_0)(r2)
        fsub f1, f0, f1
        blr


        .const
        .align  2
.CPIl3__Z2f3i_0:                                        ; float 0x4330000080000000
        .long   1501560836      ; float 4.5036e+15
        .text
        .align  2
        .globl  l3__Z2f3i
l3__Z2f3i:
.LBBl3__Z2f3i_0:        ; entry
        xoris r2, r3, 32768
        stw r2, -4(r1)
        lis r2, 17200
        stw r2, -8(r1)
        lfd f0, -8(r1)
        lis r2, ha16(.CPIl3__Z2f3i_0)
        lfs f1, lo16(.CPIl3__Z2f3i_0)(r2)
        fsub f0, f0, f1
        frsp f1, f0
        blr


        .const
        .align  2
.CPIl4__Z2f4j_0:                                        ; float 0x4330000000000000
        .long   1501560832      ; float 4.5036e+15
        .text
        .align  2
        .globl  l4__Z2f4j
l4__Z2f4j:
.LBBl4__Z2f4j_0:        ; entry
        stw r3, -4(r1)
        lis r2, 17200
        stw r2, -8(r1)
        lfd f0, -8(r1)
        lis r2, ha16(.CPIl4__Z2f4j_0)
        lfs f1, lo16(.CPIl4__Z2f4j_0)(r2)
        fsub f0, f0, f1
        frsp f1, f0
        blr


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22814 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-17 00:39:29 +00:00
Chris Lattner
37bfbb47de add a new TargetConstant node
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22813 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-17 00:34:06 +00:00
Chris Lattner
d5d0f9bd20 Eliminate the RegSDNode class, which 3 nodes (CopyFromReg/CopyToReg/ImplicitDef)
used to tack a register number onto the node.

Instead of doing this, make a new node, RegisterSDNode, which is a leaf
containing a register number.  These three operations just become normal
DAG nodes now, instead of requiring special handling.

Note that with this change, it is no longer correct to make illegal
CopyFromReg/CopyToReg nodes.  The legalizer will not touch them, and this
is bad, so don't do it. :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22806 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-16 21:55:35 +00:00
Nate Begeman
7cbd525ba8 Implement BR_CC and BRTWOWAY_CC. This allows the removal of a rather nasty
fixme from the PowerPC backend.  Emit slightly better code for legalizing
select_cc.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22805 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-16 19:49:35 +00:00
Chris Lattner
f3e133a35f Allow passing a dag into dump and getOperationName. If one is available
when printing a node, use it to render target operations with their
target instruction name instead of "<<unknown>>".


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22804 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-16 18:33:07 +00:00
Chris Lattner
ad95d6ab20 Use a extant helper to do this.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22802 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-16 18:31:23 +00:00
Chris Lattner
149c58ce0b Add some methods for dag->dag isel.
Split RemoveNodeFromCSEMaps out of DeleteNodesIfDead to do it.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22801 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-16 18:17:10 +00:00
Nate Begeman
2d56e72f09 Fix last night's PPC32 regressions by
1. Not selecting the false value of a select_cc in the false arm, which
   isn't legal for nested selects.
2. Actually returning the node we created and Legalized in the FP_TO_UINT
   Expander.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22789 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-14 18:38:32 +00:00
Nate Begeman
d2558e3e4a Teach the legalizer how to legalize FP_TO_UINT.
Teach the legalizer to promote FP_TO_UINT to FP_TO_SINT if the wider
  FP_TO_UINT is also illegal.  This allows us on PPC to codegen
  unsigned short foo(float a) { return a; }

as:
_foo:
.LBB_foo_0:     ; entry
        fctiwz f0, f1
        stfd f0, -8(r1)
        lwz r2, -4(r1)
        rlwinm r3, r2, 0, 16, 31
        blr

instead of:
_foo:
.LBB_foo_0:     ; entry
        fctiwz f0, f1
        stfd f0, -8(r1)
        lwz r2, -4(r1)
        lis r3, ha16(.CPI_foo_0)
        lfs f0, lo16(.CPI_foo_0)(r3)
        fcmpu cr0, f1, f0
        blt .LBB_foo_2  ; entry
.LBB_foo_1:     ; entry
        fsubs f0, f1, f0
        fctiwz f0, f0
        stfd f0, -16(r1)
        lwz r2, -12(r1)
        xoris r2, r2, 32768
.LBB_foo_2:     ; entry
        rlwinm r3, r2, 0, 16, 31
        blr


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22785 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-14 01:20:53 +00:00
Nate Begeman
ff66368a5f Remove an unncessary argument to SimplifySelectCC and add an additional
assert when creating a select_cc node.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22780 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-13 06:14:17 +00:00
Nate Begeman
32c392a3a5 Fix the fabs regression on x86 by abstracting the select_cc optimization
out into SimplifySelectCC.  This allows both ISD::SELECT and ISD::SELECT_CC
to use the same set of simplifying folds.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22779 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-13 06:00:21 +00:00
Chris Lattner
3e27b1f5c4 implement a couple of simple shift foldings.
e.g.  (X & 7) >> 3   -> 0


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22774 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-12 23:54:58 +00:00
Nate Begeman
e1fae4a3ae Add a select_cc optimization for recognizing abs(int). This speeds up an
integer MPEG encoding loop by a factor of two.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22758 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-11 02:18:13 +00:00
Nate Begeman
e5d63829fd Some SELECT_CC cleanups:
1. move assertions for node creation to getNode()
2. legalize the values returned in ExpandOp immediately
3. Move select_cc optimizations from SELECT's getNode() to SELECT_CC's,
   allowing them to be cleaned up significantly.

This paves the way to pick up additional optimizations on SELECT_CC, such
as sum-of-absolute-differences.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22757 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-11 01:12:20 +00:00
Nate Begeman
9373a81e53 Add new node, SELECT_CC. This node is for targets that don't natively
implement SELECT.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22755 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-10 20:51:12 +00:00
Chris Lattner
7c6e452d44 Fix an oversight that may be causing PR617.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22753 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-10 17:37:53 +00:00
Chris Lattner
bd8625b062 Fix spelling, fix some broken canonicalizations by my last patch
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22734 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-09 23:09:05 +00:00
Chris Lattner
079a27a0de add cc nodes to the AllNodes list so they show up in Graphviz output
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22731 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-09 20:40:02 +00:00
Chris Lattner
7cf7e3f33f Eliminate the SetCCSDNode in favor of a CondCodeSDNode class. This pulls the
CC out of the SetCC operation, making SETCC a standard ternary operation and
CC's a standard DAG leaf.  This will make it possible for other node to use
CC's as operands in the future...


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22728 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-09 20:20:18 +00:00
Chris Lattner
660538c8a5 Handle 64-bit constant exprs on 64-bit targets.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22696 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-08 04:26:32 +00:00
Chris Lattner
bf3fa976ee add a small simplification that can be exposed after promotion/expansion
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22691 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-07 05:00:44 +00:00
Chris Lattner
82299e7097 Change FindEarliestCallSeqEnd (used by libcall insertion) to use a set to
avoid revisiting nodes more than once.  This eliminates a source of
potentially exponential behavior.  For a small function in 191.fma3d
(hexah_stress_divergence_), this speeds up isel from taking > 20mins to
taking 0.07s.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22680 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-05 18:10:27 +00:00
Chris Lattner
c534395cb2 Fix a use-of-dangling-pointer bug, from the introduction of SrcValue's.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22679 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-05 16:55:31 +00:00
Chris Lattner
2f4eca30d1 Fix a latent bug in the libcall inserter that was exposed by Nate's patch
yesterday.  This fixes whetstone and a bunch of programs in the External tests.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22678 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-05 16:23:57 +00:00
Nate Begeman
2ac4fc0320 Fix a fixme in LegalizeDAG
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22661 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-04 21:43:28 +00:00
Misha Brukman
cd33eef1b2 * Unbreak release build
* Add comments to #endif pragmas for readability


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22647 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-04 14:22:41 +00:00
Chris Lattner
4c64dd7977 Fix PR611, codegen'ing SREM of FP operands to fmod or fmodf instead of
the sequence used for integer ops


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22629 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-03 20:31:37 +00:00
Chris Lattner
0561b3ff9f Update to use the new MathExtras.h support for log2 computation.
Patch contributed by Jim Laskey!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22594 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-02 19:26:06 +00:00
Chris Lattner
e21c305ed8 Fix casts from long to sbyte on ppc
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22570 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-01 18:16:37 +00:00
Jeff Cohen
d29b6aa608 Keep tabs and trailing spaces out.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22565 91177308-0d34-0410-b5e6-96231b3b80d8
2005-07-30 18:33:25 +00:00
Chris Lattner
f20d183c22 fix float->long conversions on x86
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22563 91177308-0d34-0410-b5e6-96231b3b80d8
2005-07-30 01:40:57 +00:00
Chris Lattner
f1fa74ee0d Allow targets to have custom expanders for FP_TO_*INT conversions where
both the src and dest values are legal


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22555 91177308-0d34-0410-b5e6-96231b3b80d8
2005-07-30 00:04:12 +00:00
Chris Lattner
80a3e94653 Allow targets to define custom expanders for FP_TO_*INT
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22548 91177308-0d34-0410-b5e6-96231b3b80d8
2005-07-29 00:33:32 +00:00
Chris Lattner
1618bebcf6 allow a target to request that unknown FP_TO_*INT conversion be promoted to
a larger integer destination.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22547 91177308-0d34-0410-b5e6-96231b3b80d8
2005-07-29 00:11:56 +00:00
Chris Lattner
fa9c801a6b instead of having all conversions be handled by one case value, and then have
subcases inside, break things out earlier.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22546 91177308-0d34-0410-b5e6-96231b3b80d8
2005-07-28 23:31:12 +00:00
Andrew Lenharth
fe660397e1 new is not a valid default anywhere, so make this pure virtual
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22542 91177308-0d34-0410-b5e6-96231b3b80d8
2005-07-28 18:13:59 +00:00
Chris Lattner
cef21c3544 Fix debug info to not print out recently freed memory.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22529 91177308-0d34-0410-b5e6-96231b3b80d8
2005-07-27 23:11:25 +00:00
Chris Lattner
8e7a70976d Print symbolic register names in debug dumps
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22528 91177308-0d34-0410-b5e6-96231b3b80d8
2005-07-27 23:03:38 +00:00
Jeff Cohen
00b16889ab Eliminate all remaining tabs and trailing spaces.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22523 91177308-0d34-0410-b5e6-96231b3b80d8
2005-07-27 06:12:32 +00:00
Nate Begeman
700a3c97e9 Remove unnecessary FP_EXTEND. This causes worse codegen for SSE.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22469 91177308-0d34-0410-b5e6-96231b3b80d8
2005-07-19 16:50:03 +00:00
Reid Spencer
a0f5bf306c For: memory operations -> stores
This is the first incremental patch to implement this feature. It adds no
functionality to LLVM but setup up the information needed from targets in
order to implement the optimization correctly. Each target needs to specify
the maximum number of store operations for conversion of the llvm.memset,
llvm.memcpy, and llvm.memmove intrinsics into a sequence of store operations.
The limit needs to be chosen at the threshold of performance for such an
optimization (generally smallish). The target also needs to specify whether
the target can support unaligned stores for multi-byte store operations.
This helps ensure the optimization doesn't generate code that will trap on
an alignment errors.
More patches to follow.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22468 91177308-0d34-0410-b5e6-96231b3b80d8
2005-07-19 04:52:44 +00:00
Chris Lattner
f4d32726e6 The assertion was wrong: the code only worked for i64. While we're at it,
expand the code to work for all integer datatypes.  This should unbreak
alpha.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22464 91177308-0d34-0410-b5e6-96231b3b80d8
2005-07-18 04:31:14 +00:00
Chris Lattner
0589523525 Only get the .bss and .data sections when needed instead of unconditionally.
This allows is to not emit empty sections when .data or .bss is not used.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22457 91177308-0d34-0410-b5e6-96231b3b80d8
2005-07-16 17:41:06 +00:00
Chris Lattner
0003395320 Refactor getSection() method to make it easier to use.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22455 91177308-0d34-0410-b5e6-96231b3b80d8
2005-07-16 17:36:04 +00:00
Chris Lattner
5f48ff7d1f Major refactor of the ELFWriter code. Instead of building up one big
vector that represents the .o file at once, build up a vector for each
section of the .o file.  This is needed because the .o file writer needs
to be able to switch between sections as it emits them (e.g. switch
between the .text section and the .rel section when emitting code).

This patch has no functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22453 91177308-0d34-0410-b5e6-96231b3b80d8
2005-07-16 08:01:13 +00:00
Nate Begeman
5a8441ea3f Teach the legalizer how to promote SINT_TO_FP to a wider SINT_TO_FP that
the target natively supports.  This eliminates some special-case code from
the x86 backend and generates better code as well.

For an i8 to f64 conversion, before & after:

_x87 before:
        subl $2, %esp
        movb 6(%esp), %al
        movsbw %al, %ax
        movw %ax, (%esp)
        filds (%esp)
        addl $2, %esp
        ret

_x87 after:
        subl $2, %esp
        movsbw 6(%esp), %ax
        movw %ax, (%esp)
        filds (%esp)
        addl $2, %esp
        ret

_sse before:
        subl $12, %esp
        movb 16(%esp), %al
        movsbl %al, %eax
        cvtsi2sd %eax, %xmm0
        addl $12, %esp
        ret

_sse after:
        subl $12, %esp
        movsbl 16(%esp), %eax
        cvtsi2sd %eax, %xmm0
        addl $12, %esp
        ret


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22452 91177308-0d34-0410-b5e6-96231b3b80d8
2005-07-16 02:02:34 +00:00
Chris Lattner
cad063f1a8 Break the code for expanding UINT_TO_FP operations out into its own
SelectionDAGLegalize::ExpandLegalUINT_TO_FP method.

Add a new method, PromoteLegalUINT_TO_FP, which allows targets to request
that UINT_TO_FP operations be promoted to a larger input type.  This is
useful for targets that have some UINT_TO_FP or SINT_TO_FP operations but
not all of them (like X86).

The same should be done with SINT_TO_FP, but this patch does not do that
yet.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22447 91177308-0d34-0410-b5e6-96231b3b80d8
2005-07-16 00:19:57 +00:00
Chris Lattner
6e741f8842 You can't use config options without config.h
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22446 91177308-0d34-0410-b5e6-96231b3b80d8
2005-07-15 22:48:31 +00:00
Chris Lattner
c5f44add43 Make this use the new autoconf support for finding the executables for
gv and Graphviz.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22434 91177308-0d34-0410-b5e6-96231b3b80d8
2005-07-14 05:33:13 +00:00
Chris Lattner
e388b5ea2c As discussed on IRC, this stuff is just for debugging.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22432 91177308-0d34-0410-b5e6-96231b3b80d8
2005-07-14 05:17:43 +00:00
Chris Lattner
f1a2f15ed3 If the Graphviz program is available, use it to visualize dot graphs.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22429 91177308-0d34-0410-b5e6-96231b3b80d8
2005-07-14 01:10:55 +00:00
Chris Lattner
c087a43510 Fix Alpha/2005-07-12-TwoMallocCalls.ll and PR593.
It is not safe to call LegalizeOp on something that has already been legalized.
Instead, just force another iteration of legalization.

This could affect all platforms but X86, as this codepath is dynamically
dead on X86 (ISD::MEMSET and friends are legal).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22419 91177308-0d34-0410-b5e6-96231b3b80d8
2005-07-13 02:00:04 +00:00
Chris Lattner
6814f1522d Fix test/Regression/CodeGen/Generic/2005-07-12-memcpy-i64-length.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22417 91177308-0d34-0410-b5e6-96231b3b80d8
2005-07-13 01:42:45 +00:00
Chris Lattner
46c53054d0 Add support for 64-bit elf files
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22400 91177308-0d34-0410-b5e6-96231b3b80d8
2005-07-12 06:57:52 +00:00
Jeff Cohen
44213c9538 VC++ demands that the function returns a value
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22393 91177308-0d34-0410-b5e6-96231b3b80d8
2005-07-12 02:53:33 +00:00
Chris Lattner
0e18050797 Clean up code, no functionality changes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22382 91177308-0d34-0410-b5e6-96231b3b80d8
2005-07-11 06:34:30 +00:00
Chris Lattner
5fe7b6e2be Emit a symbol table entry for each function we output to the ELF file. This
allows objdump to know which function we are emitting to:

00000000 <foo>:     <----
   0:   b8 01 00 00 00          mov    $0x1,%eax
   5:   03 44 24 04             add    0x4(%esp,1),%eax
   9:   c3                      ret

... and allows .o files to be useful for linking :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22378 91177308-0d34-0410-b5e6-96231b3b80d8
2005-07-11 06:17:35 +00:00
Chris Lattner
aa507db59e add code to emit the .text section to the section header.
Add a *VERY INITIAL* machine code emitter class.  This is enough to take
this C function:
int foo(int X) { return X +1; }

and make objdump produce the following:

$ objdump -d t-llvm.o

t-llvm.o:     file format elf32-i386

Disassembly of section .text:

00000000 <.text>:
   0:   b8 01 00 00 00          mov    $0x1,%eax
   5:   03 44 24 04             add    0x4(%esp,1),%eax
   9:   c3                      ret


Anything using branches or refering to the constant pool or requiring
relocations will not work yet.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22375 91177308-0d34-0410-b5e6-96231b3b80d8
2005-07-11 05:17:18 +00:00
Chris Lattner
5acd120078 Use a name mangler object to uniquify names and remove nonstandard
characters from them.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22371 91177308-0d34-0410-b5e6-96231b3b80d8
2005-07-11 03:11:47 +00:00
Chris Lattner
5f056bf4b8 Change *EXTLOAD to use an VTSDNode operand instead of being an MVTSDNode.
This is the last MVTSDNode.

This allows us to eliminate a bunch of special case code for handling
MVTSDNodes.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22367 91177308-0d34-0410-b5e6-96231b3b80d8
2005-07-10 01:55:33 +00:00
Chris Lattner
9fadb4c1c0 Change TRUNCSTORE to use a VTSDNode operand instead of being an MVTSTDNode
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22366 91177308-0d34-0410-b5e6-96231b3b80d8
2005-07-10 00:29:18 +00:00
Chris Lattner
15e4b01920 Introduce a new VTSDNode class with the ultimate goal of eliminating the
MVTSDNode class.  This class is used to provide an operand to operators
that require an extra type.  We start by converting FP_ROUND_INREG and
SIGN_EXTEND_INREG over to using it.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22364 91177308-0d34-0410-b5e6-96231b3b80d8
2005-07-10 00:07:11 +00:00
Chris Lattner
4c47e3a1c5 Add support for emitting a .data section and .bss section.
Add support for emitting external and .bss symbols.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22358 91177308-0d34-0410-b5e6-96231b3b80d8
2005-07-08 05:47:00 +00:00
Chris Lattner
80ed8faaea Add support for emitting the symbol table (and its string table) of the
module to the ELF file.  Test it by adding support for emitting common
symbols.  This allows us to compile this:

%X = weak global int 0
%Y = weak global int 0
%Z = weak global int 0

to an elf file that 'readelf's this:

Symbol table '.symtab' contains 4 entries:
   Num:    Value  Size Type    Bind   Vis      Ndx Name
     0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND
     1: 00000004     4 OBJECT  GLOBAL DEFAULT  COM X
     2: 00000004     4 OBJECT  GLOBAL DEFAULT  COM Y
     3: 00000004     4 OBJECT  GLOBAL DEFAULT  COM Z


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22343 91177308-0d34-0410-b5e6-96231b3b80d8
2005-07-07 07:02:20 +00:00
Chris Lattner
e64e72b794 Make several cleanups to Andrews varargs change:
1. Pass Value*'s into lowering methods so that the proper pointers can be
   added to load/stores from the valist
2. Intrinsics that return void should only return a token chain, not a token
   chain/retval pair.
3. Rename LowerVAArgNext -> LowerVAArg, because VANext is long gone.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22338 91177308-0d34-0410-b5e6-96231b3b80d8
2005-07-05 19:57:53 +00:00
Andrew Lenharth
f2eb1396b8 2 fixes:
1: Legalize operand in UINT_TO_FP expanision

2: SRA x, const i8 was not promoting the constant to shift amount type.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22337 91177308-0d34-0410-b5e6-96231b3b80d8
2005-07-05 19:52:39 +00:00
Andrew Lenharth
c6bead211b I really didn't think this was necessary. But, Legalize wasn't running again
and legalizing the extload.  Strange.  Should fix most alpha regressions.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22329 91177308-0d34-0410-b5e6-96231b3b80d8
2005-07-02 20:58:53 +00:00
Andrew Lenharth
31559081a4 oops
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22320 91177308-0d34-0410-b5e6-96231b3b80d8
2005-06-30 19:32:57 +00:00
Andrew Lenharth
9d416f713e FP EXTLOAD is not support on all archs, expand to LOAD and FP_EXTEND
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22319 91177308-0d34-0410-b5e6-96231b3b80d8
2005-06-30 19:22:37 +00:00
Andrew Lenharth
06ef88472f restore old srcValueNode behavior and try to to work around it
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22315 91177308-0d34-0410-b5e6-96231b3b80d8
2005-06-29 18:54:02 +00:00
Andrew Lenharth
782ad62f33 tracking the instructions causing loads and stores provides more information than just the pointer being loaded or stored
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22311 91177308-0d34-0410-b5e6-96231b3b80d8
2005-06-29 15:57:19 +00:00
Andrew Lenharth
f4b3278aeb Adapt the code for handling uint -> fp conversion for the 32 bit case to
handling it in the 64 bit case.  The two code paths should probably be merged.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22302 91177308-0d34-0410-b5e6-96231b3b80d8
2005-06-27 23:28:32 +00:00
Chris Lattner
35f0a4f24e iniital checkin of ELFWriter implementation
For now, the elf writer is only capable of emitting an empty elf file, with
a section table and a section table string table.  This will be enhanced
in the future :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22291 91177308-0d34-0410-b5e6-96231b3b80d8
2005-06-27 06:29:00 +00:00
Andrew Lenharth
213e557cef If we support structs as va_list, we must pass pointers to them to va_copy
See last commit for LangRef, this implements it on all targets.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22273 91177308-0d34-0410-b5e6-96231b3b80d8
2005-06-22 21:04:42 +00:00
Andrew Lenharth
558bc88a00 core changes for varargs
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22254 91177308-0d34-0410-b5e6-96231b3b80d8
2005-06-18 18:34:52 +00:00
Nate Begeman
41aaf7016e Fix bug 537 test 2, which checks to make sure that we fold A+(B-A) -> B for
integer types.  Add a couple checks to not perform these kinds of transform
on floating point values.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22228 91177308-0d34-0410-b5e6-96231b3b80d8
2005-06-16 07:06:03 +00:00
Duraid Madina
4560657b4c aCC and STLport complained about this, because they're like that
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22053 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-15 13:05:48 +00:00
Chris Lattner
e5eb6f829c Add some simplifications for MULH[SU]. This allows us to compile this:
long %bar(long %X) {
  %Y = mul long %X, 4294967297
  ret long %Y
}

to this:

l1_bar:
        mov %EAX, DWORD PTR [%ESP + 4]
        mov %EDX, %EAX
        add %EDX, DWORD PTR [%ESP + 8]
        ret

instead of:

l1_bar:
        mov %ECX, DWORD PTR [%ESP + 4]
        mov %EDX, 1
        mov %EAX, %ECX
        mul %EDX
        add %EDX, %ECX
        add %EDX, DWORD PTR [%ESP + 8]
        mov %EAX, %ECX
        ret


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22044 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-15 05:39:08 +00:00
Chris Lattner
4fc997941d When inserting callee-save register reloads, make sure to skip over any
terminator instructions before the 'ret' in case the target has a
multi-instruction return sequence.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22041 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-15 03:09:58 +00:00
Chris Lattner
1ca85d567c Fix construction of ioport intrinsics, fixing X86/io.llx and io-port.llx
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22026 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-14 13:56:55 +00:00
Chris Lattner
2789bde57f allow token chain at start or end of node
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22020 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-14 08:34:53 +00:00
Chris Lattner
3e01136f9f remove special case hacks for readport/readio from the binary operator
codepath


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22019 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-14 07:45:46 +00:00
Chris Lattner
385328ce41 Implement fixme's by memoizing nodes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22018 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-14 07:42:29 +00:00
Chris Lattner
b7f7d51422 Turn this into a wrapper for a simpler version of getNode.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22016 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-14 07:32:14 +00:00
Chris Lattner
adf6c2a0cb Eliminate special purpose hacks for dynamic_stack_alloc.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22015 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-14 07:29:57 +00:00
Chris Lattner
e89083a930 Use the general mechanism for creating multi-value nodes instead of using
special case hacks.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22014 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-14 07:25:05 +00:00
Chris Lattner
5fa4fa4e0f Wrap long line, actually add node to the graph.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22011 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-14 06:42:57 +00:00
Chris Lattner
d73cc5d058 legalize target-specific operations
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22010 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-14 06:34:48 +00:00
Chris Lattner
89c34637cb add a getNode() version that allows construction of any node type.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22009 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-14 06:20:26 +00:00
Chris Lattner
50381b6c41 LowerOperation takes a dag
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22004 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-14 05:50:48 +00:00
Chris Lattner
38135af219 Print the symbolic register name in a register allocator debug dump.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22002 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-14 05:34:15 +00:00
Chris Lattner
a88a260dbd Allow targets to have a custom int64->fp expander if desired
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22001 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-14 05:33:54 +00:00
Chris Lattner
a8217e3000 Align doubles on 8-byte boundaries if possible.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21993 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-13 23:14:17 +00:00
Chris Lattner
0db07092a7 print stack object alignment in -print-machineinstr dumps
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21992 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-13 22:54:44 +00:00
Chris Lattner
2a82ef317c Tolerate instrs with extra args
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21982 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-13 21:07:15 +00:00
Chris Lattner
adf6a965a3 Add an isTailCall flag to LowerCallTo
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21958 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-13 18:50:42 +00:00
Chris Lattner
d71c04199c Handle TAILCALL node
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21957 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-13 18:43:43 +00:00
Chris Lattner
405ef9e28d Emit function entry code after lowering hte arguments.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21931 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-13 07:33:32 +00:00
Chris Lattner
3aa7832c82 Allow targets to emit code into the entry block of each function
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21930 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-13 07:23:21 +00:00
Chris Lattner
712ad0c36d allow a virtual register to be associated with live-in values.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21927 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-13 07:08:07 +00:00
Chris Lattner
eb516e7f0a Fix a problem that nate reduced for me.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21923 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-13 05:17:00 +00:00
Chris Lattner
9530ddcc60 rename variables and functions to match renamed DAG nodes. Bonus feature:
I can actually remember which one is which now!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21922 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-13 05:09:11 +00:00
Chris Lattner
66de05b606 do not call expandop on the same value more than once. This fixes
X86/2004-02-22-Casts.llx


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21919 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-13 04:45:13 +00:00
Chris Lattner
a364fa126a fix a bad typeo
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21917 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-12 23:51:40 +00:00
Chris Lattner
128b52d3d7 update comment
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21916 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-12 23:24:44 +00:00
Chris Lattner
16cd04d26c rename the ADJCALLSTACKDOWN/ADJCALLSTACKUP nodes to be CALLSEQ_START/BEGIN.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21915 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-12 23:24:06 +00:00
Chris Lattner
9092fa310c Pass calling convention to use into lower call to
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21900 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-12 19:56:57 +00:00
Chris Lattner
3becf2026b fix expansion of ct[lt]z nodes
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21896 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-12 19:27:51 +00:00
Chris Lattner
39a8f33630 Expand 64-bit ctlz/cttz nodes for 32-bit targets
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21895 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-12 19:05:01 +00:00
Chris Lattner
383203b003 Fix uint->fp casts on PPC, allowing UnitTests/2005-05-12-Int64ToFP to
work on it.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21894 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-12 18:52:34 +00:00
Chris Lattner
45982dad53 Allow something to be legalized multiple times. This can be used to reduce
legalization iteration


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21892 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-12 16:53:42 +00:00
Chris Lattner
13689e2009 Oops, don't do this after we figure out where to insert the call chains.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21890 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-12 07:00:44 +00:00
Chris Lattner
44d105b7fa Make sure to expand all nodes, avoiding unintentional node duplication.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21889 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-12 06:54:21 +00:00
Chris Lattner
6980d8295f handle a common case generated by the uint64 -> FP code path better
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21888 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-12 06:27:02 +00:00
Chris Lattner
e131e5b81e add fixme
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21887 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-12 06:04:14 +00:00
Chris Lattner
b9fa3bc8f3 Fix a problem where early legalization can cause token chain problems.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21885 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-12 04:49:08 +00:00
Chris Lattner
88de6e77bf Make legalize a bit more efficient, and canonicalize sub X, C -> add X, -C
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21882 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-12 00:17:04 +00:00
Nate Begeman
d7c4a4a6c0 Necessary changes to codegen cttz efficiently on PowerPC
1. Teach LegalizeDAG how to better legalize CTTZ if the target doesn't have
   CTPOP, but does have CTLZ
2. Teach PPC32 how to do sub x, const -> add x, -const for valid consts
3. Teach PPC32 how to do and (xor a, -1) b -> andc b, a
4. Teach PPC32 that ISD::CTLZ -> PPC::CNTLZW


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21880 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-11 23:43:56 +00:00
Chris Lattner
98cf45bbf6 Fix lowering of ctlz, so now UnitTests/2005-05-11-Popcount-ffs-fls passes
with the CBE


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21875 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-11 20:24:12 +00:00
Chris Lattner
a801172e50 Fix lowering of cttz to work with signed values
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21874 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-11 20:02:14 +00:00
Chris Lattner
86f3e0c24e fix and concisify intinsic lowering for ctpop. Unfortunately, this code
looks completely untested. :(


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21873 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-11 19:42:05 +00:00
Chris Lattner
0d67f0c80f Fix the last remaining bug preventing us from switching the X86 BE over
from the simple isel to the pattern isel.  This forces inserted libcalls
to serialize against other function calls, which was breaking
UnitTests/2005-05-12-Int64ToFP.  Hopefully this will fix issues on other
targets as well.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21872 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-11 19:02:11 +00:00
Chris Lattner
27e9b41464 Do not memoize ADJCALLSTACKDOWN nodes, provide a method to hack on them.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21871 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-11 18:57:39 +00:00
Chris Lattner
16ce0df927 wrap long line
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21870 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-11 18:57:06 +00:00
Chris Lattner
5c33c9a166 Make sure to legalize generated ctpop nodes, convert tabs to spaces
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21868 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-11 18:35:21 +00:00
Duraid Madina
57ff7e5f64 expand count-leading/trailing-zeros; the test 2005-05-11-Popcount-ffs-fls.c
should now pass (the "LLVM" and "REF" results should be identical)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21866 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-11 08:45:08 +00:00
Chris Lattner
18aa680a96 Add some notes for expanding clz/ctz
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21862 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-11 05:27:09 +00:00
Chris Lattner
e3ef0a8b9f Simplify this code, use the proper shift amount
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21861 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-11 05:21:31 +00:00
Chris Lattner
9b583b4910 Legalize this correctly
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21859 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-11 05:09:47 +00:00
Chris Lattner
edb1add9a0 implement expansion of ctpop nodes, implementing CodeGen/Generic/llvm-ct-intrinsics.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21856 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-11 04:51:16 +00:00
Chris Lattner
276260b16d Print bit count nodes correctly
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21855 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-11 04:50:30 +00:00
Jeff Cohen
19bb2283e6 Silence some VC++ warnings
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21838 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-10 02:22:38 +00:00
Chris Lattner
ef311aa7cf The semantics of cast X to bool are a comparison against zero, not a truncation!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21833 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-09 22:17:13 +00:00
Chris Lattner
6d5b8e1646 legalize readio/writeio into a load/store if requested
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21827 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-09 20:36:57 +00:00
Chris Lattner
52d08bd9d8 legalize READPORT, WRITEPORT, READIO, WRITEIO, at least in the basic cases
where they are directly supported by the architecture.  Wrap a bunch of
long lines :(


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21826 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-09 20:23:03 +00:00
Chris Lattner
d0f6c1f52d Add support for matching the READPORT, WRITEPORT, READIO, WRITEIO intrinsics
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21825 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-09 20:22:36 +00:00
Chris Lattner
3c6910153c Add support for READPORT, WRITEPORT, READIO, WRITEIO
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21824 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-09 20:22:17 +00:00
Chris Lattner
57aa5961a9 Fold shifts into subsequent SHL's. These shifts often arise due to addrses
arithmetic lowering.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21818 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-09 17:06:45 +00:00
Chris Lattner
fd414a27fd Don't use the load/store instruction as the source pointer, use the pointer
being stored/loaded through!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21806 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-09 04:28:51 +00:00
Chris Lattner
0437cdd6dc memoize all nodes, even null Value* nodes. Do not add two token chain outputs
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21805 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-09 04:14:13 +00:00
Chris Lattner
369e6db9b6 wrap long lines
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21804 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-09 04:08:33 +00:00
Chris Lattner
2bf3c26b2b Print SrcValue nodes correctly
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21803 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-09 04:08:27 +00:00
Chris Lattner
1f243e9f43 Wrap long lines. Fix "warning: conflicting types for built-in function 'memset'"
warning from the CBE+GCC.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21779 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-08 19:46:29 +00:00
Misha Brukman
d7a10c8566 * Order #includes alphabetically
* Remove commented-out debug printouts


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21707 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-05 23:45:17 +00:00
Chris Lattner
7ea0ade1b6 When hitting an unsupported intrinsic, actually print it
Lower debug info to noops.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21698 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-05 17:55:17 +00:00
Andrew Lenharth
ded10bfb46 ctpop lowering in legalize
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21697 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-05 15:55:21 +00:00
Andrew Lenharth
fecf095292 Make promoteOp work for CT*
Proof?

ubyte %bar(ubyte %x) {
entry:
        %tmp.1 = call ubyte %llvm.ctlz( ubyte %x )
        ret ubyte %tmp.1
}

==>

zapnot $16,1,$0
CTLZ $0,$0
subq $0,56,$0
zapnot $0,1,$0
ret $31,($26),1


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21691 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-04 19:11:05 +00:00
Andrew Lenharth
691ef2ba06 Implement count leading zeros (ctlz), count trailing zeros (cttz), and count
population (ctpop).  Generic lowering is implemented, however only promotion
is implemented for SelectionDAG at the moment.

More coming soon.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21676 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-03 17:19:30 +00:00
Alkis Evlogimenos
b1beff0f0d Do not use deprecated APIs
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21639 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-30 07:13:31 +00:00
Chris Lattner
f76e7dc8d8 Codegen and legalize sin/cos/llvm.sqrt as FSIN/FCOS/FSQRT calls. This patch
was contributed by Morten Ofstad, with some minor tweaks and bug fixes added
by me.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21636 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-30 04:43:14 +00:00
Chris Lattner
b42a9ffbe9 Lower llvm.sqrt -> fsqrt/sqrt
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21629 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-30 04:07:50 +00:00
Chris Lattner
da6ba87d23 Legalize FSQRT, FSIN, FCOS nodes, patch contributed by Morten Ofstad
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21606 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-28 21:44:33 +00:00
Chris Lattner
7f64464ff1 Add FSQRT, FSIN, FCOS nodes, patch contributed by Morten Ofstad
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21605 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-28 21:44:03 +00:00
Andrew Lenharth
2d86ea21dd Implement Value* tracking for loads and stores in the selection DAG. This enables one to use alias analysis in the backends.
(TRUNK)Stores and (EXT|ZEXT|SEXT)Loads have an extra SDOperand which is a SrcValueSDNode which contains the Value*.  Note that if the operation is introduced by the backend, it will still have the operand, but the value* will be null.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21599 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-27 20:10:01 +00:00
Chris Lattner
d36f979085 Fold (X > -1) | (Y > -1) --> (X&Y > -1)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21552 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-26 01:18:33 +00:00
Chris Lattner
229ab2e7b2 implement some more logical compares with constants, so that:
int foo1(int x, int y) {
  int t1 = x >= 0;
  int t2 = y >= 0;
  return t1 & t2;
}
int foo2(int x, int y) {
  int t1 = x == -1;
  int t2 = y == -1;
  return t1 & t2;
}

produces:

_foo1:
        or r2, r4, r3
        srwi r2, r2, 31
        xori r3, r2, 1
        blr
_foo2:
        and r2, r4, r3
        addic r2, r2, 1
        li r2, 0
        addze r3, r2
        blr

instead of:

_foo1:
        srwi r2, r4, 31
        xori r2, r2, 1
        srwi r3, r3, 31
        xori r3, r3, 1
        and r3, r2, r3
        blr
_foo2:
        addic r2, r4, 1
        li r2, 0
        addze r2, r2
        addic r3, r3, 1
        li r3, 0
        addze r3, r3
        and r3, r2, r3
        blr


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21547 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-25 21:20:28 +00:00
Chris Lattner
6ea9279304 Codegen x < 0 | y < 0 as (x|y) < 0. This allows us to compile this to:
_foo:
        or r2, r4, r3
        srwi r3, r2, 31
        blr

instead of:

_foo:
        srwi r2, r4, 31
        srwi r3, r3, 31
        or r3, r2, r3
        blr


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21544 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-25 21:03:25 +00:00
Misha Brukman
dedf2bd5a3 Convert tabs to spaces
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21439 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-22 04:01:18 +00:00
Misha Brukman
f976c856fc Remove trailing whitespace
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21422 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-21 22:55:34 +00:00
Misha Brukman
edf128a7fa Remove trailing whitespace
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21420 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-21 22:36:52 +00:00
Chris Lattner
588bbbffa1 Improve and elimination. On PPC, for:
bool %test(int %X) {
        %Y = and int %X, 8
        %Z = setne int %Y, 0
        ret bool %Z
}

we now generate this:

        rlwinm r2, r3, 0, 28, 28
        srwi r3, r2, 3

instead of this:

        rlwinm r2, r3, 0, 28, 28
        srwi r2, r2, 3
        rlwinm r3, r2, 0, 31, 31

I'll leave it to Nate to get it down to one instruction. :)

---------------------------------------------------------------------


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21391 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-21 06:28:15 +00:00
Chris Lattner
1c2a9b95dc Fold (x & 8) != 0 and (x & 8) == 8 into (x & 8) >> 3.
This turns this PPC code:

        rlwinm r2, r3, 0, 28, 28
        cmpwi cr7, r2, 8
        mfcr r2
        rlwinm r3, r2, 31, 31, 31

into this:

        rlwinm r2, r3, 0, 28, 28
        srwi r2, r2, 3
        rlwinm r3, r2, 0, 31, 31

Next up, nuking the extra and.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21390 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-21 06:12:41 +00:00
Chris Lattner
fda2b55e1b Fold setcc of MVT::i1 operands into logical operations
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21319 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-18 04:48:12 +00:00
Chris Lattner
4a44c8df19 Another minor simplification: handle setcc (zero_extend x), c -> setcc(x, c')
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21318 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-18 04:30:45 +00:00
Chris Lattner
7467c9b086 Another simple xform
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21317 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-18 04:11:19 +00:00
Chris Lattner
706aa9685a Fold:
// (X != 0) | (Y != 0) -> (X|Y != 0)
        // (X == 0) & (Y == 0) -> (X|Y == 0)

Compiling this:

int %bar(int %a, int %b) {
        entry:
        %tmp.1 = setne int %a, 0
        %tmp.2 = setne int %b, 0
        %tmp.3 = or bool %tmp.1, %tmp.2
        %retval = cast bool %tmp.3 to int
        ret int %retval
        }

to this:

_bar:
        or r2, r3, r4
        addic r3, r2, -1
        subfe r3, r3, r2
        blr

instead of:

_bar:
        addic r2, r3, -1
        subfe r2, r2, r3
        addic r3, r4, -1
        subfe r3, r3, r4
        or r3, r2, r3
        blr


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21316 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-18 03:59:53 +00:00
Chris Lattner
36019aa5c6 Make the AND elimination operation recursive and significantly more powerful,
eliminating an and for Nate's testcase:

int %bar(int %a, int %b) {
        entry:
        %tmp.1 = setne int %a, 0
        %tmp.2 = setne int %b, 0
        %tmp.3 = or bool %tmp.1, %tmp.2
        %retval = cast bool %tmp.3 to int
        ret int %retval
        }

generating:

_bar:
        addic r2, r3, -1
        subfe r2, r2, r3
        addic r3, r4, -1
        subfe r3, r3, r4
        or r3, r2, r3
        blr

instead of:

_bar:
        addic r2, r3, -1
        subfe r2, r2, r3
        addic r3, r4, -1
        subfe r3, r3, r4
        or r2, r2, r3
        rlwinm r3, r2, 0, 31, 31
        blr


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21315 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-18 03:48:41 +00:00
Nate Begeman
72ea281d61 Add a couple missing transforms in getSetCC that were triggering assertions
in the PPC Pattern ISel


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21297 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-14 08:56:52 +00:00
Nate Begeman
eea805e74c Disbale the broken fold of shift + sz[ext] for now
Move the transform for select (a < 0) ? b : 0 into the dag from ppc isel
Enable the dag to fold and (setcc, 1) -> setcc for targets where setcc
  always produces zero or one.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21291 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-13 21:23:31 +00:00
Chris Lattner
97e001dec7 fix an infinite loop
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21289 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-13 20:06:29 +00:00
Chris Lattner
fd8d389ede fix some serious miscompiles on ia64, alpha, and ppc
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21288 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-13 19:53:40 +00:00
Chris Lattner
51679c430f avoid work when possible, perhaps fix the problem nate and andrew are seeing
with != 0 comparisons vanishing.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21287 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-13 19:41:05 +00:00
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
e666fcfbdd add back the optimization that Nate added for shl X, (zext_inreg y)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21273 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-13 02:58:13 +00:00
Chris Lattner
8a8dbfa57c Oops, remove these too.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21272 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-13 02:47:57 +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
0f2287baa1 Remove all foldings of ZERO_EXTEND_INREG, moving them to work for AND nodes
instead.  OVerall, this increases the amount of folding we can do.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21265 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-13 02:38:18 +00:00
Nate Begeman
db81ebab89 Fold shift x, [sz]ext(y) -> shift x, y
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21262 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-12 23:32:28 +00:00
Nate Begeman
b882752bd0 Fold shift by size larger than type size to undef
Make llvm undef values generate ISD::UNDEF nodes


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21261 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-12 23:12:17 +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
fd1f1ee0ba Remove some redundant checks, add a couple of new ones. This allows us to
compile this:

int foo (unsigned long a, unsigned long long g) {
  return a >= g;
}

To:

foo:
        movl 8(%esp), %eax
        cmpl %eax, 4(%esp)
        setae %al
        cmpl $0, 12(%esp)
        sete %cl
        andb %al, %cl
        movzbl %cl, %eax
        ret

instead of:

foo:
        movl 8(%esp), %eax
        cmpl %eax, 4(%esp)
        setae %al
        movzbw %al, %cx
        movl 12(%esp), %edx
        cmpl $0, %edx
        sete %al
        movzbw %al, %ax
        cmpl $0, %edx
        cmove %cx, %ax
        movzbl %al, %eax
        ret


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21244 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-12 02:54:39 +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
3b2c1d95a2 canonicalize x <u 1 -> x == 0. On this testcase:
unsigned long long g;
unsigned long foo (unsigned long a) {
  return (a >= g) ? 1 : 0;
}

It changes the ppc code from:

_foo:
.LBB_foo_0:     ; entry
        mflr r11
        stw r11, 8(r1)
        bl "L00000$pb"
"L00000$pb":
        mflr r2
        addis r2, r2, ha16(L_g$non_lazy_ptr-"L00000$pb")
        lwz r2, lo16(L_g$non_lazy_ptr-"L00000$pb")(r2)
        lwz r4, 0(r2)
        lwz r2, 4(r2)
        cmplw cr0, r3, r2
        li r2, 1
        li r3, 0
        bge .LBB_foo_2  ; entry
.LBB_foo_1:     ; entry
        or r2, r3, r3
.LBB_foo_2:     ; entry
        cmplwi cr0, r4, 1
        li r3, 1
        li r5, 0
        blt .LBB_foo_4  ; entry
.LBB_foo_3:     ; entry
        or r3, r5, r5
.LBB_foo_4:     ; entry
        cmpwi cr0, r4, 0
        beq .LBB_foo_6  ; entry
.LBB_foo_5:     ; entry
        or r2, r3, r3
.LBB_foo_6:     ; entry
        rlwinm r3, r2, 0, 31, 31
        lwz r11, 8(r1)
        mtlr r11
        blr


to:

_foo:
.LBB_foo_0:     ; entry
        mflr r11
        stw r11, 8(r1)
        bl "L00000$pb"
"L00000$pb":
        mflr r2
        addis r2, r2, ha16(L_g$non_lazy_ptr-"L00000$pb")
        lwz r2, lo16(L_g$non_lazy_ptr-"L00000$pb")(r2)
        lwz r4, 0(r2)
        lwz r2, 4(r2)
        cmplw cr0, r3, r2
        li r2, 1
        li r3, 0
        bge .LBB_foo_2  ; entry
.LBB_foo_1:     ; entry
        or r2, r3, r3
.LBB_foo_2:     ; entry
        cntlzw r3, r4
        srwi r3, r3, 5
        cmpwi cr0, r4, 0
        beq .LBB_foo_4  ; entry
.LBB_foo_3:     ; entry
        or r2, r3, r3
.LBB_foo_4:     ; entry
        rlwinm r3, r2, 0, 31, 31
        lwz r11, 8(r1)
        mtlr r11
        blr


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21241 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-12 00:28:49 +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
2bb6f41282 Don't bother sign/zext_inreg'ing the result of an and operation if we know
the result does change as a result of the extend.

This improves codegen for Alpha on this testcase:

int %a(ushort* %i) {
        %tmp.1 = load ushort* %i
        %tmp.2 = cast ushort %tmp.1 to int
        %tmp.4 = and int %tmp.2, 1
        ret int %tmp.4
}

Generating:

a:
        ldgp $29, 0($27)
        ldwu $0,0($16)
        and $0,1,$0
        ret $31,($26),1

instead of:

a:
        ldgp $29, 0($27)
        ldwu $0,0($16)
        and $0,1,$0
        addl $0,0,$0
        ret $31,($26),1

btw, alpha really should switch to livein/outs for args :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21213 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-10 23:37:16 +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
45278e37eb Fold zext_inreg(zextload), likewise for sext's
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21204 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-10 04:33:08 +00:00
Chris Lattner
edeecfcbd5 add a simple xform
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21203 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-10 04:04:49 +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
a2daa8c78d add a little peephole optimization. This allows us to codegen:
int a(short i) {
        return i & 1;
}

as

_a:
        andi. r3, r3, 1
        blr

instead of:

_a:
        rlwinm r2, r3, 0, 16, 31
        andi. r3, r2, 1
        blr

on ppc.  It should also help the other risc targets.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21189 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-09 21:43:54 +00:00
Chris Lattner
8e7d87b228 there is no need to remove this instruction, linscan does it already as it
removes noop moves.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21183 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-09 16:24:20 +00:00
Chris Lattner
799a919dbc Adjust live intervals to support a livein set
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21182 91177308-0d34-0410-b5e6-96231b3b80d8
2005-04-09 16:17:50 +00:00