Skip to content

[ADT] Add APIntOps::mulhs / APIntOps::mulhu #84207

Closed
@RKSimon

Description

@RKSimon
  • Move implementations from SelectionDAG.cpp FoldValue into APInt.h APIntOps

    case ISD::MULHS: {
    unsigned FullWidth = C1.getBitWidth() * 2;
    APInt C1Ext = C1.sext(FullWidth);
    APInt C2Ext = C2.sext(FullWidth);
    return (C1Ext * C2Ext).extractBits(C1.getBitWidth(), C1.getBitWidth());

    case ISD::MULHU: {
    unsigned FullWidth = C1.getBitWidth() * 2;
    APInt C1Ext = C1.zext(FullWidth);
    APInt C2Ext = C2.zext(FullWidth);
    return (C1Ext * C2Ext).extractBits(C1.getBitWidth(), C1.getBitWidth());

  • Add APIntTest unit test coverage

  • Update DivisionByConstantTest.cpp (this might require the lhs/rhs operands to be extended to the same bitwidth)

  • Update KnownBitsTest.cpp to use APIntOps::mulhs/u in exhaustive tests

  • Update mlir ArithOps.cpp + SPIRVCanonicalization.cpp to use APIntOps::mulhs/mulhu

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions