Skip to content

[DAG] Match fixed width ISD::AVGFLOORS + ISD::AVGCEILS patterns #85779

Closed
@RKSimon

Description

@RKSimon

Followup to #84749 and #84753

We can match the signed AVG variants in a similar way:

define i4 @src_avgfloors(i4 %a0, i4 %a1)  {
  %and = and i4 %a0, %a1
  %xor = xor i4 %a0, %a1
  %srl = ashr i4 %xor, 1
  %res = add i4 %and, %srl
  ret i4 %res
}
define i4 @src_avgceils(i4 %a0, i4 %a1)  {
  %or = or i4 %a0, %a1
  %xor = xor i4 %a0, %a1
  %srl = ashr i4 %xor, 1
  %res = sub i4 %or, %srl
  ret i4 %res
}

Alive2: https://alive2.llvm.org/ce/z/L4yGAx

Metadata

Metadata

Assignees

Labels

good first issuehttps://github.com/llvm/llvm-project/contributellvm:SelectionDAGSelectionDAGISel as well

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions