summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix an infinite loop where a transform in InstCombiner::visitAnd claims a ↵Eli Friedman2011-09-191-21/+22
| | | | | | | | construct is changed when it is not. (See included testcase.) Patch by Xiaoyi Guo. llvm-svn: 140072
* land David Blaikie's patch to de-constify Type, with a few tweaks.Chris Lattner2011-07-181-3/+3
| | | | llvm-svn: 135375
* Change Intrinsic::getDeclaration and friends to take an ArrayRef.Benjamin Kramer2011-07-141-2/+1
| | | | llvm-svn: 135154
* Second attempt at de-constifying LLVM Types in FunctionType::get(),Jay Foad2011-07-121-2/+2
| | | | | | StructType::get() and TargetData::getIntPtrType(). llvm-svn: 134982
* Revert r134893 and r134888 (and related patches in other trees). It was causingBill Wendling2011-07-121-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | an assert on Darwin llvm-gcc builds. Assertion failed: (castIsValid(op, S, Ty) && "Invalid cast!"), function Create, file /Users/buildslave/zorg/buildbot/smooshlab/slave-0.8/build.llvm-gcc-i386-darwin9-RA/llvm.src/lib/VMCore/Instructions.cpp, li\ ne 2067. etc. http://smooshlab.apple.com:8013/builders/llvm-gcc-i386-darwin9-RA/builds/2354 --- Reverse-merging r134893 into '.': U include/llvm/Target/TargetData.h U include/llvm/DerivedTypes.h U tools/bugpoint/ExtractFunction.cpp U unittests/Support/TypeBuilderTest.cpp U lib/Target/ARM/ARMGlobalMerge.cpp U lib/Target/TargetData.cpp U lib/VMCore/Constants.cpp U lib/VMCore/Type.cpp U lib/VMCore/Core.cpp U lib/Transforms/Utils/CodeExtractor.cpp U lib/Transforms/Instrumentation/ProfilingUtils.cpp U lib/Transforms/IPO/DeadArgumentElimination.cpp U lib/CodeGen/SjLjEHPrepare.cpp --- Reverse-merging r134888 into '.': G include/llvm/DerivedTypes.h U include/llvm/Support/TypeBuilder.h U include/llvm/Intrinsics.h U unittests/Analysis/ScalarEvolutionTest.cpp U unittests/ExecutionEngine/JIT/JITTest.cpp U unittests/ExecutionEngine/JIT/JITMemoryManagerTest.cpp U unittests/VMCore/PassManagerTest.cpp G unittests/Support/TypeBuilderTest.cpp U lib/Target/MBlaze/MBlazeIntrinsicInfo.cpp U lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp U lib/VMCore/IRBuilder.cpp G lib/VMCore/Type.cpp U lib/VMCore/Function.cpp G lib/VMCore/Core.cpp U lib/VMCore/Module.cpp U lib/AsmParser/LLParser.cpp U lib/Transforms/Utils/CloneFunction.cpp G lib/Transforms/Utils/CodeExtractor.cpp U lib/Transforms/Utils/InlineFunction.cpp U lib/Transforms/Instrumentation/GCOVProfiling.cpp U lib/Transforms/Scalar/ObjCARC.cpp U lib/Transforms/Scalar/SimplifyLibCalls.cpp U lib/Transforms/Scalar/MemCpyOptimizer.cpp G lib/Transforms/IPO/DeadArgumentElimination.cpp U lib/Transforms/IPO/ArgumentPromotion.cpp U lib/Transforms/InstCombine/InstCombineCompares.cpp U lib/Transforms/InstCombine/InstCombineAndOrXor.cpp U lib/Transforms/InstCombine/InstCombineCalls.cpp U lib/CodeGen/DwarfEHPrepare.cpp U lib/CodeGen/IntrinsicLowering.cpp U lib/Bitcode/Reader/BitcodeReader.cpp llvm-svn: 134949
* De-constify Types in FunctionType::get().Jay Foad2011-07-111-2/+2
| | | | llvm-svn: 134888
* We require threse bits to be zero, too.Benjamin Kramer2011-04-281-2/+2
| | | | | | | This shouldn't happen in practice because the icmp would be a constant. Add a check so we don't miscompile code if something goes wrong. llvm-svn: 130446
* Fix a comment.Benjamin Kramer2011-04-281-1/+1
| | | | llvm-svn: 130428
* InstCombine: Merge "(trunc x) == C1 & (and x, CA) == C2" into a single and+icmp.Benjamin Kramer2011-04-281-0/+36
| | | | | | This happens when GVN widens loads. Part of PR6627. llvm-svn: 130405
* Fix a ton of comment typos found by codespell. Patch byChris Lattner2011-04-151-1/+1
| | | | | | Luis Felipe Strano Moraes! llvm-svn: 129558
* Add an instcombine for constructs like a | -(b != c); a select is moreEli Friedman2011-04-141-1/+8
| | | | | | | canonical, and generally leads to better code. Found while looking at an article about saturating arithmetic. llvm-svn: 129545
* InstCombine: Add a few missing combines for ANDs and ORs of sign bit tests.Benjamin Kramer2011-03-291-0/+24
| | | | | | | | On x86 we now compile "if (a < 0 && b < 0)" into testl %edi, %esi js IF.THEN llvm-svn: 128496
* Make InstCombiner::FoldAndOfICmps create a ConstantRange that's theAnders Carlsson2011-03-011-8/+12
| | | | | | | | | intersection of the LHS and RHS ConstantRanges and return "false" when the range is empty. This simplifies some code and catches some extra cases. llvm-svn: 126744
* Move "A | ~(A & ?) -> -1" from InstCombine to InstructionSimplify.Benjamin Kramer2011-02-201-16/+8
| | | | llvm-svn: 126082
* InstCombine: Add a bunch of combines of the form x | (y ^ z).Benjamin Kramer2011-02-201-0/+41
| | | | | | | | | We usually catch this kind of optimization through InstSimplify's distributive magic, but or doesn't distribute over xor in general. "A | ~(A | B) -> A | ~B" hits 24 times on gcc.c. llvm-svn: 126081
* Fix 9216 - Endless loop in InstCombine pass.Nadav Rotem2011-02-151-1/+5
| | | | | | | The pattern "A&(A^B) -> A & ~B" recreated itself because ~B is actually a xor -1. llvm-svn: 125557
* tidy up a bit.Chris Lattner2011-02-151-7/+9
| | | | llvm-svn: 125546
* more cleanups, notably bitcast isn't used for "signed to unsigned type Chris Lattner2011-02-101-45/+27
| | | | | | conversions". :) llvm-svn: 125265
* Rework InstrTypes.h so to reduce the repetition around the NSW/NUW/ExactChris Lattner2011-02-091-2/+2
| | | | | | | | | | | | | | | | | versions of creation functions. Eventually, the "insertion point" versions of these should just be removed, we do have IRBuilder afterall. Do a massive rewrite of much of pattern match. It is now shorter and less redundant and has several other widgets I will be using in other patches. Among other changes, m_Div is renamed to m_IDiv (since it only matches integer divides) and m_Shift is gone (it used to match all binops!!) and we now have m_LogicalShift for the one client to use. Enhance IRBuilder to have "isExact" arguments to things like CreateUDiv and reduce redundancy within IRbuilder by having these methods chain to each other more instead of duplicating code. llvm-svn: 125194
* Just because we have determined that an (fcmp | fcmp) is true for A < B,Owen Anderson2011-01-211-1/+3
| | | | | | | A == B, and A > B, does not mean we can fold it to true. We still need to check for A ? B (A unordered B). llvm-svn: 123993
* reduce indentationChris Lattner2011-01-151-29/+29
| | | | llvm-svn: 123514
* Add a generic expansion transform: A op (B op' C) -> (A op B) op' (A op C)Duncan Sands2010-12-221-6/+9
| | | | | | | | if both A op B and A op C simplify. This fires fairly often but doesn't make that much difference. On gcc-as-one-file it removes two "and"s and turns one branch into a select. llvm-svn: 122399
* Add a check missing from my last commit and avoid a potential overflow ↵Benjamin Kramer2010-12-201-3/+3
| | | | | | situation. llvm-svn: 122258
* Reduce indentation.Benjamin Kramer2010-12-201-7/+5
| | | | llvm-svn: 122249
* Teach InstCombine to merge (icmp ult (X + CA), C1) | (icmp eq X, C2) into ↵Benjamin Kramer2010-12-201-1/+10
| | | | | | | | | | | | | | | (icmp ult (X + CA), C1 + 1) if C2 + CA == C1. InstCombine creates these so now we compile x == 23 || x == 24 || x == 25 to %x.off = add i32 %x, -23 %1 = icmp ult i32 %x.off, 3 instead of %x.off = add i32 %x, -23 %1 = icmp ult i32 %x.off, 2 %cmp3 = icmp eq i32 %x, 25 %ret2 = or i1 %1, %cmp3 llvm-svn: 122248
* Rename SimplifyDistributed to the more meaningfull name SimplifyByFactorizing.Duncan Sands2010-11-231-3/+3
| | | | llvm-svn: 120051
* Exploit distributive laws (eg: And distributes over Or, Mul over Add, etc) in aDuncan Sands2010-11-231-42/+11
| | | | | | | | | | | | fairly systematic way in instcombine. Some of these cases were already dealt with, in which case I removed the existing code. The case of Add has a bunch of funky logic which covers some of this plus a few variants (considers shifts to be a form of multiplication), which I didn't touch. The simplification performed is: A*B+A*C -> A*(B+C). The improvement is to do this in cases that were not already handled [such as A*B-A*C -> A*(B-C), which was reported on the mailing list], and also to do it more often by not checking for "only one use" if "B+C" simplifies. llvm-svn: 120024
* Move some those Xor simplifications which don't require creating newDuncan Sands2010-11-171-31/+2
| | | | | | | | instructions out of InstCombine and into InstructionSimplify. While there, introduce an m_AllOnes pattern to simplify matching with integers and vectors with all bits equal to one. llvm-svn: 119536
* Generalize the reassociation transform in SimplifyCommutative (now renamed toDuncan Sands2010-11-131-3/+3
| | | | | | | | | | | | | | | | SimplifyAssociativeOrCommutative) "(A op C1) op C2" -> "A op (C1 op C2)", which previously was only done if C1 and C2 were constants, to occur whenever "C1 op C2" simplifies (a la InstructionSimplify). Since the simplifying operand combination can no longer be assumed to be the right-hand terms, consider all of the possible permutations. When compiling "gcc as one big file", transform 2 (i.e. using right-hand operands) fires about 4000 times but it has to be said that most of the time the simplifying operands are both constants. Transforms 3, 4 and 5 each fired once. Transform 6, which is an existing transform that I didn't change, never fired. With this change, the testcase is now optimized perfectly with one run of instcombine (previously it required instcombine + reassociate + instcombine, and it may just have been luck that this worked). llvm-svn: 119002
* Re-apply r113679, which was reverted in r113720, which added a paid of new ↵Owen Anderson2010-09-131-5/+31
| | | | | | | | | instcombine transforms to expose greater opportunities for store narrowing in codegen. This patch fixes a potential infinite loop in instcombine caused by one of the introduced transforms being overly aggressive. llvm-svn: 113763
* Revert 113679, it was causing an infinite loop in a testcase that I've sentEric Christopher2010-09-121-30/+5
| | | | | | on to Owen. llvm-svn: 113720
* Invert and-of-or into or-of-and when doing so would allow us to clear bits ↵Owen Anderson2010-09-111-5/+30
| | | | | | | | | | | | | | of the and's mask. This can result in increased opportunities for store narrowing in code generation. Update a number of tests for this change. This fixes <rdar://problem/8285027>. Additionally, because this inverts the order of ors and ands, some patterns for optimizing or-of-and-of-or no longer fire in instances where they did originally. Add a simple transform which recaptures most of these opportunities: if we have an or-of-constant-or and have failed to fold away the inner or, commute the order of the two ors, to give the non-constant or a chance for simplification instead. llvm-svn: 113679
* This transform is also performed by InstructionSimplify, remove the duplicate.Benjamin Kramer2010-09-101-3/+0
| | | | llvm-svn: 113608
* Generalize instcombine's support for combining multiple bit checks into a ↵Owen Anderson2010-09-081-32/+278
| | | | | | single test. Patch by Dirk Steinke! llvm-svn: 113423
* Re-apply the infamous r108614, with a fix pointed out by Dirk Steinke.Owen Anderson2010-08-021-5/+38
| | | | llvm-svn: 110036
* Speculatively revert r108614, "Another attempt at getting the clang self-host toDaniel Dunbar2010-07-311-32/+0
| | | | | | | like my instcombine patch.", in an attempt to fix Clang i386 bootstrap. - Also PR7719. llvm-svn: 109953
* Another attempt at getting the clang self-host to like my instcombine patch.Owen Anderson2010-07-171-0/+32
| | | | llvm-svn: 108614
* Also revert 108422, it's causing some test failures.Eric Christopher2010-07-161-19/+0
| | | | | | Working on testcases for Owen. llvm-svn: 108494
* Speculatively revert r108429 to fix the clang self-host.Owen Anderson2010-07-151-19/+0
| | | | llvm-svn: 108436
* Per Chris' suggestion, get rid of the select canonicalization and just addOwen Anderson2010-07-151-0/+19
| | | | | | | | the corresponding or-icmp-and pattern. This has the added benefit of doing the matching earlier, and thus being less susceptible to being confused by earlier transforms. llvm-svn: 108429
* Reapply r108378, with bugfixes, testcase, and improved comment formatting.Owen Anderson2010-07-151-0/+19
| | | | | | This now passes LIT, nighty test, and llvm-gcc bootstrap on my machine. llvm-svn: 108422
* Speculatively revert r108378; may be causing bootstrap failures.Eli Friedman2010-07-151-18/+0
| | | | llvm-svn: 108389
* Add instcombine transforms to optimize tests of multiple bits of the same ↵Owen Anderson2010-07-141-0/+18
| | | | | | value into a single larger comparison. llvm-svn: 108378
* revert r108320, I see the failures now...Chris Lattner2010-07-141-8/+0
| | | | llvm-svn: 108322
* reapply benjamin's instcombine patch, I don't see anything wrong with it and ↵Chris Lattner2010-07-141-0/+8
| | | | | | can't repro any problems with a manual self-host. llvm-svn: 108320
* Nope, still breaks the release selfhost bots :(Benjamin Kramer2010-07-121-8/+0
| | | | llvm-svn: 108153
* Reapply the "or" half of r108136, which seems to be less problematic.Benjamin Kramer2010-07-121-0/+8
| | | | llvm-svn: 108152
* Revert r108141 again, sigh.Benjamin Kramer2010-07-121-17/+0
| | | | llvm-svn: 108148
* Reapply 108136 with an ugly pasto fixed.Benjamin Kramer2010-07-121-0/+17
| | | | llvm-svn: 108141
* Move optimization to avoid redundant matching.Benjamin Kramer2010-07-121-13/+13
| | | | llvm-svn: 108140
OpenPOWER on IntegriCloud