@@ -1920,7 +1920,7 @@ static bool getRangeForType(CodeGenFunction &CGF, QualType Ty,
19201920llvm::MDNode *CodeGenFunction::getRangeForLoadFromType (QualType Ty) {
19211921 llvm::APInt Min, End;
19221922 if (!getRangeForType (*this , Ty, Min, End, CGM.getCodeGenOpts ().StrictEnums ,
1923- Ty->hasBooleanRepresentation ()))
1923+ Ty->hasBooleanRepresentation () && !Ty-> isVectorType () ))
19241924 return nullptr ;
19251925
19261926 llvm::MDBuilder MDHelper (getLLVMContext ());
@@ -1948,7 +1948,7 @@ bool CodeGenFunction::EmitScalarRangeCheck(llvm::Value *Value, QualType Ty,
19481948 if (!HasBoolCheck && !HasEnumCheck)
19491949 return false ;
19501950
1951- bool IsBool = Ty->hasBooleanRepresentation () ||
1951+ bool IsBool = ( Ty->hasBooleanRepresentation () && !Ty-> isVectorType () ) ||
19521952 NSAPI (CGM.getContext()).isObjCBOOLType(Ty);
19531953 bool NeedsBoolCheck = HasBoolCheck && IsBool;
19541954 bool NeedsEnumCheck = HasEnumCheck && Ty->getAs <EnumType>();
@@ -2068,11 +2068,8 @@ llvm::Value *CodeGenFunction::EmitLoadOfScalar(Address Addr, bool Volatile,
20682068// / by ConvertType) to its load/store type (as returned by
20692069// / convertTypeForLoadStore).
20702070llvm::Value *CodeGenFunction::EmitToMemory (llvm::Value *Value, QualType Ty) {
2071- if (Ty->hasBooleanRepresentation () || Ty->isBitIntType ()) {
2072- llvm::Type *StoreTy = convertTypeForLoadStore (Ty, Value->getType ());
2073- bool Signed = Ty->isSignedIntegerOrEnumerationType ();
2074- return Builder.CreateIntCast (Value, StoreTy, Signed, " storedv" );
2075- }
2071+ if (auto *AtomicTy = Ty->getAs <AtomicType>())
2072+ Ty = AtomicTy->getValueType ();
20762073
20772074 if (Ty->isExtVectorBoolType ()) {
20782075 llvm::Type *StoreTy = convertTypeForLoadStore (Ty, Value->getType ());
@@ -2088,13 +2085,22 @@ llvm::Value *CodeGenFunction::EmitToMemory(llvm::Value *Value, QualType Ty) {
20882085 Value = Builder.CreateBitCast (Value, StoreTy);
20892086 }
20902087
2088+ if (Ty->hasBooleanRepresentation () || Ty->isBitIntType ()) {
2089+ llvm::Type *StoreTy = convertTypeForLoadStore (Ty, Value->getType ());
2090+ bool Signed = Ty->isSignedIntegerOrEnumerationType ();
2091+ return Builder.CreateIntCast (Value, StoreTy, Signed, " storedv" );
2092+ }
2093+
20912094 return Value;
20922095}
20932096
20942097// / Converts a scalar value from its load/store type (as returned
20952098// / by convertTypeForLoadStore) to its primary IR type (as returned
20962099// / by ConvertType).
20972100llvm::Value *CodeGenFunction::EmitFromMemory (llvm::Value *Value, QualType Ty) {
2101+ if (auto *AtomicTy = Ty->getAs <AtomicType>())
2102+ Ty = AtomicTy->getValueType ();
2103+
20982104 if (Ty->isPackedVectorBoolType (getContext ())) {
20992105 const auto *RawIntTy = Value->getType ();
21002106
0 commit comments