llvm.org GIT mirror llvm / 0fd6bdb
Merge r213826 ------------------------------------------------------------------------ r213826 | filcab | 2014-07-23 18:28:21 -0700 (Wed, 23 Jul 2014) | 7 lines Fixed PR20411 - bug in getINSERTPS() When we had a vector_shuffle where we had an input from each vector, we could miscompile it because we were assuming the input from V2 wouldn't be moved from where it was on the vector. Added a test case. git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_35@213911 91177308-0d34-0410-b5e6-96231b3b80d8 Filipe Cabecinhas 5 years ago
2 changed file(s) with 32 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
90539053 To = V2;
90549054 DestIndex = std::find_if(Mask.begin(), Mask.end(), FromV1Predicate) -
90559055 Mask.begin();
9056
9057 // If we have 1 element from each vector, we have to check if we're
9058 // changing V1's element's place. If so, we're done. Otherwise, we
9059 // should assume we're changing V2's element's place and behave
9060 // accordingly.
9061 int FromV2 = std::count_if(Mask.begin(), Mask.end(), FromV2Predicate);
9062 if (FromV1 == FromV2 && DestIndex == Mask[DestIndex] % 4) {
9063 From = V2;
9064 To = V1;
9065 DestIndex =
9066 std::find_if(Mask.begin(), Mask.end(), FromV2Predicate) - Mask.begin();
9067 }
90569068 } else {
90579069 assert(std::count_if(Mask.begin(), Mask.end(), FromV2Predicate) == 1 &&
90589070 "More than one element from V1 and from V2, or no elements from one "
90649076 std::find_if(Mask.begin(), Mask.end(), FromV2Predicate) - Mask.begin();
90659077 }
90669078
9079 // Get an index into the source vector in the range [0,4) (the mask is
9080 // in the range [0,8) because it can address V1 and V2)
90679081 unsigned SrcIndex = Mask[DestIndex] % 4;
90689082 if (MayFoldLoad(From)) {
90699083 // Trivial case, when From comes from a load and is only used by the
713713 %ret = shufflevector <4 x float> %load, <4 x float> %a, <4 x i32>
714714 ret <4 x float> %ret
715715 }
716
717 ; Edge case for insertps where we end up with a shuffle with mask=<0, 7, -1, -1>
718 define void @insertps_pr20411(i32* noalias nocapture %RET) #1 {
719 ; CHECK-LABEL: insertps_pr20411:
720 ; CHECK: movaps {{[^,]*}}, %[[REG1:xmm.]]
721 ; CHECK: pshufd {{.*}} ## [[REG2:xmm.]] = mem[3,0,0,0]
722 ; CHECK: insertps {{.*}} ## xmm1 = [[REG2]][0],[[REG1]][3]{{.*}}
723
724 %gather_load = shufflevector <8 x i32> , <8 x i32> undef, <8 x i32>
725 %shuffle109 = shufflevector <4 x i32> , <4 x i32> undef, <4 x i32> ; 4 5 6 7
726
727 %shuffle116 = shufflevector <8 x i32> %gather_load, <8 x i32> undef, <4 x i32> ; 3 x x x
728 %shuffle117 = shufflevector <4 x i32> %shuffle109, <4 x i32> %shuffle116, <4 x i32> ; 3 7 x x
729
730 %ptrcast = bitcast i32* %RET to <4 x i32>*
731 store <4 x i32> %shuffle117, <4 x i32>* %ptrcast, align 4
732 ret void
733 }