llvm.org GIT mirror llvm / a0f6d16
[msan] Fix handling of scalar select of vectors. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192575 91177308-0d34-0410-b5e6-96231b3b80d8 Evgeniy Stepanov 7 years ago
2 changed file(s) with 23 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
12321232 Value *CreateShadowCast(IRBuilder<> &IRB, Value *V, Type *dstTy) {
12331233 Type *srcTy = V->getType();
12341234 if (dstTy->isIntegerTy() && srcTy->isIntegerTy())
1235 return IRB.CreateIntCast(V, dstTy, false);
1235 return IRB.CreateIntCast(V, dstTy, true);
12361236 if (dstTy->isVectorTy() && srcTy->isVectorTy() &&
12371237 dstTy->getVectorNumElements() == srcTy->getVectorNumElements())
1238 return IRB.CreateIntCast(V, dstTy, false);
1238 return IRB.CreateIntCast(V, dstTy, true);
12391239 size_t srcSizeInBits = VectorOrPrimitiveTypeSizeInBits(srcTy);
12401240 size_t dstSizeInBits = VectorOrPrimitiveTypeSizeInBits(dstTy);
12411241 Value *V1 = IRB.CreateBitCast(V, Type::getIntNTy(*MS.C, srcSizeInBits));
12421242 Value *V2 =
1243 IRB.CreateIntCast(V1, Type::getIntNTy(*MS.C, dstSizeInBits), false);
1243 IRB.CreateIntCast(V1, Type::getIntNTy(*MS.C, dstSizeInBits), true);
12441244 return IRB.CreateBitCast(V2, dstTy);
12451245 // TODO: handle struct types.
12461246 }
18981898 } else {
18991899 // Sa = (sext Sb) | (select b, Sc, Sd)
19001900 S = IRB.CreateOr(
1901 S, IRB.CreateSExt(getShadow(I.getCondition()), S->getType()),
1901 S, CreateShadowCast(IRB, getShadow(I.getCondition()), S->getType()),
19021902 "_msprop_select");
19031903 }
19041904 setShadow(&I, S);
289289 ; CHECK-ORIGINS: ret <8 x i16>
290290
291291
292 ; Check that we propagate origin for "select" with scalar condition and vector
293 ; arguments. Select condition shadow is sign-extended to the vector type and
294 ; mixed into the result shadow.
295
296 define <8 x i16> @SelectVector2(<8 x i16> %a, <8 x i16> %b, i1 %c) nounwind uwtable readnone sanitize_memory {
297 entry:
298 %cond = select i1 %c, <8 x i16> %a, <8 x i16> %b
299 ret <8 x i16> %cond
300 }
301
302 ; CHECK: @SelectVector2
303 ; CHECK: select i1
304 ; CHECK: sext i1 {{.*}} to i128
305 ; CHECK: bitcast i128 {{.*}} to <8 x i16>
306 ; CHECK: or <8 x i16>
307 ; CHECK: select i1
308 ; CHECK: ret <8 x i16>
309
310
292311 define { i64, i64 } @SelectStruct(i1 zeroext %x, { i64, i64 } %a, { i64, i64 } %b) readnone sanitize_memory {
293312 entry:
294313 %c = select i1 %x, { i64, i64 } %a, { i64, i64 } %b