Chris Lattner
7dd540ee24
teach sext optimization to handle truncs from types that are not
...
the dest of the sext.
llvm-svn: 93128
2010-01-10 20:30:41 +00:00
Chris Lattner
39d2daa94c
teach zext optimization how to deal with truncs that don't come from
...
the zext dest type. This allows us to handle test52/53 in cast.ll,
and allows llvm-gcc to generate much better code for PR4216 in -m64
mode:
_test_bitfield: ## @test_bitfield
orl $32962, %edi
movl %edi, %eax
andl $-25350, %eax
ret
This also fixes a bug handling vector extends, ensuring that the
mask produced is a vector constant, not an integer constant.
llvm-svn: 93127
2010-01-10 20:25:54 +00:00
Chris Lattner
1a05fddcdc
simplify CanEvaluateSExtd to return a bool now that we have a
...
simpler profitability predicate.
llvm-svn: 93111
2010-01-10 07:57:20 +00:00
Chris Lattner
d7816780e2
the NumCastsRemoved argument to CanEvaluateSExtd is dead, remove it.
...
llvm-svn: 93110
2010-01-10 07:42:21 +00:00
Chris Lattner
2fff10c424
now that the cost model has changed, we can always consider
...
elimination of a sign extend to be a win, which simplifies
the client of CanEvaluateSExtd, and allows us to eliminate
more casts (examples taken from real code).
llvm-svn: 93109
2010-01-10 07:40:50 +00:00
Chris Lattner
d8509424a4
change the preferred canonical form for a sign extension to be
...
lshr+ashr instead of trunc+sext. We want to avoid type
conversions whenever possible, it is easier to codegen expressions
without truncates and extensions.
llvm-svn: 93107
2010-01-10 07:08:30 +00:00
Chris Lattner
2b459fe7e1
fix indentation of switch statements, no functionality change.
...
llvm-svn: 93106
2010-01-10 06:59:55 +00:00
Chris Lattner
127bbc715e
fix pasto that broke bootstrap.
...
llvm-svn: 93105
2010-01-10 06:50:04 +00:00
Chris Lattner
b7be7cc486
simplify CanEvaluateZExtd now that we don't care about the number of
...
bits known clear in the result and don't care about the # casts
eliminated. TD is also dead but keeping it for now.
llvm-svn: 93098
2010-01-10 02:50:04 +00:00
Chris Lattner
49d2c9764d
two changes:
...
1) don't try to optimize a sext or zext that is only used by a trunc, let
the trunc get optimized first. This avoids some pointless effort in
some common cases since instcombine scans down a block in the first pass.
2) Change the cost model for zext elimination to consider an 'and' cheaper
than a zext. This allows us to do it more aggressively, and for the next
patch to simplify the code quite a bit.
llvm-svn: 93097
2010-01-10 02:39:31 +00:00
Chris Lattner
f0af17dab3
enhance CanEvaluateZExtd to handle shift left and sext, allowing
...
more expressions to be promoted and casts eliminated.
llvm-svn: 93096
2010-01-10 02:22:12 +00:00
Chris Lattner
7723e2b10f
remove an xform subsumed by EvaluateInDifferentType.
...
llvm-svn: 93095
2010-01-10 01:35:55 +00:00
Chris Lattner
c95a7a21b7
clean up this xform by using m_Trunc.
...
llvm-svn: 93092
2010-01-10 01:04:31 +00:00
Chris Lattner
883550afe8
inline and remove the rest of commonIntCastTransforms.
...
llvm-svn: 93091
2010-01-10 01:00:46 +00:00
Chris Lattner
c3aca38468
Inline the expression type promotion/demotion stuff out of
...
commonIntCastTransforms into the callers, eliminating a switch,
and allowing the static predicate methods to be moved down to
live next to the corresponding function. No functionality
change.
llvm-svn: 93089
2010-01-10 00:58:42 +00:00
Eric Christopher
4a1d7e1506
Remove unnecessary dyn_cast and add a comment. Part of a WIP.
...
llvm-svn: 93026
2010-01-08 21:37:11 +00:00
Chris Lattner
9242ae047c
mplement a theoretical fixme.
...
llvm-svn: 93024
2010-01-08 19:28:47 +00:00
Chris Lattner
10840e9e13
rename CanEvaluateInDifferentType -> CanEvaluateTruncated and
...
simplify it now that it is only used for truncates.
llvm-svn: 93021
2010-01-08 19:19:23 +00:00
Chris Lattner
a1e223ea10
teach instcombine to delete sign extending shift pairs (sra(shl X, C), C) when
...
the input is already sign extended.
llvm-svn: 93019
2010-01-08 19:04:21 +00:00
Chris Lattner
8c92b57df9
tidy up some stuff duncan pointed out.
...
llvm-svn: 93007
2010-01-08 17:48:19 +00:00
Chris Lattner
35d3b9dcd0
teach ComputeNumSignBits to look through PHI nodes.
...
llvm-svn: 92964
2010-01-07 23:44:37 +00:00
Chris Lattner
3057c37959
Enhance instcombine to reason more strongly about promoting computation
...
that feeds into a zext, similar to the patch I did yesterday for sext.
There is a lot of room for extension beyond this patch.
llvm-svn: 92962
2010-01-07 23:41:00 +00:00
Eric Christopher
2cdb806fd8
Move the object size intrinsic optimization to inst-combine and make
...
it work for any integer size return type.
llvm-svn: 92853
2010-01-06 20:04:44 +00:00
Chris Lattner
4339f2abdb
tweaks suggested by Duncan
...
llvm-svn: 92824
2010-01-06 05:32:15 +00:00
Chris Lattner
98748c0964
Teach instcombine's sext elimination logic to be more aggressive.
...
Previously, instcombine would only promote an expression tree to
the larger type if doing so eliminated two casts. This is because
a need to manually do the sign extend after the promoted expression
tree with two shifts. Now, we keep track of whether the result of
the computation is going to be properly sign extended already. If
so, we can unconditionally promote the expression, which allows us
to zap more sext's.
This implements rdar://6598839 (aka gcc pr38751)
llvm-svn: 92815
2010-01-06 01:56:21 +00:00
Chris Lattner
8600dd3d7c
simplify this code.
...
llvm-svn: 92800
2010-01-05 23:00:30 +00:00
Chris Lattner
554d0564ff
make this a static function instead of a method.
...
llvm-svn: 92795
2010-01-05 22:30:42 +00:00
Chris Lattner
a93c63c22d
more rearrangement and cleanup, fix my test failure.
...
llvm-svn: 92792
2010-01-05 22:21:18 +00:00
Chris Lattner
f476ef502c
cleanup
...
llvm-svn: 92790
2010-01-05 22:07:33 +00:00
Chris Lattner
f88dd5ed64
remove two trunc xforms that are subsumed by EvaluateInDifferentType.
...
The only difference is that EvaluateInDifferentType checks to ensure
they are profitable before doing them :)
llvm-svn: 92788
2010-01-05 22:01:41 +00:00
Chris Lattner
44a63815b9
just remove this xform which is subsumed by others.
...
llvm-svn: 92775
2010-01-05 21:16:30 +00:00
Chris Lattner
b82a840eb2
move a trunc-specific transform out of commonIntCastTransforms into visitTrunc.
...
llvm-svn: 92773
2010-01-05 21:11:17 +00:00
Benjamin Kramer
d2564e3afb
Move remaining stuff to the isInteger predicate.
...
llvm-svn: 92771
2010-01-05 21:05:54 +00:00
Chris Lattner
fd7e42b65d
move a zext specific xform out of commonIntCastTransforms into visitZExt and modernize it.
...
llvm-svn: 92770
2010-01-05 21:04:47 +00:00
Chris Lattner
aaccc8de62
move a trunc-specific xform out of commonIntCastTransforms into visitTrunc
...
llvm-svn: 92768
2010-01-05 20:57:30 +00:00
Chris Lattner
dec6847bf6
reduce indentation
...
llvm-svn: 92766
2010-01-05 20:56:24 +00:00
Benjamin Kramer
a81a6dff0d
Convert a ton of simple integer type equality tests to the new predicate.
...
llvm-svn: 92760
2010-01-05 20:07:06 +00:00
Chris Lattner
54f4e39956
optimize comparisons against cttz/ctlz/ctpop, patch by Alastair Lynn!
...
llvm-svn: 92745
2010-01-05 18:09:56 +00:00
Dan Gohman
28943873e6
Use do+while instead of while for loops which obviously have a
...
non-zero trip count. Use SmallVector's pop_back_val().
llvm-svn: 92734
2010-01-05 16:27:25 +00:00
Benjamin Kramer
f7cc698b69
Add newline at EOF.
...
llvm-svn: 92727
2010-01-05 13:32:48 +00:00
Benjamin Kramer
ccce8bae14
Avoid going through the LLVMContext for type equality where it's safe to dereference the type pointer.
...
llvm-svn: 92726
2010-01-05 13:12:22 +00:00
Chris Lattner
223812d547
prune some #includes.
...
llvm-svn: 92712
2010-01-05 07:54:43 +00:00
Chris Lattner
0a8191ee88
split and/or/xor out into one overly-large (2000LOC) file. However, I think
...
it does make sense to keep them together, at least for now.
llvm-svn: 92711
2010-01-05 07:50:36 +00:00
Chris Lattner
ed41b14f54
missed file with previous commit.
...
llvm-svn: 92710
2010-01-05 07:45:02 +00:00
Chris Lattner
dc67e13442
split instcombine of shifts out to its own file.
...
llvm-svn: 92709
2010-01-05 07:44:46 +00:00
Chris Lattner
e903f38b4d
eliminate getBitCastOperand and simplify some over-complex inbounds stuff.
...
llvm-svn: 92708
2010-01-05 07:42:10 +00:00
Chris Lattner
7a9e47ac4b
split call handling out to InstCombineCalls.cpp
...
llvm-svn: 92707
2010-01-05 07:32:13 +00:00
Chris Lattner
9da1cb243b
optimize cttz and ctlz when we can prove something about the
...
leading/trailing bits. Patch by Alastair Lynn!
llvm-svn: 92706
2010-01-05 07:23:56 +00:00
Chris Lattner
85e65e58ac
this inline function moved to addsub
...
llvm-svn: 92705
2010-01-05 07:20:54 +00:00
Chris Lattner
82aa888e8c
split add/sub out to its own file. Eliminate use of
...
dyn_castNotVal in the X+~X transform. dyn_castNotVal is
dramatic overkill for what the xform needed.
llvm-svn: 92704
2010-01-05 07:18:46 +00:00
Chris Lattner
c7de92ae15
all the places we use hasOneUse() we know are instructions, so inline
...
and simplify.
llvm-svn: 92700
2010-01-05 07:04:23 +00:00
Chris Lattner
c6493f070e
eliminate AssociativeOpt and its last uses.
...
llvm-svn: 92697
2010-01-05 07:01:16 +00:00
Chris Lattner
94694c7f0b
inline the FoldICmpLogical functor.
...
llvm-svn: 92695
2010-01-05 06:59:49 +00:00
Chris Lattner
98d48a0b76
inline the 'AddRHS' transformation, simplifying things significantly.
...
Eliminate the 'AddMaskingAnd' transformation, it is redundant with this
more general code right below it:
// A+B --> A|B iff A and B have no bits set in common.
llvm-svn: 92693
2010-01-05 06:29:13 +00:00
Chris Lattner
39b063bf37
remove massive over-genality manifested as a big template
...
that got instantiated. There is no reason for instcombine
to try this hard for simple associative optimizations. Next
up, eliminate the template completely.
llvm-svn: 92692
2010-01-05 06:24:06 +00:00
Chris Lattner
dc054bf39a
split mul/div/rem instructions out to their own file.
...
llvm-svn: 92689
2010-01-05 06:09:35 +00:00
Chris Lattner
1e7b7b50b1
clean up header.
...
llvm-svn: 92688
2010-01-05 06:05:07 +00:00
Chris Lattner
8f771cb78f
split select out to its own file.
...
llvm-svn: 92687
2010-01-05 06:03:12 +00:00
Chris Lattner
a65e2f7304
split out load/store/alloca.
...
llvm-svn: 92685
2010-01-05 05:57:49 +00:00
Chris Lattner
841af4f03d
reduce indentation
...
llvm-svn: 92684
2010-01-05 05:42:08 +00:00
Chris Lattner
ec97a90221
split vector stuff out to InstCombineVectorOps.cpp
...
llvm-svn: 92683
2010-01-05 05:36:20 +00:00
Chris Lattner
de1feded32
split PHI node stuff out to InstCombinePHI.cpp
...
llvm-svn: 92682
2010-01-05 05:31:55 +00:00
Chris Lattner
27acfcd1c4
convert various IntrinsicInst's to use class instead of struct.
...
llvm-svn: 92681
2010-01-05 05:21:26 +00:00
Devang Patel
be94f23992
Remove dead debug info intrinsics.
...
Intrinsic::dbg_stoppoint
Intrinsic::dbg_region_start
Intrinsic::dbg_region_end
Intrinsic::dbg_func_start
AutoUpgrade simply ignores these intrinsics now.
llvm-svn: 92557
2010-01-05 01:10:40 +00:00
Daniel Dunbar
72a87448c1
Fix some struct/class specifier mismatches.
...
llvm-svn: 92550
2010-01-05 00:15:58 +00:00
Chris Lattner
a751d09c08
Truncate GEP indexes larger than the pointer size down to pointer size
...
when doing this transform if the GEP is not inbounds. No testcase because
it is very difficult to trigger this: instcombine already canonicalizes
GEP indices to pointer size, so it relies specific permutations of the
instcombine worklist.
Thanks to Duncan for pointing this possible problem out.
llvm-svn: 92495
2010-01-04 18:57:15 +00:00
Chris Lattner
2cb08e69b1
silence a bogus 'might be used uninit' warning from GCC.
...
llvm-svn: 92494
2010-01-04 18:48:26 +00:00
Chris Lattner
59d95743c8
move some more cast-related stuff
...
llvm-svn: 92471
2010-01-04 07:59:07 +00:00
Chris Lattner
92be2adba6
move the [Can]EvaluateInDifferentType functions out to InstCombineCasts.cpp
...
llvm-svn: 92469
2010-01-04 07:54:59 +00:00
Chris Lattner
2b295a0eba
split 943 lines of instcombine out to a new InstCombineCasts.cpp
...
file. InstructionCombining.cpp is now down to a svelte 9300 lines :)
llvm-svn: 92468
2010-01-04 07:53:58 +00:00
Chris Lattner
2188e40e4c
split instcombine of compares (visit[FI]Cmp) out to
...
a new InstCombineCompares.cpp file.
llvm-svn: 92467
2010-01-04 07:37:31 +00:00
Chris Lattner
6ea40f1542
update cmakefile
...
llvm-svn: 92466
2010-01-04 07:19:55 +00:00
Chris Lattner
7e0449172c
move the 'SimplifyDemandedFoo' methods out to their own file, cutting 1K lines out of instcombine.cpp
...
llvm-svn: 92465
2010-01-04 07:17:19 +00:00
Chris Lattner
35522b7465
split the instcombine class definition out to a header shared
...
among the instcombine library.
llvm-svn: 92463
2010-01-04 07:12:23 +00:00
Chris Lattner
b8906bda13
remove a ton of unneeded LLVMContext stuff.
...
llvm-svn: 92462
2010-01-04 07:02:48 +00:00
Chris Lattner
66c2e54bcd
move InstCombineWorklist out to its own header.
...
llvm-svn: 92461
2010-01-04 06:30:00 +00:00
Chris Lattner
e2b9da98b0
forgot to svn add these.
...
llvm-svn: 92460
2010-01-04 06:28:20 +00:00
Chris Lattner
c0e6640d3a
move instcombine to its own library, it's past time.
...
llvm-svn: 92459
2010-01-04 06:23:24 +00:00