Commit Graph

1487 Commits

Author SHA1 Message Date
Wojciech Matyjewicz
ed2232502e 1. "Upgrage" comments.
2. Using zero-extended value of Scale and unsigned division is safe provided
   that Scale doesn't have the sign bit set.
   Previously these 2 instructions:
        %p = bitcast [100 x {i8,i8,i8}]* %x to i8*
        %q = getelementptr i8* %p, i32 -4
   were combined into:
        %q = getelementptr [100 x { i8, i8, i8 }]* %x, i32 0,
               i32 1431655764, i32 0
   what was incorrect.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44936 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-12 15:21:32 +00:00
Chris Lattner
1afab9c1e0 Implement constant folding if vector<->vector bitcasts where the number
of source/dest elements changes.  This implements
test/Transforms/InstCombine/bitcast-vector-fold.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44855 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-11 07:29:44 +00:00
Chris Lattner
f286f6fd93 Fix PR1850 by removing an unsafe transformation from VMCore/ConstantFold.cpp.
Reimplement the xform in Analysis/ConstantFolding.cpp where we can use
targetdata to validate that it is safe.  While I'm in there, fix some const
correctness issues and generalize the interface to the "operand folder".


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44817 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-10 22:53:04 +00:00
Duncan Sands
cbb8badce8 Make PruneEH update the nounwind/noreturn attributes
on functions as it calculates them.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44802 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-10 19:09:40 +00:00
Devang Patel
5ffdc56f53 If ExitValue operand is also defined in Loop header then
insert new ExitValue after this operand definition.

This fixes PR1828.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44539 91177308-0d34-0410-b5e6-96231b3b80d8
2007-12-03 19:17:21 +00:00
Duncan Sands
afa3b6da11 Add some convenience methods for querying attributes, and
use them.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44403 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-28 17:07:01 +00:00
Duncan Sands
dc024674ff Fix PR1146: parameter attributes are longer part of
the function type, instead they belong to functions
and function calls.  This is an updated and slightly
corrected version of Reid Spencer's original patch.
The only known problem is that auto-upgrading of
bitcode files doesn't seem to work properly (see
test/Bitcode/AutoUpgradeIntrinsics.ll).  Hopefully
a bitcode guru (who might that be? :) ) will fix it.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44359 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-27 13:23:08 +00:00
Nick Lewycky
c54c561c9f Add new SCEV, SCEVSMax. This allows LLVM to analyze do-while loops.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44319 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-25 22:41:31 +00:00
Chris Lattner
cfa597569d Implement PR1822
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44318 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-25 21:27:53 +00:00
Duncan Sands
827cde1c83 Fix PR1816. If a bitcast of a function only exists because of a
trivial difference in function attributes, allow calls to it to
be converted to direct calls.  Based on a patch by Török Edwin.
While there, move the various lists of mutually incompatible
parameters etc out of the verifier and into ParameterAttributes.h.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44315 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-25 14:10:56 +00:00
Chris Lattner
9e513acd31 Fix PR1816, by correcting the broken definition of APInt::countTrailingZeros.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44296 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-23 22:42:31 +00:00
Duncan Sands
e4dc717585 Ding dong, the DoesntAccessMemoryFns and
OnlyReadsMemoryFns tables are dead!  We
get more, and more accurate, information
from gcc via the readnone and readonly
function attributes.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44288 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-23 19:30:27 +00:00
Chris Lattner
42b5e08e71 Fix a bug where we'd try to find a scev value for a bitcast operand,
even though the bitcast operand did not have integer type.  This fixes
PR1814.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44286 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-23 08:46:22 +00:00
Chris Lattner
eec8b9a7d6 Fix PR1817.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44284 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-22 23:47:13 +00:00
Duncan Sands
73d4bb6676 Turn invokes of nounwind functions into ordinary calls.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44280 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-22 22:24:59 +00:00
Duncan Sands
5ef7be79e0 Readonly/readnone functions are allowed to throw
exceptions, so don't turn invokes of them into
calls.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44278 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-22 21:40:06 +00:00
Chris Lattner
a7d1ab0ab3 Fix PR1800 by correcting mistaken logic.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44188 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-16 06:04:17 +00:00
Chris Lattner
1b12d8855d Implement PR1796 and Transforms/SimplifyCFG/noreturn-call.ll
by inserting unreachable after no-return calls.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44099 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-14 06:19:25 +00:00
Chris Lattner
59ab338882 upgrade test
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44067 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-13 21:42:48 +00:00
Chris Lattner
b42c8f7101 Implement PR1786 by iterating between dead cycle elimination
and simplifycfg in the rare cases when it is needed.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44044 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-13 07:32:38 +00:00
Chris Lattner
7b52fe7272 Tighten up a check for folding away loads from (newly constant) globals. This
fixes a crash on Transforms/GlobalOpt/2007-11-09-GEP-GEP-Crash.ll and 
rdar://5585488.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43949 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-09 17:33:02 +00:00
Andrew Lenharth
b410df995c Better check
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43897 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-08 18:45:15 +00:00
Andrew Lenharth
ab9338eb9f Fix PR1780
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43893 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-08 17:39:28 +00:00
Chris Lattner
cf5008a792 Implement PR1777 by detecting dependent phis that
all compute the same value.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43777 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-06 21:52:06 +00:00
Dan Gohman
cff550995b Fix an abort in instcombine when folding creates a vector rem instruction.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43743 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-05 23:16:33 +00:00
Devang Patel
5d01aa484f If a value is incoming from outside the loop then the value does not need remapping and the value is never tracked through LastValueMap.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43728 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-05 19:32:30 +00:00
Duncan Sands
3cb3650a27 Change uses of getTypeSize to getABITypeSize, getTypeStoreSize
or getTypeSizeInBits as appropriate in ScalarReplAggregates.
The right change to make was not always obvious, so it would
be good to have an sroa guru review this.  While there I noticed
some bugs, and fixed them: (1) arrays of x86 long double have
holes due to alignment padding, but this wasn't being spotted
by HasStructPadding (renamed to HasPadding).  The same goes
for arrays of oddly sized ints.  Vectors also suffer from this,
in fact the problem for vectors is much worse because basic
vector assumptions seem to be broken by vectors of type with
alignment padding.   I didn't try to fix any of these vector
problems.  (2) The code for extracting smaller integers from
larger ones (in the "int union" case) was wrong on big-endian
machines for integers with size not a multiple of 8, like i1.
Probably this is impossible to hit via llvm-gcc, but I fixed
it anyway while there and added a testcase.  I also got rid of
some trailing whitespace and changed a function name which
had an obvious typo in it.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43672 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-04 14:43:57 +00:00
Owen Anderson
7ebba512c3 Fix test/Transforms/DeadStoreElimination/PartialStore.ll, which had been
silently failing because of an incorrect run line for some time.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43605 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-01 05:29:16 +00:00
Chris Lattner
e41dcdc964 Fix InstCombine/2007-10-31-StringCrash.ll by removing an obvious
(in hindsight) infinite recursion.  Simplify the code.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43597 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-01 02:30:35 +00:00
Chris Lattner
74e012afd3 Fix InstCombine/2007-10-31-RangeCrash.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43596 91177308-0d34-0410-b5e6-96231b3b80d8
2007-11-01 02:18:41 +00:00
Dan Gohman
d61de35564 Add support for folding binary operators with vector zero operands.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43510 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-30 19:00:49 +00:00
Chris Lattner
c20b0fbfcd update testcase
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43452 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-29 17:06:35 +00:00
Chris Lattner
cee291c505 Model stacksave and stackrestore as both writing memory, since we
don't model their dependences on allocas correctly.  This fixes
PR1745.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43442 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-29 05:47:52 +00:00
Chris Lattner
b361ec3197 Fix PR1749 and InstCombine/2007-10-28-EmptyField.ll by handling
zero-length fields better.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43427 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-29 02:40:02 +00:00
Chris Lattner
3cb63ddd51 Fix PR1752 and LoopSimplify/2007-10-28-InvokeCrash.ll: terminators
can have uses too.  Wouldn't it be nice if invoke didn't exist? :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43426 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-29 02:30:37 +00:00
Chris Lattner
99c65745a2 Implement a couple of foldings for ordered and unordered comparisons,
implementing cases related to PR1738.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43289 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-24 05:38:08 +00:00
Bill Wendling
80629c85f1 Don't branch fold inline asm statements.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43191 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-19 21:09:55 +00:00
Devang Patel
3305aaa350 This test now passes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43183 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-19 17:11:01 +00:00
Chris Lattner
a0bc7fc7bd Fix PR1735 and Transforms/DeadArgElim/2007-10-18-VarargsReturn.ll by
fixing some obviously broken code :(


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43141 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-18 18:49:29 +00:00
Devang Patel
cd2858ee16 XFAIL for now.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43111 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-18 00:48:43 +00:00
Devang Patel
84458323a2 Do not raise free() call that is called through invoke instruction.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43083 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-17 20:12:58 +00:00
Devang Patel
afc407ea51 Apply "Instead of loading small c string constant, use integer constant directly" transformation while processing load instruction.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43070 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-17 07:24:40 +00:00
Chris Lattner
a79dd432b3 Fix a bug in my patch last night that broke InstCombine/2007-10-12-Crash.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42920 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-12 18:05:47 +00:00
Chris Lattner
cb324cfc32 testcase for PR1728
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42890 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-12 05:29:53 +00:00
Devang Patel
f9193de25b Lower memcpy if it makes sense.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42864 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-11 17:21:57 +00:00
Devang Patel
5c4cd0d82e Fix bug in updating dominance frontier after loop
unswitch when frontier includes basic blocks that 
are not inside loop.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42654 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-05 22:29:34 +00:00
Devang Patel
bc2265abe1 Relax unsafe use check. If there is one unconditional use inside the loop then it is safe to promote value even if there is another conditional use inside the loop.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42493 91177308-0d34-0410-b5e6-96231b3b80d8
2007-10-01 18:12:58 +00:00
Devang Patel
a6dff2faeb Handle multiple induction variables.
This fixes PR714.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42309 91177308-0d34-0410-b5e6-96231b3b80d8
2007-09-25 18:24:48 +00:00
Devang Patel
453a844128 Add transformation to update loop interation space. Now,
for (i=A; i<N; i++) {
  if (i < X && i > Y)
    do_something();
}

is transformed into

U=min(N,X); L=max(A,Y);
for (i=L;i<U;i++)
  do_somethihg();                            



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42299 91177308-0d34-0410-b5e6-96231b3b80d8
2007-09-25 17:31:19 +00:00
Devang Patel
128459b85b Do not promote null values because it may be unsafe to do so.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42270 91177308-0d34-0410-b5e6-96231b3b80d8
2007-09-24 20:02:42 +00:00