fn eliminate_upper_bits(bits: usize, e: il::Expression) -> Result<il::Expression> {
        // Returns true if this side of an or statement can be safely eliminated
        fn or_eliminate(bits: usize, e: &il::Expression) -> bool {
            let mask: u64 = (1 << (bits as u64)) - 1;

            match e {
                il::Expression::Constant(c) => {
                    c.value_u64().map(|v| v & mask == 0).unwrap_or(false)
                }
                _ => false,
            }
        }

        Ok(match e {
            il::Expression::Or(lhs, rhs) => {
                if or_eliminate(bits, &lhs) {
                    *rhs
                } else if or_eliminate(bits, &rhs) {
                    *lhs
                } else {
                    il::Expression::or(*lhs, *rhs)?
                }
            }
            _ => e,
        })
    }
// We have reached an optimization that allows us to safely eliminate upper
// bits in some circumstances. For example trun.8(0xFFFFFF00:32 | e:32) can be
// simplified to trun.8(e:32)
We have reached an optimization that allows us to safely eliminate upper
bits in some circumstances. For example trun.8(0xFFFFFF00:32 | e:32) can be
simplified to trun.8(e:32)
We have reached an optimization that allows us to safely eliminate upper bits in some circumstances . For example trun . 8 ( 0xFFFFFF00 : 32 | e : 32 ) can be simplified to trun . 8 ( e : 32 )
fn eliminate_upper_bits(bits: usize, e: il::Expression) -> Result<il::Expression> {
        // Returns true if this side of an or statement can be safely eliminated
        fn or_eliminate(bits: usize, e: &il::Expression) -> bool {
            let mask: u64 = (1 << (bits as u64)) - 1;
            match e {
                il::Expression::Constant(c) => {
                    c.value_u64().map(|v| v & mask == 0).unwrap_or(false)
                }
                _ => false,
            }
        }
        Ok(match e {
            il::Expression::Or(lhs, rhs) => {
                if or_eliminate(bits, &lhs) {
                    *rhs
                } else if or_eliminate(bits, &rhs) {
                    *lhs
                } else {
                    il::Expression::or(*lhs, *rhs)?
                }
            }
            _ => e,
        })
    }
fn eliminate_upper_bits ( bits : usize , e : il :: Expression ) -> Result < il :: Expression > { // Returns true if this side of an or statement can be safely eliminated fn or_eliminate ( bits : usize , e : & il :: Expression ) -> bool { let mask : u64 = ( 1 << ( bits as u64 ) ) - 1 ; match e { il :: Expression :: Constant ( c ) => { c . value_u64 ( ) . map ( | v | v & mask == 0 ) . unwrap_or ( false ) } _ => false , } } Ok ( match e { il :: Expression :: Or ( lhs , rhs ) => { if or_eliminate ( bits , & lhs ) { * rhs } else if or_eliminate ( bits , & rhs ) { * lhs } else { il :: Expression :: or ( * lhs , * rhs ) ? } } _ => e , } ) }
We have reached an optimization that allows us to safely eliminate upper
bits in some circumstances.
We have reached an optimization that allows us to safely eliminate upper bits in some circumstances .
bits
usize
e
il::Expression