Skip to content

[ADT] Add APIntOps::avgfloors/avgflooru/avgceils/avgceilu #84211

Closed
@RKSimon

Description

@RKSimon
  • Move implementations from SelectionDAG.cpp FoldValue into APInt.h APIntOps
    case ISD::AVGFLOORS: {
    unsigned FullWidth = C1.getBitWidth() + 1;
    APInt C1Ext = C1.sext(FullWidth);
    APInt C2Ext = C2.sext(FullWidth);
    return (C1Ext + C2Ext).extractBits(C1.getBitWidth(), 1);
    }
    case ISD::AVGFLOORU: {
    unsigned FullWidth = C1.getBitWidth() + 1;
    APInt C1Ext = C1.zext(FullWidth);
    APInt C2Ext = C2.zext(FullWidth);
    return (C1Ext + C2Ext).extractBits(C1.getBitWidth(), 1);
    }
    case ISD::AVGCEILS: {
    unsigned FullWidth = C1.getBitWidth() + 1;
    APInt C1Ext = C1.sext(FullWidth);
    APInt C2Ext = C2.sext(FullWidth);
    return (C1Ext + C2Ext + 1).extractBits(C1.getBitWidth(), 1);
    }
    case ISD::AVGCEILU: {
    unsigned FullWidth = C1.getBitWidth() + 1;
    APInt C1Ext = C1.zext(FullWidth);
    APInt C2Ext = C2.zext(FullWidth);
    return (C1Ext + C2Ext + 1).extractBits(C1.getBitWidth(), 1);
    }
  • Add APIntTest unit test coverage

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions