This is an archive of the discontinued LLVM Phabricator instance.

[DAG] FoldConstantArithmetic - fold intop(bitcast(buildvector(c1)),bitcast(buildvector(c1))) -> bitcast(intop(buildvector(c1'),buildvector(c2')))
ClosedPublic

Authored by RKSimon on Nov 10 2021, 5:54 AM.

Details

Summary

Enable FoldConstantArithmetic to constant fold bitcasted constant build vectors. These have typically been bitcasted for type legalization purposes.

By extracting the raw constant bit data, performing the constant fold, and then casting the constant bit data back to the (legalized) type, we can perform constant folding on integer types after legalization.

This in particular helps 32-bit targets which need to handle vXi64 build vectors - during legalization the (unsupported) i64 elements are split to create a bitcasted v2Xi32 build vector.

Addresses some regressions in D113192.

Diff Detail

Event Timeline

RKSimon created this revision.Nov 10 2021, 5:54 AM
RKSimon requested review of this revision.Nov 10 2021, 5:54 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 10 2021, 5:54 AM
lebedev.ri accepted this revision.Nov 10 2021, 8:56 AM

Looks good to me, but please wait for one more review.

This revision is now accepted and ready to land.Nov 10 2021, 8:56 AM
pengfei accepted this revision.Nov 10 2021, 5:41 PM

This tests look good.

llvm/test/CodeGen/X86/packss.ll
200–203

Nit, I think this value is not necessary now.