Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LiftContext::lift_op responsible for ~25% of the generated llvm ir #220

Open
bjorn3 opened this issue Nov 16, 2021 · 0 comments
Open

LiftContext::lift_op responsible for ~25% of the generated llvm ir #220

bjorn3 opened this issue Nov 16, 2021 · 0 comments

Comments

@bjorn3
Copy link
Contributor

bjorn3 commented Nov 16, 2021

$ cargo llvm-lines -p rspirv
  Lines          Copies       Function name
  -----          ------       -------------
  434621 (100%)  6861 (100%)  (TOTAL)
  113962 (26.2%)    1 (0.0%)  rspirv::lift::LiftContext::lift_op

I wonder if it would be possible to have all operand matches of all instructions with the same "function signature" be grouped together. Something like:

145u32 | 146u32 => {
    let id1 = (match operands.next() {
        Some(&dr::Operand::IdRef(ref value)) => Some(*value),
        Some(_) => return Err(OperandError::WrongType.into()),
        None => None,
    }).ok_or(OperandError::Missing)?;
    let id2 = (match operands.next() {
        Some(&dr::Operand::IdRef(ref value)) => Some(*value),
        Some(_) => return Err(OperandError::WrongType.into()),
        None => None,
    })
    .ok_or(OperandError::Missing)?;
    match raw.class.opcode as u32 {
        145u32 => ops::Op::MatrixTimesVector { matrix: id1, vector: id2 },
        146u32 => ops::Op::MatrixTimesMatrix { left_matrix: id1, right_matrix: id2 },
        _ => unreachable!(),
    }
}

instead of

145u32 => Ok(ops::Op::MatrixTimesVector {
    matrix: (match operands.next() {
        Some(&dr::Operand::IdRef(ref value)) => Some(*value),
        Some(_) => return Err(OperandError::WrongType.into()),
        None => None,
    })
    .ok_or(OperandError::Missing)?,
    vector: (match operands.next() {
        Some(&dr::Operand::IdRef(ref value)) => Some(*value),
        Some(_) => return Err(OperandError::WrongType.into()),
        None => None,
    })
    .ok_or(OperandError::Missing)?,
}),
146u32 => Ok(ops::Op::MatrixTimesMatrix {
    left_matrix: (match operands.next() {
        Some(&dr::Operand::IdRef(ref value)) => Some(*value),
        Some(_) => return Err(OperandError::WrongType.into()),
        None => None,
    })
    .ok_or(OperandError::Missing)?,
        right_matrix: (match operands.next() {
        Some(&dr::Operand::IdRef(ref value)) => Some(*value),
        Some(_) => return Err(OperandError::WrongType.into()),
        None => None,
    })
    .ok_or(OperandError::Missing)?,
}),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant