Commit Graph

15198 Commits

Author SHA1 Message Date
Chris Lattner
84750587bf Fold the full generality of (any_extend (truncate x))
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30514 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-20 06:29:17 +00:00
Chris Lattner
5f42a240ba Two things:
1. teach SimplifySetCC that '(srl (ctlz x), 5) == 0' is really x != 0.
2. Teach visitSELECT_CC to use SimplifySetCC instead of calling it and
   ignoring the result.  This allows us to compile:

bool %test(ulong %x) {
  %tmp = setlt ulong %x, 4294967296
  ret bool %tmp
}

to:

_test:
        cntlzw r2, r3
        cmplwi cr0, r3, 1
        srwi r2, r2, 5
        li r3, 0
        beq cr0, LBB1_2 ;
LBB1_1: ;
        mr r3, r2
LBB1_2: ;
        blr

instead of:

_test:
        addi r2, r3, -1
        cntlzw r2, r2
        cntlzw r3, r3
        srwi r2, r2, 5
        cmplwi cr0, r2, 0
        srwi r2, r3, 5
        li r3, 0
        bne cr0, LBB1_2 ;
LBB1_1: ;
        mr r3, r2
LBB1_2: ;
        blr

This isn't wonderful, but it's an improvement.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30513 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-20 06:19:26 +00:00
Chris Lattner
ac924c8248 This is already done
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30512 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-20 04:59:33 +00:00
Chris Lattner
b8456460cb We went through all that trouble to compute whether it was safe to transform
this comparison, but never checked it.  Whoops, no wonder we miscompiled
177.mesa!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30511 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-20 04:44:59 +00:00
Chris Lattner
711762497c Improve PPC64 equality comparisons like PPC32 comparisons.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30510 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-20 04:33:27 +00:00
Chris Lattner
3836dbd3bd Two improvements:
1. Codegen this comparison:
     if (X == 0x8000)

as:

        cmplwi cr0, r3, 32768
        bne cr0, LBB1_2 ;cond_next

instead of:

        lis r2, 0
        ori r2, r2, 32768
        cmpw cr0, r3, r2
        bne cr0, LBB1_2 ;cond_next


2. Codegen this comparison:
      if (X == 0x12345678)

as:

        xoris r2, r3, 4660
        cmplwi cr0, r2, 22136
        bne cr0, LBB1_2 ;cond_next

instead of:

        lis r2, 4660
        ori r2, r2, 22136
        cmpw cr0, r3, r2
        bne cr0, LBB1_2 ;cond_next


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30509 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-20 04:25:47 +00:00
Chris Lattner
cc96ac3a7d Add a note that we should match rlwnm better
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30508 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-20 03:59:25 +00:00
Chris Lattner
3fe6c1d389 Legalize is no longer limited to cleverness with just constant shift amounts.
Allow it to be clever when possible and fall back to the gross code when needed.

This allows us to compile:

long long foo1(long long X, int C) {
  return X << (C|32);
}
long long foo2(long long X, int C) {
  return X << (C&~32);
}

to:
_foo1:
        rlwinm r2, r5, 0, 27, 31
        slw r3, r4, r2
        li r4, 0
        blr


        .globl  _foo2
        .align  4
_foo2:
        rlwinm r2, r5, 0, 27, 25
        subfic r5, r2, 32
        slw r3, r3, r2
        srw r5, r4, r5
        or r3, r3, r5
        slw r4, r4, r2
        blr

instead of:

_foo1:
        ori r2, r5, 32
        subfic r5, r2, 32
        addi r6, r2, -32
        srw r5, r4, r5
        slw r3, r3, r2
        slw r6, r4, r6
        or r3, r3, r5
        slw r4, r4, r2
        or r3, r3, r6
        blr


        .globl  _foo2
        .align  4
_foo2:
        rlwinm r2, r5, 0, 27, 25
        subfic r5, r2, 32
        addi r6, r2, -32
        srw r5, r4, r5
        slw r3, r3, r2
        slw r6, r4, r6
        or r3, r3, r5
        slw r4, r4, r2
        or r3, r3, r6
        blr


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30507 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-20 03:47:40 +00:00
Chris Lattner
0ea26ca45b Expand 64-bit shifts more optimally if we know that the high bit of the
shift amount is one or zero.  For example, for:

long long foo1(long long X, int C) {
  return X << (C|32);
}

long long foo2(long long X, int C) {
  return X << (C&~32);
}

we get:

_foo1:
        movb $31, %cl
        movl 4(%esp), %edx
        andb 12(%esp), %cl
        shll %cl, %edx
        xorl %eax, %eax
        ret
_foo2:
        movb $223, %cl
        movl 4(%esp), %eax
        movl 8(%esp), %edx
        andb 12(%esp), %cl
        shldl %cl, %eax, %edx
        shll %cl, %eax
        ret

instead of:

_foo1:
        subl $4, %esp
        movl %ebx, (%esp)
        movb $32, %bl
        movl 8(%esp), %eax
        movl 12(%esp), %edx
        movb %bl, %cl
        orb 16(%esp), %cl
        shldl %cl, %eax, %edx
        shll %cl, %eax
        xorl %ecx, %ecx
        testb %bl, %bl
        cmovne %eax, %edx
        cmovne %ecx, %eax
        movl (%esp), %ebx
        addl $4, %esp
        ret
_foo2:
        subl $4, %esp
        movl %ebx, (%esp)
        movb $223, %cl
        movl 8(%esp), %eax
        movl 12(%esp), %edx
        andb 16(%esp), %cl
        shldl %cl, %eax, %edx
        shll %cl, %eax
        xorl %ecx, %ecx
        xorb %bl, %bl
        testb %bl, %bl
        cmovne %eax, %edx
        cmovne %ecx, %eax
        movl (%esp), %ebx
        addl $4, %esp
        ret


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30506 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-20 03:38:48 +00:00
Evan Cheng
571c15e38a Back out Chris' last set of changes. This breaks 177.mesa and povray somehow.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30505 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-20 01:39:40 +00:00
Evan Cheng
7df4ad9a7f 80 col.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30504 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-20 01:10:02 +00:00
Andrew Lenharth
16d7955eb0 If we have an add, do it in the pointer realm, not the int realm. This is critical in the linux kernel for pointer analysis correctness
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30496 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-19 18:24:51 +00:00
Chris Lattner
2b41b8e870 Fix UnitTests/2005-05-12-Int64ToFP.c with llc-beta. In particular, do not
allow it to go into an infinite loop, filling up the disk!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30494 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-19 18:02:01 +00:00
Rafael Espindola
4d4c021758 fix header
add comments
untabify


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30486 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-19 16:41:40 +00:00
Rafael Espindola
71f3b94fa8 Implement a MachineFunctionPass to fix the mul instruction
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30485 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-19 15:49:25 +00:00
Chris Lattner
f529b08c0d item done
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30483 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-19 06:19:03 +00:00
Chris Lattner
733f576d29 implement select.ll:test19-22
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30482 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-19 06:18:21 +00:00
Chris Lattner
cf9d0acfef Fold the PPCISD shifts when presented with 0 inputs. This occurs for code
like:
long long test(long long X, int Y) {
  return 1ULL << Y;
}
long long test2(long long X, int Y) {
  return -1LL << Y;
}

which we used to compile to:

_test:
        li r2, 1
        subfic r3, r5, 32
        li r4, 0
        addi r6, r5, -32
        srw r3, r2, r3
        slw r4, r4, r5
        slw r6, r2, r6
        or r3, r4, r3
        slw r4, r2, r5
        or r3, r3, r6
        blr
_test2:
        li r2, -1
        subfic r3, r5, 32
        addi r6, r5, -32
        srw r3, r2, r3
        slw r4, r2, r5
        slw r2, r2, r6
        or r3, r4, r3
        or r3, r3, r2
        blr

Now we produce:

_test:
        li r2, 1
        addi r3, r5, -32
        subfic r4, r5, 32
        slw r3, r2, r3
        srw r4, r2, r4
        or r3, r4, r3
        slw r4, r2, r5
        blr
_test2:
        li r2, -1
        subfic r3, r5, 32
        addi r6, r5, -32
        srw r3, r2, r3
        slw r4, r2, r5
        slw r2, r2, r6
        or r3, r4, r3
        or r3, r3, r2
        blr


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30479 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-19 05:22:59 +00:00
Chris Lattner
863ac769b8 Fold extract_element(cst) to cst
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30478 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-19 05:02:39 +00:00
Chris Lattner
5c6621c3bc Minor speedup for legalize by avoiding some malloc traffic
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30477 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-19 04:51:23 +00:00
Evan Cheng
6b5578f052 Fix a typo.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30474 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-18 23:28:33 +00:00
Evan Cheng
52cc1ea2a1 Allow i32 UDIV, SDIV, UREM, SREM to be expanded into libcalls.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30470 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-18 21:49:04 +00:00
Nick Lewycky
025f4c0fad Walk down the dominator tree instead of the control flow graph. That means
that we can't modify the CFG any more, at least not until it's possible
to update the dominator tree (PR217).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30469 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-18 21:09:35 +00:00
Andrew Lenharth
2ab804c607 A pass to remove the worst of the replay trap offenders, and as a bonus, align basic blocks when it is free to do so
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30467 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-18 19:44:29 +00:00
Chris Lattner
6d7ca92bbf Fix an infinite loop building the CFE
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30465 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-18 18:27:05 +00:00
Andrew Lenharth
ea4f9d5801 Jump tables on Alpha
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30463 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-18 18:01:03 +00:00
Andrew Lenharth
303c6222a4 oops
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30462 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-18 18:00:18 +00:00
Andrew Lenharth
3fbd67898e absolute addresses must match pointer size
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30461 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-18 17:59:35 +00:00
Jim Laskey
e85fb6719a Sort out mangled names for globals
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30460 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-18 14:47:26 +00:00
Chris Lattner
4af90abc13 Implement a trivial optzn: of vastart is never called in a function that takes
... args, remove the '...'.

This is Transforms/DeadArgElim/dead_vaargs.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30459 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-18 07:02:31 +00:00
Chris Lattner
f73fb88688 add a note. Our 64-bit shifts are ~30% slower than gcc's
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30457 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-18 05:36:54 +00:00
Chris Lattner
e695a3bd32 Implement InstCombine/cast.ll:test31. This speeds up 462.libquantum by 26%.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30456 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-18 05:27:43 +00:00
Chris Lattner
79bc332ddb add a helper method
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30452 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-18 04:54:57 +00:00
Chris Lattner
b33a42a21f This is closer to what we really want.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30451 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-18 04:54:35 +00:00
Chris Lattner
b7363791ed Implement Transforms/InstCombine/shift-sra.ll:test0
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30450 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-18 04:31:40 +00:00
Chris Lattner
65b72baa59 Rewrite shift/and/compare sequences to promote better licm of the RHS.
Use isLogicalShift/isArithmeticShift to simplify code.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30448 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-18 04:22:48 +00:00
Anton Korobeynikov
bcb9770efe Added some eye-candy for Subtarget type checking
Added X86 StdCall & FastCall calling conventions. Codegen will follow.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30446 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-17 20:25:45 +00:00
Chris Lattner
2f463865c2 Add ShiftInst::isLogical/ArithmeticShift methods.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30445 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-17 19:29:56 +00:00
Chris Lattner
a5b07404f7 Add new SetCondInst::isRelational/isEquality methods. Rename
Instruction::isRelational to Instruction::isComparison.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30444 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-17 19:14:47 +00:00
Nick Lewycky
e81f725b3a Explain change with a comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30443 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-17 17:51:00 +00:00
Nick Lewycky
38c7c42a32 Fix PR912. The input to erase() must not be a reference to the data
being erased.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30442 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-17 16:23:36 +00:00
Anton Korobeynikov
93c2b37340 Small fixes for supporting dll* linkage types
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30441 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-17 13:06:18 +00:00
Chris Lattner
7ed96abc09 add a note noticed through source inspection
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30418 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-16 23:57:51 +00:00
Chris Lattner
8829dc88a8 Oh yeah, this is needed too
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30407 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-16 05:08:34 +00:00
Chris Lattner
88640b5ecd add a note
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30406 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-16 03:30:19 +00:00
Chris Lattner
f6bd07c7fe Fix Transforms/InstCombine/2006-09-15-CastToBool.ll and PR913
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30405 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-16 03:14:10 +00:00
Chris Lattner
a89654b1a1 simplify control flow, no functionality change
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30403 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-16 00:21:44 +00:00
Chris Lattner
7d7bffe157 Allow custom expand of mul
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30402 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-16 00:09:24 +00:00
Chris Lattner
cbce2f6c1b add a nate note
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30399 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-15 20:31:36 +00:00
Chris Lattner
94876527af revert previous two patches. They cause miscompilation of MultiSource/Applications/Burg
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30397 91177308-0d34-0410-b5e6-96231b3b80d8
2006-09-15 17:24:45 +00:00