summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Delete a store whose input is a load from the same pointer:Chris Lattner2007-12-291-1/+12
| | | | | | | x = load p store x -> p llvm-svn: 45398
* Tell TargetLoweringOpt whether it is running beforeChris Lattner2007-12-221-1/+1
| | | | | | or after legalize. llvm-svn: 45321
* Don't leave newly created nodes around if it turns out they are not needed.Evan Cheng2007-12-191-2/+4
| | | | llvm-svn: 45186
* Redo previous patch so optimization only done for i1.Dale Johannesen2007-12-061-16/+4
| | | | | | Simpler and safer. llvm-svn: 44663
* third time around: instead of disabling this completely,Chris Lattner2007-12-061-6/+13
| | | | | | | only disable it if we don't know it will be obviously profitable. Still fixme, but less so. :) llvm-svn: 44658
* Actually, disable this code for now. More analysis and improvements toChris Lattner2007-12-061-0/+6
| | | | | | the X86 backend are needed before this should be enabled by default. llvm-svn: 44657
* implement a readme entry, compiling the code into:Chris Lattner2007-12-061-19/+65
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | _foo: movl $12, %eax andl 4(%esp), %eax movl _array(%eax), %eax ret instead of: _foo: movl 4(%esp), %eax shrl $2, %eax andl $3, %eax movl _array(,%eax,4), %eax ret As it turns out, this triggers all the time, in a wide variety of situations, for example, I see diffs like this in various programs: - movl 8(%eax), %eax - shll $2, %eax - andl $1020, %eax - movl (%esi,%eax), %eax + movzbl 8(%eax), %eax + movl (%esi,%eax,4), %eax - shll $2, %edx - andl $1020, %edx - movl (%edi,%edx), %edx + andl $255, %edx + movl (%edi,%edx,4), %edx Unfortunately, I also see stuff like this, which can be fixed in the X86 backend: - andl $85, %ebx - addl _bit_count(,%ebx,4), %ebp + shll $2, %ebx + andl $340, %ebx + addl _bit_count(%ebx), %ebp llvm-svn: 44656
* Fix PR1842.Dale Johannesen2007-12-061-4/+16
| | | | llvm-svn: 44649
* Don't lower srem/urem X%C to X-X/C*C unless the division is actuallyDan Gohman2007-11-261-14/+18
| | | | | | | | | optimized. This avoids creating illegal divisions when the combiner is running after legalize; this fixes PR1815. Also, it produces better code in the included testcase by avoiding the subtract and multiply when the division isn't optimized. llvm-svn: 44341
* Move MinAlign to MathExtras.h.Duncan Sands2007-11-091-1/+0
| | | | llvm-svn: 43944
* Fix some load/store logic that would be wrong forDuncan Sands2007-11-091-4/+8
| | | | | | | | apints on big-endian machines if the bitwidth is not a multiple of 8. Introduce a new helper, MVT::getStoreSizeInBits, and use it. llvm-svn: 43934
* If both parts of smul_lohi, etc. are used, don't simplify. If only one part ↵Evan Cheng2007-11-081-30/+31
| | | | | | is used, try simplify it. llvm-svn: 43888
* Typo.Evan Cheng2007-10-301-1/+1
| | | | llvm-svn: 43511
* Fix a DAGCombiner abort on a bitcast from a scalar to a vector.Dan Gohman2007-10-291-1/+2
| | | | llvm-svn: 43470
* Enable more fold (sext (load x)) -> (sext (truncate (sextload x)))Evan Cheng2007-10-291-24/+134
| | | | | | | | transformation. Previously, it's restricted by ensuring the number of load uses is one. Now the restriction is loosened up by allowing setcc uses to be "extended" (e.g. setcc x, c, eq -> setcc sext(x), sext(c), eq). llvm-svn: 43465
* The guaranteed alignment of ptr+offset is only the minimum ofDuncan Sands2007-10-281-9/+13
| | | | | | | | | | | | | | | | | | | of offset and the alignment of ptr if these are both powers of 2. While the ptr alignment is guaranteed to be a power of 2, there is no reason to think that offset is. For example, if offset is 12 (the size of a long double on x86-32 linux) and the alignment of ptr is 8, then the alignment of ptr+offset will in general be 4, not 8. Introduce a function MinAlign, lifted from gcc, for computing the minimum guaranteed alignment. I've tried to fix up everywhere under lib/CodeGen/SelectionDAG/. I also changed some places that weren't wrong (because both values were a power of 2), as a defensive change against people copying and pasting the code. Hopefully someone who cares about alignment will review the rest of LLVM and fix up the remaining places. Since I'm on x86 I'm not very motivated to do this myself... llvm-svn: 43421
* Redo "last ppc long double fix" as Chris wants.Dale Johannesen2007-10-191-1/+1
| | | | llvm-svn: 43189
* More ppcf128 issues (maybe the last)?Dale Johannesen2007-10-191-1/+1
| | | | llvm-svn: 43160
* Disable attempts to constant fold PPC f128.Dale Johannesen2007-10-161-12/+16
| | | | | | | Remove the assumption that this will happen from various places. llvm-svn: 43053
* One mundane change: Change ReplaceAllUsesOfValueWith to *optionally* Chris Lattner2007-10-151-19/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | take a deleted nodes vector, instead of requiring it. One more significant change: Implement the start of a legalizer that just works on types. This legalizer is designed to run before the operation legalizer and ensure just that the input dag is transformed into an output dag whose operand and result types are all legal, even if the operations on those types are not. This design/impl has the following advantages: 1. When finished, this will *significantly* reduce the amount of code in LegalizeDAG.cpp. It will remove all the code related to promotion and expansion as well as splitting and scalarizing vectors. 2. The new code is very simple, idiomatic, and modular: unlike LegalizeDAG.cpp, it has no 3000 line long functions. :) 3. The implementation is completely iterative instead of recursive, good for hacking on large dags without blowing out your stack. 4. The implementation updates nodes in place when possible instead of deallocating and reallocating the entire graph that points to some mutated node. 5. The code nicely separates out handling of operations with invalid results from operations with invalid operands, making some cases simpler and easier to understand. 6. The new -debug-only=legalize-types option is very very handy :), allowing you to easily understand what legalize types is doing. This is not yet done. Until the ifdef added to SelectionDAGISel.cpp is enabled, this does nothing. However, this code is sufficient to legalize all of the code in 186.crafty, olden and freebench on an x86 machine. The biggest issues are: 1. Vectors aren't implemented at all yet 2. SoftFP is a mess, I need to talk to Evan about it. 3. No lowering to libcalls is implemented yet. 4. Various operations are missing etc. 5. There are FIXME's for stuff I hax0r'd out, like softfp. Hey, at least it is a step in the right direction :). If you'd like to help, just enable the #ifdef in SelectionDAGISel.cpp and compile code with it. If this explodes it will tell you what needs to be implemented. Help is certainly appreciated. Once this goes in, we can do three things: 1. Add a new pass of dag combine between the "type legalizer" and "operation legalizer" passes. This will let us catch some long-standing isel issues that we miss because operation legalization often obfuscates the dag with target-specific nodes. 2. We can rip out all of the type legalization code from LegalizeDAG.cpp, making it much smaller and simpler. When that happens we can then reimplement the core functionality left in it in a much more efficient and non-recursive way. 3. Once the whole legalizer is non-recursive, we can implement whole-function selectiondags maybe... llvm-svn: 42981
* Enhance the truncstore optimization code to handle shiftedChris Lattner2007-10-131-2/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | values and propagate demanded bits through them in simple cases. This allows this code: void foo(char *P) { strcpy(P, "abc"); } to compile to: _foo: ldrb r3, [r1] ldrb r2, [r1, #+1] ldrb r12, [r1, #+2]! ldrb r1, [r1, #+1] strb r1, [r0, #+3] strb r2, [r0, #+1] strb r12, [r0, #+2] strb r3, [r0] bx lr instead of: _foo: ldrb r3, [r1, #+3] ldrb r2, [r1, #+2] orr r3, r2, r3, lsl #8 ldrb r2, [r1, #+1] ldrb r1, [r1] orr r2, r1, r2, lsl #8 orr r3, r2, r3, lsl #16 strb r3, [r0] mov r2, r3, lsr #24 strb r2, [r0, #+3] mov r2, r3, lsr #16 strb r2, [r0, #+2] mov r3, r3, lsr #8 strb r3, [r0, #+1] bx lr testcase here: test/CodeGen/ARM/truncstore-dag-combine.ll This also helps occasionally for X86 and other cases not involving unaligned load/stores. llvm-svn: 42954
* Add a simple optimization to simplify the input toChris Lattner2007-10-131-0/+42
| | | | | | | truncate and truncstore instructions, based on the knowledge that they don't demand the top bits. llvm-svn: 42952
* Correct swapped arguments to getConstant.Duncan Sands2007-10-101-1/+1
| | | | llvm-svn: 42824
* DAGCombiner support for UDIVREM/SDIVREM and UMUL_LOHI/SMUL_LOHI. Dan Gohman2007-10-081-17/+137
| | | | | | | | | Check if one of the two results unneeded so see if a simpler operator could bs used. Also check to see if each of the two computations could be simplified if they were split into separate operators. Factor out the code that calls visit() so that it can be used for this purpose. llvm-svn: 42759
* Reapply 42677.Evan Cheng2007-10-061-3/+52
| | | | llvm-svn: 42692
* revert evan's patch until the header is committedChris Lattner2007-10-061-52/+3
| | | | llvm-svn: 42686
* Added DAG xforms. e.g.Evan Cheng2007-10-061-3/+52
| | | | | | | | (vextract (v4f32 s2v (f32 load $addr)), 0) -> (f32 load $addr) (vextract (v4i32 bc (v4f32 s2v (f32 load $addr))), 0) -> (i32 load $addr) Remove x86 specific patterns. llvm-svn: 42677
* Fix a bogus splat xform:Evan Cheng2007-09-181-2/+1
| | | | | | | | shuffle <undef, undef, x, undef>, <undef, undef, undef, undef>, <2, 2, 2, 2> != <undef, undef, x, undef> llvm-svn: 42111
* Prevent crash on long double.Dale Johannesen2007-09-181-0/+4
| | | | llvm-svn: 42103
* Revise previous patch per review comments.Dale Johannesen2007-09-121-5/+5
| | | | | | | Next round of x87 long double stuff. Getting close now, basically works. llvm-svn: 41875
* Add APInt interfaces to APFloat (allows directlyDale Johannesen2007-09-111-3/+5
| | | | | | | | | access to bits). Use them in place of float and double interfaces where appropriate. First bits of x86 long double constants handling (untested, probably does not work). llvm-svn: 41858
* Emit:Chris Lattner2007-09-101-0/+10
| | | | | | | | | | | | | | | | | cmpl %eax, %ecx setae %al movzbl %al, %eax instead of: cmpl %eax, %ecx setb %al xorb $1, %al movzbl %al, %eax when using logical not of a C comparison. llvm-svn: 41807
* Add mod, copysign, abs operations to APFloat.Dale Johannesen2007-08-311-7/+9
| | | | | | | | Implement some constant folding in SelectionDAG and DAGCombiner using APFloat. Remove double versions of constructor and getValue from ConstantFPSDNode. llvm-svn: 41664
* Make DAGCombiner's global alias analysis query more precise in the caseDan Gohman2007-08-271-2/+3
| | | | | | where both pointers have non-zero offsets. llvm-svn: 41491
* Revise per review comments.Dale Johannesen2007-08-261-1/+1
| | | | llvm-svn: 41409
* Add APFloat interface to ConstantFPSDNode. ChangeDale Johannesen2007-08-251-10/+6
| | | | | | | over uses in DAGCombiner. Fix interfaces to work with APFloats. llvm-svn: 41407
* Fold C ? 0 : 1 to ~C or zext(~C) or trunc(~C) depending the types.Evan Cheng2007-08-181-3/+14
| | | | llvm-svn: 41163
* Fix the alias analysis query in DAGCombiner to not add in twoDan Gohman2007-07-261-2/+2
| | | | | | | offsets. The SrcValueOffset values are the real offsets from the SrcValue base pointers. llvm-svn: 40534
* Don't call SimplifyVBinOp for non-vector operations, following earlier reviewDan Gohman2007-07-131-25/+49
| | | | | | feedback. This theoretically makes the common (scalar) case more efficient. llvm-svn: 39823
* Fix a bug in the folding of binary operators to undef.Dan Gohman2007-07-101-4/+10
| | | | | | Thanks to Lauro for spotting this! llvm-svn: 38491
* Fix the folding of undef in several binary operators to recognizeDan Gohman2007-07-101-7/+7
| | | | | | undef in either the left or right operand. llvm-svn: 38489
* Preserve volatililty and alignment information when lowering orDan Gohman2007-07-091-9/+22
| | | | | | simplifying loads and stores. llvm-svn: 38473
* Fix this warning:Chris Lattner2007-07-091-1/+1
| | | | | | | | | DAGCombiner.cpp: In member function 'llvm::SDOperand<unnamed>::DAGCombiner::visitOR(llvm::SDNode*)': DAGCombiner.cpp:1608: warning: passing negative value '-0x00000000000000001' for argument 1 to 'llvm::SDOperand llvm::SelectionDAG::getConstant(uint64_t, llvm::MVT::ValueType, bool)' oiy. llvm-svn: 38458
* Fix several over-aggressive folds for undef nodes in dagcombine, toDan Gohman2007-07-031-51/+46
| | | | | | follow the rules for undef used in instcombine. llvm-svn: 37851
* Teach GetNegatedExpression to negate 0-B to B in UnsafeFPMath mode, andDan Gohman2007-07-021-11/+14
| | | | | | | | | | visitFSUB to fold 0-B to -B in UnsafeFPMath mode. Also change visitFNEG to use isNegatibleForFree/GetNegatedExpression instead of doing a subset of the same thing manually. This fixes test/CodeGen/X86/negative-sin.ll. llvm-svn: 37842
* Generalize MVT::ValueType and associated functions to be able to representDan Gohman2007-06-251-292/+240
| | | | | | | | | | | | | | | extended vector types. Remove the special SDNode opcodes used for pre-legalize vector operations, and the special MVT::Vector type used with them. Adjust lowering and legalize to work with the normal SDNode kinds instead, and to use the normal MVT functions to work with vector types instead of using the two special operands that the pre-legalize nodes held. This allows pre-legalize and post-legalize DAGs, and the code that operates on them, to be more consistent. Pre-legalize vector operators can be handled more consistently with scalar operators. And, -view-dag-combine1-dags and -view-legalize-dags now look prettier for vector code. llvm-svn: 37719
* Move ComputeMaskedBits, MaskedValueIsZero, and ComputeNumSignBits fromDan Gohman2007-06-221-23/+23
| | | | | | | | | TargetLowering to SelectionDAG so that they have more convenient access to the current DAG, in preparation for the ValueType routines being changed from standalone functions to members of SelectionDAG for the pre-legalize vector type changes. llvm-svn: 37704
* Xforms:Evan Cheng2007-06-211-0/+64
| | | | | | | (add (select cc, 0, c), x) -> (select cc, x, (add, x, c)) (sub x, (select cc, 0, c)) -> (select cc, x, (sub, x, c)) llvm-svn: 37685
* Pass a SelectionDAG into SDNode::dump everywhere it's used, in preprationDan Gohman2007-06-191-5/+5
| | | | | | | for needing the DAG node to print pre-legalize extended value types, and to get better debug messages with target-specific nodes. llvm-svn: 37656
* Rename MVT::getVectorBaseType to MVT::getVectorElementType.Dan Gohman2007-06-141-1/+1
| | | | llvm-svn: 37579
OpenPOWER on IntegriCloud