History log of /external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
68e05fb3687ca68d5a5be49100c7c274a3185525 30-Sep-2011 Jim Grosbach <grosbach@apple.com> Don't modify constant in-place.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140875 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
cbf676b3ba907f72405a02938f5cd85fb3e6a46c 30-Sep-2011 Jim Grosbach <grosbach@apple.com> float comparison to double 'zero' constant can just be a float 'zero.'

InstCombine was incorrectly considering the conversion of the constant
zero to be unsafe.

We want to transform:
define float @bar(float %x) nounwind readnone optsize ssp {
%conv = fpext float %x to double
%cmp = fcmp olt double %conv, 0.000000e+00
%conv1 = zext i1 %cmp to i32
%conv2 = sitofp i32 %conv1 to float
ret float %conv2
}

Into:
define float @bar(float %x) nounwind readnone optsize ssp {
%cmp = fcmp olt float %x, 0.000000e+00 ; <---- This
%conv1 = zext i1 %cmp to i32
%conv2 = sitofp i32 %conv1 to float
ret float %conv2
}


rdar://10215914


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140869 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
0cc4a958f3f27dafd5c6039962f3e3ddb17ba39f 30-Sep-2011 Jim Grosbach <grosbach@apple.com> Tidy up. Trailing whitespace.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140865 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
a9390a4d5f5d568059a80970d22194b165d097a7 27-Sep-2011 Benjamin Kramer <benny.kra@googlemail.com> Stop emitting instructions with the name "tmp" they eat up memory and have to be uniqued, without any benefit.

If someone prefers %tmp42 to %42, run instnamer.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140634 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
747032522f9f3b2d9bae71aa303c1a0fd953eee9 20-Jul-2011 Eli Friedman <eli.friedman@gmail.com> Clean up includes of llvm/Analysis/ConstantFolding.h so it's included where it's used and not included where it isn't.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135628 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
db125cfaf57cc83e7dd7453de2d509bc8efd0e5e 18-Jul-2011 Chris Lattner <sabre@nondot.org> land David Blaikie's patch to de-constify Type, with a few tweaks.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135375 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
c73b24db5f6226ed44ebc44ce1c25bb357206623 15-Jul-2011 Chris Lattner <sabre@nondot.org> start using the new helper methods a bit.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135251 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
eb9a85f09e18b3fe88499710404b38d3a9128f62 14-Jul-2011 Benjamin Kramer <benny.kra@googlemail.com> Change Intrinsic::getDeclaration and friends to take an ArrayRef.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135154 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
fc6d3a49867cd38954dc40936a88f1907252c6d2 13-Jul-2011 Jay Foad <jay.foad@gmail.com> Convert InsertValueInst and ExtractValueInst APIs to use ArrayRef.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135040 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
5fdd6c8793462549e3593890ec61573da06e3346 12-Jul-2011 Jay Foad <jay.foad@gmail.com> Second attempt at de-constifying LLVM Types in FunctionType::get(),
StructType::get() and TargetData::getIntPtrType().

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134982 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
2280ebd61416b73d0b6137f275b25af82e268d1f 12-Jul-2011 Bill Wendling <isanbard@gmail.com> Revert r134893 and r134888 (and related patches in other trees). It was causing
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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134949 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
f362affa3a695164a94d275fb44d18f44ebb855a 11-Jul-2011 Jay Foad <jay.foad@gmail.com> De-constify Types in FunctionType::get().

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134888 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
fc87cdc1f4df357167a7cef91af92b5012934124 04-Jul-2011 Benjamin Kramer <benny.kra@googlemail.com> PR10267: Don't combine an equality compare with an AND into an inequality compare when the AND has more than one use.

This can pessimize code, inequalities are generally more expensive.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134379 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
e7fdcad2f2d82c81684cb9962327330786c35107 13-Jun-2011 Benjamin Kramer <benny.kra@googlemail.com> InstCombine: Fold A-b == C --> b == A-C if A and C are constants.

The backend already knew this trick.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132915 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
ffd0ae64c497d13956d16526c46245bfbf48e91f 13-Jun-2011 Benjamin Kramer <benny.kra@googlemail.com> InstCombine: Shrink ((zext X) & C1) == C2 to fold away the cast if the "zext" and the "and" have one use.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132897 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
7e7c9cc31a9c0ca337235ae04fc268e58da1d01b 13-Jun-2011 Benjamin Kramer <benny.kra@googlemail.com> Simplify code. No functionality changes, name changes aside.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132896 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
a831a9b972f1b4fa4f3457acf303abbfc71c1ede 26-May-2011 Eli Friedman <eli.friedman@gmail.com> PR9998: ashr exact %x, 31 is not equivalent to sdiv exact %x, -2147483648.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132097 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
107ffd58f70651cc928416f6aaf267accc992c23 19-May-2011 Eli Friedman <eli.friedman@gmail.com> More instcombine simplifications towards better debug locations.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131596 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
67f071e69795dca1151cdb8d57d222b6f041d748 14-May-2011 Stuart Hastings <stuart@apple.com> Avoid combining GEPs that might overflow at runtime.
rdar://problem/9267970

Patch by Julien Lerouge!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131339 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
b6e7cd655c6ee119dbeacc321ee92387f983edb0 05-May-2011 Eli Friedman <eli.friedman@gmail.com> PR9838: Fix transform introduced in r127064 to not trigger when only one side of the icmp is an exact shift.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130954 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
325eeb1cd7c3247ead1513204bc9cf4b6e883653 26-Apr-2011 Chris Lattner <sabre@nondot.org> Transform: "icmp eq (trunc (lshr(X, cst1)), cst" to "icmp (and X, mask), cst"
when X has multiple uses. This is useful for exposing secondary optimizations,
but the X86 backend isn't ready for this when X has a single use. For example,
this can disable load folding.

This is inching towards resolving PR6627.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130238 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
5036ce4a64caaeaff4b1f8f1c91836cc2e49a455 26-Apr-2011 Chris Lattner <sabre@nondot.org> some random cleanups, no functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130237 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
7a2bdde0a0eebcd2125055e0eacaca040f0b766c 15-Apr-2011 Chris Lattner <sabre@nondot.org> Fix a ton of comment typos found by codespell. Patch by
Luis Felipe Strano Moraes!



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129558 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
7ebdc37d2bbfc62ff7957b346bb3a91eb6044d5f 31-Mar-2011 Benjamin Kramer <benny.kra@googlemail.com> InstCombine: APFloat can't perform arithmetic on PPC double doubles, don't even try.

Thanks Eli!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128676 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
00e00d693c3991d85ffebf305ddbfd5dfb99ead6 31-Mar-2011 Benjamin Kramer <benny.kra@googlemail.com> InstCombine: Fix transform to use the swapped predicate.

Thanks Frits!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128628 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
68b4bd0a63156a9f57210243bc5a8959e93b24fa 31-Mar-2011 Benjamin Kramer <benny.kra@googlemail.com> InstCombine: fold fcmp (fneg x), (fneg y) -> fcmp x, y

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128627 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
0db50189dcde3408134e9011052ed8b731ec303a 31-Mar-2011 Benjamin Kramer <benny.kra@googlemail.com> InstCombine: fold fcmp pred (fneg x), C -> fcmp swap(pred) x, -C

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128626 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
b194bdc03b6aa932ba4f719a8aa02db8d498f364 31-Mar-2011 Benjamin Kramer <benny.kra@googlemail.com> InstCombine: Shrink "fcmp (fpext x), C" to "fcmp x, C" if C can be losslessly converted to the type of x.

Fixes PR9592.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128625 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
cd0274ca189040a2fd883b00a678184afc2cda3a 31-Mar-2011 Benjamin Kramer <benny.kra@googlemail.com> InstCombine: fold fcmp (fpext x), (fpext y) -> fcmp x, y.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128624 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
dcf77575d25ad4841e585afa27bc5ee62b32d9fd 08-Mar-2011 Nick Lewycky <nicholas@mxc.ca> Reorder comments to put them the right way around.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127220 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
d01f50f42ce60207ed6d27fb1778e456d83be06c 06-Mar-2011 Nick Lewycky <nicholas@mxc.ca> ConstantInt has some getters which return ConstantInt's or ConstantVector's of
the value splatted into every element. Extend this to getTrue and getFalse which
by providing new overloads that take Types that are either i1 or <N x i1>. Use
it in InstCombine to add vector support to some code, fixing PR8469!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127116 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
58bfcdbcf6a7c1cac0187f7c6beb3afe9d8f5411 05-Mar-2011 Nick Lewycky <nicholas@mxc.ca> Thread comparisons over udiv/sdiv/ashr/lshr exact and lshr nuw/nsw whenever
possible. This goes into instcombine and instsimplify because instsimplify
doesn't need to check hasOneUse since it returns (almost exclusively) constants.

This fixes PR9343 #4 #5 and #8!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127064 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
9feda1730c225589e144fb1f86a86a8cf3f39c9e 05-Mar-2011 Nick Lewycky <nicholas@mxc.ca> Try once again to optimize "icmp (srem X, Y), Y" by turning the comparison into
true/false or "icmp slt/sge Y, 0".


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127063 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
3dc7e49c70726cb47829fb892938ff75a9c9e626 28-Feb-2011 Nick Lewycky <nicholas@mxc.ca> srem doesn't actually have the same resulting sign as its numerator, you could
also have a zero when numerator = denominator. Reverts parts of r126635 and
r126637.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126644 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
b042f8e9699dd15d7ac48bb9b9475122b1673687 28-Feb-2011 Nick Lewycky <nicholas@mxc.ca> Teach InstCombine to fold "(shr exact X, Y) == 0" --> X == 0, fixing #1 from
PR9343.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126643 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
d8d1584c13c554349c235177b2b89cb5117347b2 28-Feb-2011 Nick Lewycky <nicholas@mxc.ca> The sign of an srem instruction is the sign of its dividend (the first
argument), regardless of the divisor. Teach instcombine about this and fix
test7 in PR9343!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126635 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
39a7de72c8b5013f32802ceacefaaf6697726c28 18-Feb-2011 Duncan Sands <baldrick@free.fr> Add some transforms of the kind X-Y>X -> 0>Y which are valid when there is no
overflow. These subsume some existing equality transforms, so zap those.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125843 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
a77243300ba1a40c80c0f8417ba74bb76e7de279 17-Feb-2011 Duncan Sands <baldrick@free.fr> Transform "A + B >= A + C" into "B >= C" if the adds do not wrap. Likewise for some
variations (some of these were already present so I unified the code). Spotted by my
auto-simplifier as occurring a lot.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125734 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
e5116f840eedbc3cffa31adc683b4e37d53f2c7a 13-Feb-2011 Chris Lattner <sabre@nondot.org> remove a now-unneccesary cast.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125464 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
bb75d337c4d544692cd250acba8e3507aacb7b75 13-Feb-2011 Chris Lattner <sabre@nondot.org> implement instcombine folding for things like (x >> c) < 42.
We were previously simplifying divisions, but not right shifts!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125454 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
74542aa5001fb6ff3d7d0958b5c391cde63df1ca 13-Feb-2011 Chris Lattner <sabre@nondot.org> refactor some code out into a helper method.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125451 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
b6c8cb442298c79b1319078b3038156466be0c40 11-Feb-2011 Benjamin Kramer <benny.kra@googlemail.com> Also fold (A+B) == A -> B == 0 when the add is commuted.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125411 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
b20c0b5092f11ff349855ec1e732590160aeba23 10-Feb-2011 Chris Lattner <sabre@nondot.org> Enhance the "compare with shift" and "compare with div"
optimizations to be much more aggressive in the face of
exact/nsw/nuw div and shifts. For example, these (which
are the same except the first is 'exact' sdiv:

define i1 @sdiv_icmp4_exact(i64 %X) nounwind {
%A = sdiv exact i64 %X, -5 ; X/-5 == 0 --> x == 0
%B = icmp eq i64 %A, 0
ret i1 %B
}

define i1 @sdiv_icmp4(i64 %X) nounwind {
%A = sdiv i64 %X, -5 ; X/-5 == 0 --> x == 0
%B = icmp eq i64 %A, 0
ret i1 %B
}

compile down to:

define i1 @sdiv_icmp4_exact(i64 %X) nounwind {
%1 = icmp eq i64 %X, 0
ret i1 %1
}

define i1 @sdiv_icmp4(i64 %X) nounwind {
%X.off = add i64 %X, 4
%1 = icmp ult i64 %X.off, 9
ret i1 %1
}

This happens when you do something like:
(ptr1-ptr2) == 42

where the pointers are pointers to non-unit types.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125266 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
77bc49e5e2e2a5e549d65bc0bedd86ff3df6b161 30-Jan-2011 Anders Carlsson <andersca@mac.com> Recognize and simplify

(A+B) == A -> B == 0
A == (A+B) -> B == 0



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124567 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
9d32f60a6f7dbd8e83187481cd2ae0a2f3e726ce 20-Jan-2011 Duncan Sands <baldrick@free.fr> At -O123 the early-cse pass is run before instcombine has run. According to my
auto-simplier the transform most missed by early-cse is (zext X) != 0 -> X != 0.
This patch adds this transform and some related logic to InstructionSimplify
and removes some of the logic from instcombine (unfortunately not all because
there are several situations in which instcombine can improve things by making
new instructions, whereas instsimplify is not allowed to do this). At -O2 this
often results in more than 15% more simplifications by early-cse, and results in
hundreds of lines of bitcode being eliminated from the testsuite. I did see some
small negative effects in the testsuite, for example a few additional instructions
in three programs. One program, 483.xalancbmk, got an additional 35 instructions,
which seems to be due to a function getting an additional instruction and then
being inlined all over the place.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123911 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
9922ccf4b483ce37524047879f9b2f9bb73e3ccb 16-Jan-2011 Chris Lattner <sabre@nondot.org> remove the AllowAggressive argument to FoldOpIntoPhi. It is forced to false in the
first line of the function because it isn't a good idea, even for compares.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123566 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
27a98482bd70dd12eecd02ad600f78a2fc6c16a2 15-Jan-2011 Chris Lattner <sabre@nondot.org> fix typo


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123516 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
fdb5b01df486f8fca44927a38dc9763e9d538e4c 15-Jan-2011 Chris Lattner <sabre@nondot.org> Catch ~x < cst just like ~x < ~y, we currently handle this through
means that are about to disappear.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123515 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
a33b6254bb40488a9574533cadf4cd0b701e97d1 11-Jan-2011 Owen Anderson <resistor@mac.com> Remove dead variable, const-ref-ize an APInt.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123248 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
da1c122da5e1a86c8c2bf20e47a43f5c8fefc4e2 11-Jan-2011 Owen Anderson <resistor@mac.com> Fix a random missed optimization by making InstCombine more aggressive when determining which bits are demanded by
a comparison against a constant.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123203 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
e5cbdca3bd4bc40ca31282531a9292f70648d265 19-Dec-2010 Chris Lattner <sabre@nondot.org> recognize an unsigned add with overflow idiom into uadd.
This resolves a README entry and technically resolves PR4916,
but we still get poor code for the testcase in that PR because
GVN isn't CSE'ing uadd with add, filed as PR8817.

Previously we got:

_test7: ## @test7
addq %rsi, %rdi
cmpq %rdi, %rsi
movl $42, %eax
cmovaq %rsi, %rax
ret

Now we get:

_test7: ## @test7
addq %rsi, %rdi
movl $42, %eax
cmovbq %rsi, %rax
ret



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122182 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
0fe80bbbb6a017169d273c4824903b52a7ea2414 19-Dec-2010 Chris Lattner <sabre@nondot.org> use IC.ReplaceInstUsesWith instead of a raw RAUW so that uses of
the old thing end up on the instcombine worklist. Not doing this
can cause an extra top-level iteration of instcombine, burning
compile time.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122179 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
0a62474830f50b423329470caeb9a4e4da14a607 19-Dec-2010 Chris Lattner <sabre@nondot.org> generalize the sadd creation code to not require that the
sadd formed is half the size of the original type. We can
now compile this into a sadd.i8:

unsigned char X(char a, char b) {
int res = a+b;
if ((unsigned )(res+128) > 255U)
abort();
return res;
}




git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122178 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
dd7e83737491b14ebf98e09fa6cb9b515f9f2e3e 19-Dec-2010 Chris Lattner <sabre@nondot.org> fix another miscompile in the llvm.sadd formation logic: it wasn't
checking to see if the high bits of the original add result were dead.
Inserting a smaller add and zexting back to that size is not good enough.

This is likely to be the fix for 8816.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122177 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
368397bb7de8318a4663fec846bda714ae78dd7a 19-Dec-2010 Chris Lattner <sabre@nondot.org> fix a bug (possibly 8816) in the sadd forming xform: it isn't
profitable (or safe) to promote code when the add-with-constant
has other uses.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122175 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
f0f568b49e111da1258902b73a7b9266222e1842 19-Dec-2010 Chris Lattner <sabre@nondot.org> rework the code added in r122072 to pull it out to its own
helper function, clean up comments, and reduce indentation.
No functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122174 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
e63dda51c2b230215837063dba73e9299f8c0aba 17-Dec-2010 Owen Anderson <resistor@mac.com> Reapply r121905 (automatic synthesis of @llvm.sadd.with.overflow) with a fix for a bug that manifested itself
on the DragonEgg self-host bot. Unfortunately, the testcase is pretty messy and doesn't reduce well due to
interactions with other parts of InstCombine.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122072 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
ebef48ea4b0d838d2e4f05024a517bf18b1cc110 16-Dec-2010 Duncan Sands <baldrick@free.fr> Speculatively revert commit 121905 since it looks like it might have broken the
dragonegg self-host buildbot. Original commit message:

Add an InstCombine transform to recognize instances of manual overflow-safe addition
(performing the addition in a wider type and explicitly checking for overflow), and
fold them down to intrinsics. This currently only supports signed-addition, but could
be generalized if someone works out the magic constant formulas for other operations.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121965 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
12984de3140534da4f312190118726963a2b521e 15-Dec-2010 Owen Anderson <resistor@mac.com> Add an InstCombine transform to recognize instances of manual overflow-safe addition
(performing the addition in a wider type and explicitly checking for overflow), and
fold them down to intrinsics. This currently only supports signed-addition, but could
be generalized if someone works out the magic constant formulas for other operations.

Fixes <rdar://problem/8558713>.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121905 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
40f8f6264d5af2c38e797e0dc59827cd231e8ff7 07-Dec-2010 Jay Foad <jay.foad@gmail.com> PR5207: Change APInt methods trunc(), sext(), zext(), sextOrTrunc() and
zextOrTrunc(), and APSInt methods extend(), extOrTrunc() and new method
trunc(), to be const and to return a new value instead of modifying the
object in place.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121120 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
7a874ddda037349184fbeb22838cc11a1a9bb78f 01-Dec-2010 Jay Foad <jay.foad@gmail.com> PR5207: Rename overloaded APInt methods set(), clear(), flip() to
setAllBits(), setBit(unsigned), etc.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120564 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
79b967bd9fed0a3147d704ce269af6cc26aff391 23-Nov-2010 Chris Lattner <sabre@nondot.org> duncan's spider sense was right, I completely reversed the condition
on this instcombine xform. This fixes a miscompilation of 403.gcc.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119988 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
75d8f599e72c151df48a28bebc6e4e342f469b8a 21-Nov-2010 Chris Lattner <sabre@nondot.org> optimize:
void a(int x) { if (((1<<x)&8)==0) b(); }

into "x != 3", which occurs over 100 times in 403.gcc but in no
other program in llvm-test.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119922 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
618898e933c6350f1f7976370f3822c086d70f0c 29-Jul-2010 Eli Friedman <eli.friedman@gmail.com> PR7750: !CExpr->isNullValue() only properly computes whether CExpr is nonnull
if CExpr is a ConstantInt.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@109773 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
3472766f9eb7d66f234c390ce1b3a8b76f0ee9ce 12-Jul-2010 Duncan Sands <baldrick@free.fr> Convert some tab stops into spaces.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108130 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
caf70b31b0d8cbae0f05df404dd5935c27369690 24-Jun-2010 Gabor Greif <ggreif@gmail.com> use ArgOperand API

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106752 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
1d9b973fd7e60e4149678a03aac762551c846f13 27-May-2010 Duncan Sands <baldrick@free.fr> Teach instCombine to remove malloc+free if malloc's only uses are comparisons
to null. Patch by Matti Niemenmaa.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104871 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
551754c4958086cc6910da7c950f2875e212f5cf 17-Apr-2010 Eric Christopher <echristo@apple.com> Revert 101465, it broke internal OpenGL testing.

Probably the best way to know that all getOperand() calls have been handled
is to replace that API instead of updating.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101579 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
4ec2258ffb495d7ce00177e447740ef1123a27db 16-Apr-2010 Gabor Greif <ggreif@gmail.com> reapply r101434
with a fix for self-hosting

rotate CallInst operands, i.e. move callee to the back
of the operand array

the motivation for this patch are laid out in my mail to llvm-commits:
more efficient access to operands and callee, faster callgraph-construction,
smaller compiler binary


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101465 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
607a7ab3da72a2eb53553a520507cbb8068dd1d8 16-Apr-2010 Gabor Greif <ggreif@gmail.com> back out r101423 and r101397, they break llvm-gcc self-host on darwin10

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101434 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
2ff961f66816daab8bbc58a19025161d969821c2 15-Apr-2010 Gabor Greif <ggreif@gmail.com> reapply r101364, which has been backed out in r101368
with a fix

rotate CallInst operands, i.e. move callee to the back
of the operand array

the motivation for this patch are laid out in my mail to llvm-commits:
more efficient access to operands and callee, faster callgraph-construction,
smaller compiler binary


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101397 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
9ee17208115482441953127615231c59a2f4d052 15-Apr-2010 Gabor Greif <ggreif@gmail.com> back out r101364, as it trips the linux nightlybot on some clang C++ tests

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101368 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
165dac08d1bb8428b32a5f39cdd3dbee2888987f 15-Apr-2010 Gabor Greif <ggreif@gmail.com> rotate CallInst operands, i.e. move callee to the back
of the operand array

the motivation for this patch are laid out in my mail to llvm-commits:
more efficient access to operands and callee, faster callgraph-construction,
smaller compiler binary


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101364 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
e05678132345eb8a632362dbd320ee7d36226e67 09-Apr-2010 Dan Gohman <gohman@apple.com> Add variants of ult, ule, etc. which take a uint64_t RHS, for convenience.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@100824 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
f34f48c57870cf4eb4d48e23b11e29b95d1950c3 05-Mar-2010 Chris Lattner <sabre@nondot.org> Fix PR6503. This turned into a much more interesting and nasty bug. Various
parts of the cmp|cmp and cmp&cmp folding logic wasn't prepared for vectors
(unrelated to the bug but noticed while in the code) and the code was
*definitely* not safe to use by the (cast icmp)|(cast icmp) handling logic
that I added in r95855. Fix all this up by changing the various routines
to more consistently use IRBuilder and not pass in the I which had the wrong
type.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97801 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
39516a632385cb8103c94fceb6cfed13897a24b4 24-Feb-2010 Dan Gohman <gohman@apple.com> Fix indentation.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97024 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
1df9859c40492511b8aa4321eb76496005d3b75b 16-Feb-2010 Duncan Sands <baldrick@free.fr> There are two ways of checking for a given type, for example isa<PointerType>(T)
and T->isPointerTy(). Convert most instances of the first form to the second form.
Requested by Chris.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96344 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
b0bc6c361da9009e8414efde317d9bbff755f6c0 15-Feb-2010 Duncan Sands <baldrick@free.fr> Uniformize the names of type predicates: rather than having isFloatTy and
isInteger, we now have isFloatTy and isIntegerTy. Requested by Chris!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96223 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
5f670d41318368e2a5fdc6fe2d385f003c6db68d 01-Feb-2010 Chris Lattner <sabre@nondot.org> cleanups.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94995 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
9aa1e246dd15dfc73a2f6f44766ca97ba9573c9d 08-Jan-2010 Chris Lattner <sabre@nondot.org> tidy up some stuff duncan pointed out.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93007 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
033574074d3c980057a0cb989d272ec72a8f9523 05-Jan-2010 Chris Lattner <sabre@nondot.org> optimize comparisons against cttz/ctlz/ctpop, patch by Alastair Lynn!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92745 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
d7f5a588907f86ddc83fa29accea54a6c0e78e94 04-Jan-2010 Chris Lattner <sabre@nondot.org> 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92495 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
02446fc99abb06d3117d65c0b1f5fba4f906db2e 04-Jan-2010 Chris Lattner <sabre@nondot.org> split instcombine of compares (visit[FI]Cmp) out to
a new InstCombineCompares.cpp file.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92467 91177308-0d34-0410-b5e6-96231b3b80d8
/external/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp