diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -4409,7 +4409,7 @@ EVT VT = Src0.getValueType(); Align Alignment = cast(I.getArgOperand(2)) ->getMaybeAlignValue() - .getValueOr(DAG.getEVTAlign(VT)); + .getValueOr(DAG.getEVTAlign(VT.getScalarType())); const TargetLowering &TLI = DAG.getTargetLoweringInfo(); AAMDNodes AAInfo; @@ -4527,7 +4527,7 @@ EVT VT = TLI.getValueType(DAG.getDataLayout(), I.getType()); Align Alignment = cast(I.getArgOperand(1)) ->getMaybeAlignValue() - .getValueOr(DAG.getEVTAlign(VT)); + .getValueOr(DAG.getEVTAlign(VT.getScalarType())); AAMDNodes AAInfo; I.getAAMetadata(AAInfo); diff --git a/llvm/lib/Transforms/Scalar/ScalarizeMaskedMemIntrin.cpp b/llvm/lib/Transforms/Scalar/ScalarizeMaskedMemIntrin.cpp --- a/llvm/lib/Transforms/Scalar/ScalarizeMaskedMemIntrin.cpp +++ b/llvm/lib/Transforms/Scalar/ScalarizeMaskedMemIntrin.cpp @@ -956,22 +956,22 @@ scalarizeMaskedStore(DL, CI, DTU, ModifiedDT); return true; case Intrinsic::masked_gather: { - unsigned AlignmentInt = - cast(CI->getArgOperand(1))->getZExtValue(); + MaybeAlign MA = + cast(CI->getArgOperand(1))->getMaybeAlignValue(); Type *LoadTy = CI->getType(); - Align Alignment = - DL.getValueOrABITypeAlignment(MaybeAlign(AlignmentInt), LoadTy); + Align Alignment = DL.getValueOrABITypeAlignment(MA, + LoadTy->getScalarType()); if (TTI.isLegalMaskedGather(LoadTy, Alignment)) return false; scalarizeMaskedGather(DL, CI, DTU, ModifiedDT); return true; } case Intrinsic::masked_scatter: { - unsigned AlignmentInt = - cast(CI->getArgOperand(2))->getZExtValue(); + MaybeAlign MA = + cast(CI->getArgOperand(2))->getMaybeAlignValue(); Type *StoreTy = CI->getArgOperand(0)->getType(); - Align Alignment = - DL.getValueOrABITypeAlignment(MaybeAlign(AlignmentInt), StoreTy); + Align Alignment = DL.getValueOrABITypeAlignment(MA, + StoreTy->getScalarType()); if (TTI.isLegalMaskedScatter(StoreTy, Alignment)) return false; scalarizeMaskedScatter(DL, CI, DTU, ModifiedDT);