This is an archive of the discontinued LLVM Phabricator instance.

[DAG] Allow isNullOrNullSplat to see truncated zeroes
ClosedPublic

Authored by dmgreen on Jun 5 2021, 11:51 AM.

Details

Summary

This sets the AllowTruncation flag on isConstOrConstSplat in isNullOrNullSplat, allowing it to see truncated constant zeroes on architectures such as AArch64, where only a i32.i64 are legal. As a truncation of 0 is always 0, this should always be valid, allowing some extra folding to happen including some of the cases from D103755.

Whilst I'm here also add a call to peekThroughBitcasts as bitcast Zero is still Zero, and removed a related TODO comment from isOneOrOneSplat as the bitcast of 1 isn't always still 1.

Diff Detail

Event Timeline

dmgreen created this revision.Jun 5 2021, 11:51 AM
dmgreen requested review of this revision.Jun 5 2021, 11:51 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 5 2021, 11:51 AM
Herald added a subscriber: MaskRay. · View Herald Transcript

Whilst I'm here also add a call to peekThroughBitcasts as bitcast Zero is still Zero, and removed a related TODO comment from isOneOrOneSplat as the bitcast of 1 isn't always still 1.

Is this necessary for any of the test changes? I just wonder whether we should add this separately.

llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
9605

/*AllowTruncation*/true ?

Whilst I'm here also add a call to peekThroughBitcasts as bitcast Zero is still Zero, and removed a related TODO comment from isOneOrOneSplat as the bitcast of 1 isn't always still 1.

Is this necessary for any of the test changes? I just wonder whether we should add this separately.

Sure, I can remove it from here, it won't effect any of the test cases. I believe we will already turn bitcast(buildvector(0's)) to buildvector(0's) already.

dmgreen updated this revision to Diff 350183.Jun 6 2021, 11:56 PM
RKSimon accepted this revision.Jun 7 2021, 1:04 AM

LGTM - cheers

Whilst I'm here also add a call to peekThroughBitcasts as bitcast Zero is still Zero, and removed a related TODO comment from isOneOrOneSplat as the bitcast of 1 isn't always still 1.

You need to update the patch summary.

This revision is now accepted and ready to land.Jun 7 2021, 1:04 AM

RISCV changes LGTM

Thanks Folks.

This revision was automatically updated to reflect the committed changes.