This is an archive of the discontinued LLVM Phabricator instance.

[AArch64] Enhance 'isBitfieldPositioningOp' to find pattern (shl(and(val,mask), N)
ClosedPublic

Authored by mingmingl on Oct 12 2022, 9:58 PM.

Details

Summary

Before this patch (and D135844)

  • Given DAG node shl(op, N), isBitfieldPositioningOp uses (optionally shifted)op as the Src (least significant bits of Src are inserted into DstLSB of Dst node)

After this patch

  • If op is and(val, mask), isBitfieldPositioningOp tries to see through and and find if val is a simpler source than op.

The motivation is similar (probably symmetric) to isSeveralBitsExtractOpFromShr for isBitfieldExtractOpFromShr

Existing test cases are improved without regressions.

Diff Detail

Event Timeline

mingmingl created this revision.Oct 12 2022, 9:58 PM
mingmingl requested review of this revision.Oct 12 2022, 9:58 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 12 2022, 9:58 PM
mingmingl retitled this revision from [AArch64]Enhance 'isBitfieldPositioningOp' to find pattern (shl(and(val,mask), N) to [AArch64][3/4]Enhance 'isBitfieldPositioningOp' to find pattern (shl(and(val,mask), N).Oct 13 2022, 12:19 AM
mingmingl edited the summary of this revision. (Show Details)
mingmingl added a reviewer: dmgreen.

This seems similar to a demand bits fold. Can it check that AndMask is a superset of AllOnes >> Shift?

mingmingl updated this revision to Diff 467947.Oct 14 2022, 3:51 PM
mingmingl retitled this revision from [AArch64][3/4]Enhance 'isBitfieldPositioningOp' to find pattern (shl(and(val,mask), N) to [AArch64] Enhance 'isBitfieldPositioningOp' to find pattern (shl(and(val,mask), N).

Address comments.

This seems similar to a demand bits fold. Can it check that AndMask is a superset of AllOnes >> Shift?

Checking AndMask is a superset of AllOnes >> Shift makes sense. Done by checking isMask_64((AndImm << Shift) >> Shift).

  • This patch previously introduced a bug (fixed in the latest reply) by checking isShiftedMask_64((AndImm << Shift) >> Shift).

Also make refactor patch a parent of this one (bypassing D135844).

dmgreen accepted this revision.Oct 17 2022, 1:07 AM

LGTM

This revision is now accepted and ready to land.Oct 17 2022, 1:07 AM
This revision was landed with ongoing or failed builds.Oct 17 2022, 9:02 AM
This revision was automatically updated to reflect the committed changes.