Skip to content

Commit 77379d6

Browse files
committed
Ignore i64 ConstantInt indices from ExtractElement and InsertElement instructions that fit within 32 bits
1 parent 0dafdf6 commit 77379d6

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

llvm/lib/Target/DirectX/DXILShaderFlags.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,24 @@ void ModuleShaderFlags::updateFunctionFlags(ComputedShaderFlags &CSF,
118118
if (!CSF.Int64Ops) {
119119
for (const Value *Op : I.operands()) {
120120
if (Op->getType()->isIntegerTy(64)) {
121+
122+
// Special-case handling for ConstantInt indices of ExtractElement and
123+
// InsertElement instructions (likely inserted by the Scalarization
124+
// pass). As long as the constant indices fit within 32 bits, we do not
125+
// consider them to count as 64-bit integer usage.
126+
switch (I.getOpcode()) {
127+
case Instruction::ExtractElement:
128+
case Instruction::InsertElement:
129+
if (Op == I.getOperand(I.getNumOperands() - 1)) { // Index operand
130+
if (isa<ConstantInt>(Op)) {
131+
const ConstantInt *CI = cast<ConstantInt>(Op);
132+
// The constant index must fit within 32 bits
133+
if (CI->getZExtValue() <= UINT32_MAX)
134+
continue;
135+
}
136+
}
137+
}
138+
121139
CSF.Int64Ops = true;
122140
break;
123141
}

0 commit comments

Comments
 (0)