This is an archive of the discontinued LLVM Phabricator instance.

[LV] Fold Add/Mul with neutral elements.
Needs ReviewPublic

Authored by fhahn on Jun 11 2023, 3:23 PM.

Details

Summary

Building on D152659, fold add/mul with their neutral elements.

There is a large number of tests that need updating, which I will do
if/once there's agreement on the direction. The missing fold was pointed
out in D147783

Depends on D152659.

Diff Detail

Event Timeline

fhahn created this revision.Jun 11 2023, 3:23 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 11 2023, 3:23 PM
fhahn requested review of this revision.Jun 11 2023, 3:23 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 11 2023, 3:23 PM
fhahn added a comment.Jun 12 2023, 2:38 AM

Interestingly, this is also causing some binary changes, so is presumably catching same missed simplifications or enabling additional/earlier simplifications: https://llvm-compile-time-tracker.com/compare.php?from=e3753cc0f9c8404f21dd7486febfb4766f4c9659&to=d34adaeac19f4555a08b38e65b393999c421237c&stat=size-text

Ayal added inline comments.Jun 15 2023, 7:17 AM
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
2517

Note the attempt here to apply add-zero and multiply-by-one foldings.

llvm/test/Transforms/LoopVectorize/RISCV/strided-accesses.ll
21

Redundant code in preheader, optimize the recipe that (will/not) generate it?

228

More mul-by-one opportunities to fold?

715

More mul-by-zero opportunities to fold?