summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Back out previous commit, it isn't safe.Nate Begeman2006-02-051-6/+0
| | | | llvm-svn: 26006
* fold c1 << (x + c2) into (c1 << c2) << x. fix a warning.Nate Begeman2006-02-051-1/+7
| | | | llvm-svn: 26005
* Handle urem by shifted powers of 2.Nate Begeman2006-02-051-4/+15
| | | | llvm-svn: 26001
* handle combining A / (B << N) into A >>u (log2(B)+N) when B is a power of 2Nate Begeman2006-02-051-2/+13
| | | | llvm-svn: 26000
* Add a framework for eliminating instructions that produces undemanded bits.Nate Begeman2006-02-031-10/+30
| | | | llvm-svn: 25945
* Add common code for reassociating ops in the dag combinerNate Begeman2006-02-031-50/+55
| | | | llvm-svn: 25934
* Turn any_extend nodes into zero_extend nodes when it allows us to remove anChris Lattner2006-02-021-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | and instruction. This allows us to compile stuff like this: bool %X(int %X) { %Y = add int %X, 14 %Z = setne int %Y, 12345 ret bool %Z } to this: _X: cmpl $12331, 4(%esp) setne %al movzbl %al, %eax ret instead of this: _X: cmpl $12331, 4(%esp) setne %al movzbl %al, %eax andl $1, %eax ret This occurs quite a bit with the X86 backend. For example, 25 times in lambda, 30 times in 177.mesa, 14 times in galgel, 70 times in fma3d, 25 times in vpr, several hundred times in gcc, ~45 times in crafty, ~60 times in parser, ~140 times in eon, 110 times in perlbmk, 55 on gap, 16 times on bzip2, 14 times on twolf, and 1-2 times in many other SPEC2K programs. llvm-svn: 25901
* add two dag combines:Chris Lattner2006-02-021-8/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (C1-X) == C2 --> X == C1-C2 (X+C1) == C2 --> X == C2-C1 This allows us to compile this: bool %X(int %X) { %Y = add int %X, 14 %Z = setne int %Y, 12345 ret bool %Z } into this: _X: cmpl $12331, 4(%esp) setne %al movzbl %al, %eax andl $1, %eax ret not this: _X: movl $14, %eax addl 4(%esp), %eax cmpl $12345, %eax setne %al movzbl %al, %eax andl $1, %eax ret Testcase here: Regression/CodeGen/X86/compare-add.ll nukage of the and coming up next. llvm-svn: 25898
* Fix some of the stuff in the PPC README file, and clean up legalizationNate Begeman2006-02-011-3/+49
| | | | | | of the SELECT_CC, BR_CC, and BRTWOWAY_CC nodes. llvm-svn: 25875
* Move MaskedValueIsZero from the DAGCombiner to the TargetLowering ↵Chris Lattner2006-01-301-120/+21
| | | | | | interface,making isMaskedValueZeroForTargetNode simpler, and useable from other partsof the compiler. llvm-svn: 25803
* pass the address of MaskedValueIsZero into isMaskedValueZeroForTargetNode,Chris Lattner2006-01-301-1/+1
| | | | | | to permit recursion llvm-svn: 25799
* eliminate uses of SelectionDAG::getBR2Way_CCChris Lattner2006-01-291-3/+10
| | | | llvm-svn: 25767
* Add a missing case to the dag combiner.Nate Begeman2006-01-281-2/+3
| | | | llvm-svn: 25723
* Add explicit #includes of <iostream>Chris Lattner2006-01-221-0/+1
| | | | llvm-svn: 25515
* Get rid of code in the DAGCombiner that is duplicated in SelectionDAG.cppNate Begeman2006-01-181-74/+80
| | | | | | Now all constant folding in the code generator is in one place. llvm-svn: 25426
* Fix a backwards conditional that caused an inf loop in some cases. ThisChris Lattner2006-01-181-1/+1
| | | | | | fixes: test/Regression/CodeGen/Generic/2005-01-18-SetUO-InfLoop.ll llvm-svn: 25419
* Disable two transformations that contribute to bus errors on SparcV8.Chris Lattner2006-01-151-2/+6
| | | | llvm-svn: 25339
* Add a simple missing fold to produce this:Chris Lattner2006-01-121-0/+8
| | | | | | | | | | | subfic r3, r2, 33 instead of this: subfic r2, r2, 32 addi r3, r2, 1 llvm-svn: 25255
* Don't create rotate instructions in unsupported types, because we don't haveChris Lattner2006-01-121-2/+2
| | | | | | promote/expand code yet. This fixes the 177.mesa failure on PPC. llvm-svn: 25250
* Add bswap, rotl, and rotr nodesNate Begeman2006-01-111-2/+36
| | | | | | | | | Add dag combiner code to recognize rotl, rotr Add ppc code to match rotl Targets should add rotl/rotr patterns if they have them llvm-svn: 25222
* Revert the previous check-in. Leave shl x, 1 along for target to deal with.Evan Cheng2006-01-061-3/+0
| | | | llvm-svn: 25121
* fold (shl x, 1) -> (add x, x)Evan Cheng2006-01-061-0/+3
| | | | llvm-svn: 25120
* Added initial support for DEBUG_LABEL allowing debug specific labels to beJim Laskey2006-01-051-2/+1
| | | | | | inserted in the code. llvm-svn: 25104
* Add unique id to debug location for debug label use (work in progress.)Jim Laskey2006-01-041-1/+2
| | | | llvm-svn: 25096
* Remove redundant debug locations.Jim Laskey2005-12-231-0/+34
| | | | llvm-svn: 24995
* Simplify store(bitconv(x)) to store(x). This allows us to compile this:Chris Lattner2005-12-231-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | void bar(double Y, double *X) { *X = Y; } to this: bar: save -96, %o6, %o6 st %i1, [%i2+4] st %i0, [%i2] restore %g0, %g0, %g0 retl nop instead of this: bar: save -104, %o6, %o6 st %i1, [%i6+-4] st %i0, [%i6+-8] ldd [%i6+-8], %f0 std %f0, [%i2] restore %g0, %g0, %g0 retl nop on sparcv8. llvm-svn: 24983
* fold (conv (load x)) -> (load (conv*)x).Chris Lattner2005-12-231-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This allows us to compile this: void foo(double); void bar(double *X) { foo(*X); } To this: bar: save -96, %o6, %o6 ld [%i0+4], %o1 ld [%i0], %o0 call foo nop restore %g0, %g0, %g0 retl nop instead of this: bar: save -104, %o6, %o6 ldd [%i0], %f0 std %f0, [%i6+-8] ld [%i6+-4], %o1 ld [%i6+-8], %o0 call foo nop restore %g0, %g0, %g0 retl nop on SparcV8. llvm-svn: 24982
* Fold bitconv(bitconv(x)) -> x. We now compile this:Chris Lattner2005-12-231-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | void foo(double); void bar(double X) { foo(X); } to this: bar: save -96, %o6, %o6 or %g0, %i0, %o0 or %g0, %i1, %o1 call foo nop restore %g0, %g0, %g0 retl nop instead of this: bar: save -112, %o6, %o6 st %i1, [%i6+-4] st %i0, [%i6+-8] ldd [%i6+-8], %f0 std %f0, [%i6+-16] ld [%i6+-12], %o1 ld [%i6+-16], %o0 call foo nop restore %g0, %g0, %g0 retl nop on V8. llvm-svn: 24981
* constant fold bits_convert in getNode and in the dag combiner for fp<->intChris Lattner2005-12-231-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | conversions. This allows V8 to compiles this: void %test() { call float %test2( float 1.000000e+00, float 2.000000e+00, double 3.000000e+00, double* null ) ret void } into: test: save -96, %o6, %o6 sethi 0, %o3 sethi 1049088, %o2 sethi 1048576, %o1 sethi 1040384, %o0 or %g0, %o3, %o4 call test2 nop restore %g0, %g0, %g0 retl nop instead of: test: save -112, %o6, %o6 sethi 0, %o4 sethi 1049088, %l0 st %o4, [%i6+-12] st %l0, [%i6+-16] ld [%i6+-12], %o3 ld [%i6+-16], %o2 sethi 1048576, %o1 sethi 1040384, %o0 call test2 nop restore %g0, %g0, %g0 retl nop llvm-svn: 24980
* * Fix a GlobalAddress lowering bug.Evan Cheng2005-12-211-1/+4
| | | | | | * Teach DAG combiner about X86ISD::SETCC by adding a TargetLowering hook. llvm-svn: 24921
* Don't create SEXTLOAD/ZEXTLOAD instructions that the target doesn't supportChris Lattner2005-12-151-2/+4
| | | | | | if after legalize. This fixes IA64 failures. llvm-svn: 24725
* When folding loads into ops, immediately replace uses of the op with theChris Lattner2005-12-141-6/+6
| | | | | | | | | load. This reduces number of worklist iterations and avoid missing optimizations depending on folding of things into sext_inreg nodes (which aren't supported by all targets). Tested by Regression/CodeGen/X86/extend.ll:test2 llvm-svn: 24712
* Fix the (zext (zextload)) case to trigger, similarly for sign extends.Chris Lattner2005-12-141-7/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Allow (zext (truncate)) to apply after legalize if the target supports AND (which all do). This compiles short %foo() { %tmp.0 = load ubyte* %X ; <ubyte> [#uses=1] %tmp.3 = cast ubyte %tmp.0 to short ; <short> [#uses=1] ret short %tmp.3 } to: _foo: movzbl _X, %eax ret instead of: _foo: movzbl _X, %eax movzbl %al, %eax ret thanks to Evan for pointing this out. llvm-svn: 24709
* Fix a miscompilation in crafty due to a recent patchChris Lattner2005-12-141-1/+1
| | | | llvm-svn: 24706
* Fold (zext (load x) to (zextload x).Evan Cheng2005-12-141-1/+18
| | | | llvm-svn: 24702
* Only transform (sext (truncate x)) -> (sextinreg x) if before legalize orChris Lattner2005-12-071-1/+3
| | | | | | if the target supports the resultant sextinreg llvm-svn: 24632
* Teach the dag combiner to turn a truncate/sign_extend pair into a sextinregChris Lattner2005-12-071-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | when the types match up. This allows the X86 backend to compile: sbyte %toggle_value(sbyte* %tmp.1) { %tmp.2 = load sbyte* %tmp.1 ret sbyte %tmp.2 } to this: _toggle_value: mov %EAX, DWORD PTR [%ESP + 4] movsx %EAX, BYTE PTR [%EAX] ret instead of this: _toggle_value: mov %EAX, DWORD PTR [%ESP + 4] movsx %EAX, BYTE PTR [%EAX] movsx %EAX, %AL ret noticed in Shootout/objinst. -Chris llvm-svn: 24630
* Fix operator precedence bug caught by VC++.Jeff Cohen2005-11-121-2/+2
| | | | llvm-svn: 24318
* Switch the allnodes list from a vector of pointers to an ilist of nodes.This ↵Chris Lattner2005-11-091-1/+3
| | | | | | | | eliminates the vector, allows constant time removal of a node froma graph, and makes iteration over the all nodes list stable when adding nodes to the graph. llvm-svn: 24263
* Fix a crash that Andrew noticed, and add a pair of braces to unfconfuseNate Begeman2005-11-021-5/+5
| | | | | | XCode's indenting. llvm-svn: 24159
* Fix a source of undefined behavior when dealing with 64-bit types. ThisChris Lattner2005-11-021-1/+1
| | | | | | may fix PR652. Thanks to Andrew for tracking down the problem. llvm-svn: 24145
* Codegen mul by negative power of two with a shift and negate.Chris Lattner2005-10-301-3/+13
| | | | | | | | | | | | | | | | | | | This implements test/Regression/CodeGen/PowerPC/mul-neg-power-2.ll, producing: _foo: slwi r2, r3, 1 subfic r3, r2, 63 blr instead of: _foo: mulli r2, r3, -2 addi r3, r2, 63 blr llvm-svn: 24106
* Fix DSE to not nuke dead stores unless they redundant store is the sameChris Lattner2005-10-271-1/+4
| | | | | | VT as the killing one. Fix fixes PR491 llvm-svn: 24034
* Add a simple xform that is useful for bitfield operations.Chris Lattner2005-10-271-0/+9
| | | | llvm-svn: 24029
* Clear a bit in this file that was causing a miscompilation of 178.galgel.Chris Lattner2005-10-251-1/+1
| | | | llvm-svn: 23980
* BuildSDIV and BuildUDIV only work for i32/i64, but they don't check thatChris Lattner2005-10-221-10/+20
| | | | | | | | the input is that type, this caused a failure on gs on X86 last night. Move the hard checks into Build[US]Div since that is where decisions like this should be made. llvm-svn: 23881
* add a case missing from the dag combiner that exposed the failure onChris Lattner2005-10-211-0/+3
| | | | | | 2005-10-21-longlonggtu.ll. llvm-svn: 23875
* Fix a typo in the dag combiner, so that this can work on i64 targetsNate Begeman2005-10-211-3/+2
| | | | llvm-svn: 23856
* Invert the TargetLowering flag that controls divide by consant expansion.Nate Begeman2005-10-211-10/+37
| | | | | | | | | | Add a new flag to TargetLowering indicating if the target has really cheap signed division by powers of two, make ppc use it. This will probably go away in the future. Implement some more ISD::SDIV folds in the dag combiner Remove now dead code in the x86 backend. llvm-svn: 23853
* Fix a couple bugs in the const div stuff where we'd generate MULHS/MULHUNate Begeman2005-10-201-3/+4
| | | | | | | for types that aren't legal, and fail a divisor is less than zero comparison, which would cause us to drop a subtract. llvm-svn: 23846
OpenPOWER on IntegriCloud