llvm-6502/test/Transforms/InstCombine
Benjamin Kramer c37cb66e6e Fix for wrong instcombine on vector insert/extract
When trying to collapse sequences of insertelement/extractelement
instructions into single shuffle instructions, there is one specific
case where the Instruction Combiner wrongly updates the resulting
Mask of shuffle indexes.

The problem is in function CollectShuffleElments.

If we have a sequence of insert/extract element instructions
like the one below:

  %tmp1 = extractelement <4 x float> %LHS, i32 0
  %tmp2 = insertelement <4 x float> %RHS, float %tmp1, i32 1
  %tmp3 = extractelement <4 x float> %RHS, i32 2
  %tmp4 = insertelement <4 x float> %tmp2, float %tmp3, i32 3

Where:
  . %RHS will have a mask of [4,5,6,7]
  . %LHS will have a mask of [0,1,2,3]

The Mask of shuffle indexes is wrongly computed to [4,1,6,7]
instead of [4,0,6,7].
When analyzing %tmp2 in order to compute the Mask for the
resulting shuffle instruction, the algorithm forgets to update
the mask index at position 1 with the index associated to the
element extracted from %LHS by instruction %tmp1.

Patch by Andrea DiBiagio!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179291 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-11 15:10:09 +00:00
..
2002-03-11-InstCombineHang.ll
2002-05-14-SubFailure.ll
2002-08-02-CastTest.ll
2002-12-05-MissedConstProp.ll
2003-05-26-CastMiscompile.ll
2003-05-27-ConstExprCrash.ll
2003-06-05-BranchInvertInfLoop.ll
2003-07-21-ExternalConstant.ll
2003-08-12-AllocaNonNull.ll
2003-09-09-VolatileLoadElim.ll
2003-10-29-CallSiteResolve.ll
2003-11-03-VarargsCallBug.ll
2004-01-13-InstCombineInvokePHI.ll
2004-02-23-ShiftShiftOverflow.ll
2004-03-13-InstCombineInfLoop.ll
2004-04-04-InstCombineReplaceAllUsesWith.ll
2004-05-07-UnsizedCastLoad.ll
2004-07-27-ConstantExprMul.ll
2004-08-09-RemInfLoop.ll
2004-08-10-BoolSetCC.ll
2004-09-20-BadLoadCombine2.ll
2004-09-20-BadLoadCombine.ll
2004-09-28-BadShiftAndSetCC.ll
2004-11-22-Missed-and-fold.ll
2004-11-27-SetCCForCastLargerAndConstant.ll
2004-12-08-RemInfiniteLoop.ll
2005-03-04-ShiftOverflow.ll
2005-04-07-UDivSelectCrash.ll
2005-06-15-DivSelectCrash.ll
2005-06-15-ShiftSetCCCrash.ll
2005-06-16-RangeCrash.ll
2005-06-16-SetCCOrSetCCMiscompile.ll
2005-07-07-DeadPHILoop.ll
2006-02-13-DemandedMiscompile.ll
2006-02-28-Crash.ll
2006-03-30-ExtractElement.ll
2006-04-28-ShiftShiftLongLong.ll
2006-05-04-DemandedBitCrash.ll
2006-09-15-CastToBool.ll
2006-10-19-SignedToUnsignedCastAndConst-2.ll
2006-10-20-mask.ll
2006-10-26-VectorReassoc.ll
2006-11-10-ashr-miscompile.ll
2006-12-01-BadFPVectorXform.ll
2006-12-05-fp-to-int-ext.ll
2006-12-08-Phi-ICmp-Op-Fold.ll
2006-12-08-Select-ICmp.ll
2006-12-15-Range-Test.ll
2006-12-23-Select-Cmp-Cmp.ll
2007-01-13-ExtCompareMiscompile.ll
2007-01-14-FcmpSelf.ll
2007-01-18-VectorInfLoop.ll
2007-01-27-AndICmp.ll
2007-02-01-LoadSinkAlloca.ll
2007-02-07-PointerCast.ll
2007-02-23-PhiFoldInfLoop.ll
2007-03-13-CompareMerge.ll
2007-03-19-BadTruncChangePR1261.ll
2007-03-21-SignedRangeTest.ll
2007-03-25-BadShiftMask.ll
2007-03-25-DoubleShift.ll
2007-03-26-BadShiftMask.ll
2007-04-08-SingleEltVectorCrash.ll
2007-05-10-icmp-or.ll
2007-05-14-Crash.ll
2007-05-18-CastFoldBug.ll
2007-06-06-AshrSignBit.ll
2007-06-21-DivCompareMiscomp.ll
2007-08-02-InfiniteLoop.ll
2007-09-10-AliasConstFold.ll
2007-09-17-AliasConstFold2.ll
2007-10-10-EliminateMemCpy.ll
2007-10-12-Crash.ll
2007-10-28-stacksave.ll
2007-10-31-RangeCrash.ll
2007-10-31-StringCrash.ll
2007-11-07-OpaqueAlignCrash.ll
2007-11-15-CompareMiscomp.ll
2007-11-22-IcmpCrash.ll
2007-11-25-CompatibleAttributes.ll
2007-12-10-ConstFoldCompare.ll
2007-12-12-GEPScale.ll
2007-12-16-AsmNoUnwind.ll
2007-12-18-AddSelCmpSub.ll
2007-12-28-IcmpSub2.ll
2008-01-06-BitCastAttributes.ll
2008-01-06-CastCrash.ll
2008-01-06-VoidCast.ll
2008-01-13-AndCmpCmp.ll
2008-01-13-NoBitCastAttributes.ll
2008-01-14-VarArgTrampoline.ll
2008-01-21-MismatchedCastAndCompare.ll
2008-01-21-MulTrunc.ll
2008-01-27-FloatSelect.ll
2008-01-29-AddICmp.ll
2008-02-13-MulURem.ll
2008-02-16-SDivOverflow2.ll
2008-02-16-SDivOverflow.ll
2008-02-23-MulSub.ll
2008-02-28-OrFCmpCrash.ll
2008-03-13-IntToPtr.ll
2008-04-22-ByValBitcast.ll
2008-04-28-VolatileStore.ll
2008-04-29-VolatileLoadDontMerge.ll
2008-04-29-VolatileLoadMerge.ll
2008-05-08-LiveStoreDelete.ll
2008-05-08-StrLenSink.ll Tests: rewrite 'opt ... %s' to 'opt ... < %s' so that opt does not emit a ModuleID 2012-12-30 01:28:40 +00:00
2008-05-09-SinkOfInvoke.ll
2008-05-17-InfLoop.ll
2008-05-18-FoldIntToPtr.ll
2008-05-22-IDivVector.ll
2008-05-22-NegValVector.ll
2008-05-23-CompareFold.ll
2008-05-31-AddBool.ll
2008-05-31-Bools.ll
2008-06-05-ashr-crash.ll
2008-06-08-ICmpPHI.ll
2008-06-13-InfiniteLoopStore.ll
2008-06-13-ReadOnlyCallStore.ll
2008-06-19-UncondLoad.ll
2008-06-21-CompareMiscomp.ll
2008-06-24-StackRestore.ll
2008-07-08-AndICmp.ll
2008-07-08-ShiftOneAndOne.ll
2008-07-08-SubAnd.ll
2008-07-08-VolatileLoadMerge.ll
2008-07-09-SubAndError.ll
2008-07-10-CastSextBool.ll
2008-07-10-ICmpBinOp.ll
2008-07-11-RemAnd.ll
2008-07-13-DivZero.ll
2008-07-16-fsub.ll
2008-07-16-sse2_storel_dq.ll
2008-08-05-And.ll
2008-08-17-ICmpXorSignbit.ll
2008-09-02-VectorCrash.ll
2008-09-29-FoldingOr.ll
2008-10-11-DivCompareFold.ll
2008-10-23-ConstFoldWithoutMask.ll
2008-11-01-SRemDemandedBits.ll
2008-11-08-FCmp.ll
2008-11-20-DivMulRem.ll
2008-11-27-IDivVector.ll
2008-11-27-MultiplyIntVec.ll
2008-11-27-UDivNegative.ll
2008-12-17-SRemNegConstVec.ll
2009-01-05-i128-crash.ll
2009-01-08-AlignAlloca.ll
2009-01-16-PointerAddrSpace.ll
2009-01-19-fmod-constant-float-specials.ll
2009-01-19-fmod-constant-float.ll
2009-01-24-EmptyStruct.ll
2009-01-31-InfIterate.ll
2009-01-31-Pressure.ll
2009-02-04-FPBitcast.ll
2009-02-11-NotInitialized.ll Move library call prototype attribute inference to functionattrs 2013-03-21 00:55:59 +00:00
2009-02-20-InstCombine-SROA.ll
2009-02-21-LoadCST.ll
2009-02-25-CrashZeroSizeArray.ll
2009-03-18-vector-ashr-crash.ll
2009-03-20-AShrOverShift.ll
2009-03-24-InfLoop.ll
2009-04-07-MulPromoteToI96.ll
2009-05-23-FCmpToICmp.ll
2009-06-11-StoreAddrSpace.ll
2009-06-16-SRemDemandedBits.ll
2009-07-02-MaskedIntVector.ll
2009-12-17-CmpSelectNull.ll
2010-01-28-NegativeSRem.ll
2010-03-03-ExtElim.ll Tests: rewrite 'opt ... %s' to 'opt ... < %s' so that opt does not emit a ModuleID 2012-12-30 01:28:40 +00:00
2010-05-30-memcpy-Struct.ll Tests: rewrite 'opt ... %s' to 'opt ... < %s' so that opt does not emit a ModuleID 2012-12-30 01:28:40 +00:00
2010-11-01-lshr-mask.ll For rdar://12329730, last piece. 2012-12-04 22:15:32 +00:00
2010-11-21-SizeZeroTypeGEP.ll
2010-11-23-Distributed.ll
2011-02-14-InfLoop.ll
2011-03-08-SRemMinusOneBadOpt.ll
2011-05-02-VectorBoolean.ll
2011-05-13-InBoundsGEP.ll
2011-05-28-swapmulsub.ll
2011-06-13-nsw-alloca.ll
2011-09-03-Trampoline.ll
2011-10-07-AlignPromotion.ll
2012-3-15-or-xor-constant.ll
2012-6-7-vselect-bitcast.ll
2012-01-11-OpaqueBitcastCrash.ll
2012-02-13-FCmp.ll
2012-02-28-ICmp.ll
2012-03-10-InstCombine.ll
2012-04-23-Neon-Intrinsics.ll Use references to attribute groups on the call/invoke instructions. 2013-02-22 09:09:42 +00:00
2012-04-24-vselect.ll
2012-04-30-SRem.ll
2012-05-27-Negative-Shift-Crash.ll
2012-05-28-select-hang.ll
2012-06-06-LoadOfPHIs.ll
2012-07-25-LoadPart.ll
2012-07-30-addrsp-bitcast.ll
2012-08-28-udiv_ashl.ll
2012-09-17-ZeroSizedAlloca.ll
2012-09-24-MemcpyFromGlobalCrash.ll
2012-10-25-vector-of-pointers.ll
2012-12-14-simp-vgep.ll Fix a crash in ValueTracking on vectors of pointers. 2012-12-14 20:43:49 +00:00
2013-03-05-Combine-BitcastTy-Into-Alloca.ll InstCombine: Don't shrink allocas when combining with a bitcast. 2013-03-06 05:44:53 +00:00
abs-1.ll
add2.ll
add3.ll
add-shrink.ll
add-sitofp.ll
add.ll
addnegneg.ll
adjust-for-sminmax.ll
align-2d-gep.ll
align-addr.ll
align-external.ll
alloca.ll
and2.ll
and-compare.ll
and-fcmp.ll
and-not-or.ll
and-or-and.ll
and-or-not.ll
and-or.ll
and-xor-merge.ll
and-xor-or.ll
and.ll
apint-add1.ll
apint-add2.ll
apint-and1.ll
apint-and2.ll
apint-and-compare.ll
apint-and-or-and.ll
apint-and-xor-merge.ll
apint-call-cast-target.ll
apint-cast-and-cast.ll
apint-cast-cast-to-and.ll
apint-cast.ll
apint-div1.ll
apint-div2.ll
apint-mul1.ll
apint-mul2.ll
apint-not.ll
apint-or1.ll
apint-or2.ll
apint-rem1.ll
apint-rem2.ll
apint-select.ll
apint-shift-simplify.ll FileCheckize a bunch of tests. 2013-04-11 12:32:23 +00:00
apint-shift.ll
apint-shl-trunc.ll
apint-sub.ll
apint-xor1.ll
apint-xor2.ll
apint-zext1.ll
apint-zext2.ll
ashr-nop.ll
atomic.ll
badmalloc.ll
binop-cast.ll
bit-checks.ll
bit-tracking.ll
bitcast-bigendian.ll Add test case for commit r178031. 2013-03-26 17:30:02 +00:00
bitcast-sext-vector.ll
bitcast-store.ll
bitcast-vec-canon.ll
bitcast-vec-uniform.ll
bitcast-vector-fold.ll Constant fold vector bitcasts of halves similarly to how floats and doubles are folded. Test case included. 2013-02-26 22:51:07 +00:00
bitcast.ll Optimization: bitcast (<1 x ...> insertelement ..., X, ...) to ... ==> bitcast X to ... 2013-02-11 21:41:44 +00:00
bitcount.ll
bittest.ll
bswap-fold.ll
bswap.ll
call2.ll
call-cast-target.ll
call-intrinsics.ll
call.ll
canonicalize_branch.ll
cast_ptr.ll
cast-mul-select.ll
cast-set.ll
cast.ll unHECKify test fixed by Jacob in r159003. 2012-12-12 20:58:42 +00:00
compare-signs.ll Tests: rewrite 'opt ... %s' to 'opt ... < %s' so that opt does not emit a ModuleID 2013-01-01 13:57:25 +00:00
constant-expr-datalayout.ll Teach the DataLayout aware constant folder to be much more aggressive towards 2013-02-14 03:23:37 +00:00
constant-fold-compare.ll
constant-fold-gep.ll
cos-1.ll
cos-2.ll
CPP_min_max.ll
crash.ll
dce-iterate.ll
deadcode.ll
debug-line.ll instcombine: Migrate printf optimizations 2012-11-26 20:37:20 +00:00
debuginfo.ll Revert "Adding DIImportedModules to DIScopes." 2013-03-28 02:44:59 +00:00
devirt.ll Tests: rewrite 'opt ... %s' to 'opt ... < %s' so that opt does not emit a ModuleID 2012-12-30 01:28:40 +00:00
disable-simplify-libcalls.ll
div-shift.ll
div.ll
double-float-shrink-1.ll
double-float-shrink-2.ll
enforce-known-alignment.ll
exact.ll Teach InstCombine to work with smaller legal types in icmp (shl %v, C1), C2 2013-02-15 14:35:47 +00:00
exp2-1.ll
exp2-2.ll
ExtractCast.ll
extractvalue.ll
fast-math.ll Fix a bug in fast-math fadd/fsub simplification. 2013-03-25 20:43:41 +00:00
fcmp-select.ll
fcmp-special.ll
fcmp.ll
fdiv.ll
ffs-1.ll Fix bogus comment; no functional change. 2012-11-26 00:25:33 +00:00
fmul.ll 1. Hoist minus sign as high as possible in an attempt to reveal 2013-01-15 21:09:32 +00:00
fold-bin-operand.ll
fold-calls.ll
fold-phi.ll Add back FoldOpIntoPhi optimizations with fix. Included test cases to help catch these errors and to test the presence of the optimization itself 2012-12-14 22:08:26 +00:00
fold-sqrt-sqrtf.ll
fold-vector-select.ll
fold-vector-zero.ll
fp-ret-bitcast.ll
fpcast.ll Teach InstCombine to hoist FABS and FNEG through FPTRUNC instructions. The application of these operations commutes with the truncation, so we should prefer to do them in the smallest size we can, to save register space, use smaller constant pool entries, etc. 2013-01-10 22:06:52 +00:00
fpextend.ll
fprintf-1.ll instcombine: Migrate fputs optimizations 2012-11-29 15:45:43 +00:00
fputs-1.ll instcombine: Migrate fputs optimizations 2012-11-29 15:45:43 +00:00
fsub.ll
fwrite-1.ll instcombine: Migrate fwrite optimizations 2012-11-29 15:45:39 +00:00
gep-addrspace.ll
gepgep.ll
getelementptr.ll Use references to attribute groups on the call/invoke instructions. 2013-02-22 09:09:42 +00:00
hoist_instr.ll
icmp.ll Address issues found by Duncan during post-commit review of r177856. 2013-03-25 11:47:38 +00:00
idioms.ll Tests: rewrite 'opt ... %s' to 'opt ... < %s' so that opt does not emit a ModuleID 2012-12-30 01:28:40 +00:00
IntPtrCast.ll
intrinsics.ll Revert "Have InstCombine call SipmlifyCall when handling calls. Test case included." 2013-02-08 01:55:39 +00:00
invariant.ll
invoke.ll Revert 179071 because it is not the right way to support non standard new/new[] operators. 2013-04-09 04:43:46 +00:00
isascii-1.ll instcombine: Migrate isascii optimizations 2012-11-26 03:10:07 +00:00
isdigit-1.ll instcombine: Migrate isdigit optimizations 2012-11-26 02:31:59 +00:00
JavaCompare.ll
known_align.ll
LandingPadClauses.ll
lit.local.cfg
load3.ll ConstantFolding: Evaluate GEP indices in the index type. 2013-01-23 20:41:05 +00:00
load-cmp.ll InstCombine: Improve the result bitvect type when folding (cmp pred (load (gep GV, i)) C) to a bit test. 2013-03-22 08:25:01 +00:00
load-select.ll
load.ll
loadstore-alignment.ll
logical-select.ll The transform is: 2013-02-16 23:41:36 +00:00
lshr-phi.ll
malloc-free-delete.ll When code size is the priority (Oz, MinSize attribute), help llvm 2013-01-07 18:37:41 +00:00
memcmp-1.ll
memcmp-2.ll
memcpy_chk-1.ll
memcpy_chk-2.ll
memcpy-1.ll
memcpy-2.ll
memcpy-from-global.ll Get rid of the getPointeeAlignment helper function from 2012-11-26 23:04:53 +00:00
memcpy-to-load.ll
memcpy.ll
memmove_chk-1.ll
memmove_chk-2.ll
memmove-1.ll
memmove-2.ll
memmove.ll
memset2.ll
memset_chk-1.ll
memset_chk-2.ll
memset-1.ll
memset-2.ll
memset.ll
merge-icmp.ll
mul-masked-bits.ll
mul.ll InstCombine: canonicalize sext-and --> select 2013-01-30 06:35:22 +00:00
multi-use-or.ll
narrow.ll
neon-intrinsics.ll
no-negzero.ll
not-fcmp.ll
not.ll
nothrow.ll
nsw.ll
obfuscated_splat.ll Tests: rewrite 'opt ... %s' to 'opt ... < %s' so that opt does not emit a ModuleID 2012-12-30 01:28:40 +00:00
objsize-64.ll Revert 179071 because it is not the right way to support non standard new/new[] operators. 2013-04-09 04:43:46 +00:00
objsize.ll Revert r176408 and r176407 to address PR15540. 2013-04-09 18:16:05 +00:00
odr-linkage.ll
or-fcmp.ll
or-to-xor.ll
or-xor.ll
or.ll The transform is: 2013-02-16 23:41:36 +00:00
osx-names.ll instcombine: Migrate fprintf optimizations 2012-11-29 15:45:33 +00:00
overflow.ll
phi-merge-gep.ll
phi.ll
pow-1.ll Use references to attribute groups on the call/invoke instructions. 2013-02-22 09:09:42 +00:00
pow-2.ll
pr2645-0.ll
pr2645-1.ll
pr2996.ll
pr8547.ll
pr12251.ll
pr12338.ll
preserve-sminmax.ll
printf-1.ll instcombine: Migrate printf optimizations 2012-11-26 20:37:20 +00:00
printf-2.ll instcombine: Don't replace all uses for instructions with no uses 2012-11-27 18:52:49 +00:00
ptr-int-cast.ll InstCombine: Fix and simplify the inttoptr side too. 2013-02-05 20:22:40 +00:00
puts-1.ll instcombine: Migrate puts optimizations 2012-11-29 19:15:17 +00:00
README.txt
rem.ll
sdiv-1.ll
sdiv-2.ll
select-2.ll
select-crash.ll
select-load-call.ll
select.ll
set.ll
setcc-strength-reduce.ll
sext.ll Transform (sub 0, (zext bool to A)) to (sext bool to A) and 2013-01-21 21:57:20 +00:00
shift-sra.ll
shift.ll Revert r174152. The shift amount may overflow and in that case this transformation is illegal. 2013-02-01 07:59:33 +00:00
shufflemask-undef.ll
shufflevec-constant.ll
sign-test-and-or.ll
signed-comparison.ll
signext.ll rdar://12329730 (2nd part) 2012-12-04 00:04:54 +00:00
simplify-demanded-bits-pointer.ll
sink_instruction.ll Tests: rewrite 'opt ... %s' to 'opt ... < %s' so that opt does not emit a ModuleID 2012-12-30 01:28:40 +00:00
sitofp.ll
sprintf-1.ll Move sprintf simplifier tests to test/Transforms/InstCombine 2012-11-27 15:35:58 +00:00
sqrt.ll Tests: rewrite 'opt ... %s' to 'opt ... < %s' so that opt does not emit a ModuleID 2012-12-30 01:28:40 +00:00
srem1.ll
srem-simplify-bug.ll
srem.ll
stack-overalign.ll
stacksaverestore.ll
store.ll teach instcombine to preserve TBAA tag when merging two stores, part of 2012-12-31 08:10:58 +00:00
stpcpy_chk-1.ll
stpcpy_chk-2.ll
stpcpy-1.ll
stpcpy-2.ll
strcat-1.ll
strcat-2.ll
strcat-3.ll
strchr-1.ll
strchr-2.ll
strcmp-1.ll
strcmp-2.ll
strcpy_chk-1.ll
strcpy_chk-2.ll
strcpy_chk-64.ll
strcpy-1.ll
strcpy-2.ll
strcspn-1.ll
strcspn-2.ll
strlen-1.ll
strlen-2.ll
strncat-1.ll
strncat-2.ll
strncat-3.ll
strncmp-1.ll
strncmp-2.ll
strncpy_chk-1.ll
strncpy_chk-2.ll
strncpy-1.ll
strncpy-2.ll
strpbrk-1.ll
strpbrk-2.ll
strrchr-1.ll
strrchr-2.ll
strspn-1.ll
strstr-1.ll
strstr-2.ll
strto-1.ll Move library call prototype attribute inference to functionattrs 2013-03-21 00:55:59 +00:00
struct-assign-tbaa.ll
sub-xor.ll
sub.ll
toascii-1.ll instcombine: Migrate toascii optimizations 2012-11-26 03:38:52 +00:00
trunc.ll
udiv_select_to_select_shift.ll
udiv-simplify-bug-0.ll
udiv-simplify-bug-1.ll
udivrem-change-width.ll
urem-simplify-bug.ll
urem.ll
vec_demanded_elts.ll
vec_extract_elt.ll Teach InstCombine to optimize extract of a value from a vector add operation with a constant zero. 2013-01-15 23:43:14 +00:00
vec_insertelt.ll
vec_narrow.ll
vec_sext.ll
vec_shuffle.ll Fix for wrong instcombine on vector insert/extract 2013-04-11 15:10:09 +00:00
vector_gep1.ll Tests: rewrite 'opt ... %s' to 'opt ... < %s' so that opt does not emit a ModuleID 2012-12-30 02:33:22 +00:00
vector_gep2.ll
vector-casts.ll InstCombine: canonicalize sext-and --> select 2013-01-30 06:35:22 +00:00
vector-srem.ll
vector-type.ll Remove -O3. 2013-03-28 19:34:14 +00:00
volatile_store.ll
weak-symbols.ll
x86-crc32-demanded.ll
xor2.ll fix a typo 2012-12-05 00:33:16 +00:00
xor-undef.ll
xor.ll
zero-point-zero-add.ll
zeroext-and-reduce.ll
zext-bool-add-sub.ll Transform (sub 0, (zext bool to A)) to (sext bool to A) and 2013-01-21 21:57:20 +00:00
zext-fold.ll
zext-or-icmp.ll
zext.ll

This directory contains test cases for the instcombine transformation.  The
dated tests are actual bug tests, whereas the named tests are used to test
for features that the this pass should be capable of performing.