Skip to content

Commit 5b364cb

Browse files
committed
address pr comments cont
1 parent e947d2c commit 5b364cb

File tree

4 files changed

+12
-17
lines changed

4 files changed

+12
-17
lines changed

clang/lib/CodeGen/CGExpr.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2429,7 +2429,7 @@ void CodeGenFunction::EmitStoreThroughLValue(RValue Src, LValue Dst,
24292429
llvm::Value *SrcVal = Src.getScalarVal();
24302430

24312431
if (SrcVal->getType()->getPrimitiveSizeInBits() <
2432-
VecTy->getScalarSizeInBits())
2432+
VecTy->getScalarSizeInBits())
24332433
SrcVal = Builder.CreateZExt(SrcVal, VecTy->getScalarType());
24342434

24352435
auto *IRStoreTy = dyn_cast<llvm::IntegerType>(Vec->getType());
@@ -2655,8 +2655,7 @@ void CodeGenFunction::EmitStoreThroughExtVectorComponentLValue(RValue Src,
26552655

26562656
if (const VectorType *VTy = Dst.getType()->getAs<VectorType>()) {
26572657
unsigned NumSrcElts = VTy->getNumElements();
2658-
unsigned NumDstElts =
2659-
cast<llvm::FixedVectorType>(VecTy)->getNumElements();
2658+
unsigned NumDstElts = cast<llvm::FixedVectorType>(VecTy)->getNumElements();
26602659
if (NumDstElts == NumSrcElts) {
26612660
// Use shuffle vector is the src and destination are the same number of
26622661
// elements and restore the vector mask since it is on the side it will be
@@ -2666,7 +2665,8 @@ void CodeGenFunction::EmitStoreThroughExtVectorComponentLValue(RValue Src,
26662665
Mask[getAccessedFieldNo(i, Elts)] = i;
26672666

26682667
llvm::Value *SrcVal = Src.getScalarVal();
2669-
if (VecTy->getScalarSizeInBits() > SrcVal->getType()->getScalarSizeInBits())
2668+
if (VecTy->getScalarSizeInBits() >
2669+
SrcVal->getType()->getScalarSizeInBits())
26702670
SrcVal = Builder.CreateZExt(SrcVal, VecTy);
26712671

26722672
Vec = Builder.CreateShuffleVector(SrcVal, Mask);
@@ -2679,7 +2679,8 @@ void CodeGenFunction::EmitStoreThroughExtVectorComponentLValue(RValue Src,
26792679
for (unsigned i = 0; i != NumSrcElts; ++i)
26802680
ExtMask.push_back(i);
26812681
ExtMask.resize(NumDstElts, -1);
2682-
llvm::Value *ExtSrcVal = Builder.CreateShuffleVector(Src.getScalarVal(), ExtMask);
2682+
llvm::Value *ExtSrcVal =
2683+
Builder.CreateShuffleVector(Src.getScalarVal(), ExtMask);
26832684
// build identity
26842685
SmallVector<int, 4> Mask;
26852686
for (unsigned i = 0; i != NumDstElts; ++i)

clang/lib/CodeGen/CGExprConstant.cpp

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1978,23 +1978,17 @@ llvm::Constant *ConstantEmitter::emitForMemory(CodeGenModule &CGM,
19781978
}
19791979

19801980
// Zero-extend bool.
1981-
if (C->getType()->isIntegerTy(1) && !destType->isBitIntType()) {
1981+
// In HLSL bool vectors are stored in memory as a vector of i32
1982+
if ((C->getType()->isIntegerTy(1) && !destType->isBitIntType()) ||
1983+
(destType->isExtVectorBoolType() &&
1984+
!destType->isPackedVectorBoolType(CGM.getContext()))) {
19821985
llvm::Type *boolTy = CGM.getTypes().ConvertTypeForMem(destType);
19831986
llvm::Constant *Res = llvm::ConstantFoldCastOperand(
19841987
llvm::Instruction::ZExt, C, boolTy, CGM.getDataLayout());
19851988
assert(Res && "Constant folding must succeed");
19861989
return Res;
19871990
}
19881991

1989-
// In HLSL bool vectors are stored in memory as a vector of i32
1990-
if (destType->isExtVectorBoolType() && CGM.getContext().getLangOpts().HLSL) {
1991-
llvm::Type *boolVecTy = CGM.getTypes().ConvertTypeForMem(destType);
1992-
llvm::Constant *Res = llvm::ConstantFoldCastOperand(
1993-
llvm::Instruction::ZExt, C, boolVecTy, CGM.getDataLayout());
1994-
assert(Res && "Constant folding must succeed");
1995-
return Res;
1996-
}
1997-
19981992
if (destType->isBitIntType()) {
19991993
ConstantAggregateBuilder Builder(CGM);
20001994
llvm::Type *LoadStoreTy = CGM.getTypes().convertTypeForLoadStore(destType);

clang/test/CodeGenHLSL/BoolVector.hlsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,4 @@ void fn6() {
108108
void fn7() {
109109
bool2 Arr[2] = {{true,true}, {false,false}};
110110
Arr[0][1] = false;
111-
}
111+
}

clang/test/CodeGenHLSL/builtins/ScalarSwizzles.hlsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,4 +301,4 @@ void AssignBool3(bool2 V) {
301301
bool2 AccessBools() {
302302
bool4 X = true.xxxx;
303303
return X.zw;
304-
}
304+
}

0 commit comments

Comments
 (0)