Commit b7d9677d authored by Tobias Klausmann's avatar Tobias Klausmann Committed by Ilia Mirkin

nv50/ir: constant fold OP_SPLIT

Split the source immediate value into new values and move them into the
original defs set by the split. Since we can only have up to 64-bit
immediates, this is largely beneficial for F64 (and, in the future, U64)
Signed-off-by: default avatarTobias Klausmann <>
[imirkin: always use U32, set newi for foldCount tracking]
Signed-off-by: Ilia Mirkin's avatarIlia Mirkin <>
parent 75128d6f
......@@ -932,6 +932,24 @@ ConstantFolding::opnd(Instruction *i, ImmediateValue &imm0, int s)
Instruction *newi = i;
switch (i->op) {
case OP_SPLIT: {
bld.setPosition(i, false);
uint8_t size = i->getDef(0)->reg.size;
uint32_t mask = (1ULL << size) - 1;
assert(size <= 32);
uint64_t val =;
for (int8_t d = 0; i->defExists(d); ++d) {
Value *def = i->getDef(d);
assert(def->reg.size == size);
newi = bld.mkMov(def, bld.mkImm((uint32_t)(val & mask)), TYPE_U32);
val >>= size;
delete_Instruction(prog, i);
case OP_MUL:
if (i->dType == TYPE_F32)
tryCollapseChainedMULs(i, s, imm0);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment