This is an archive of the discontinued LLVM Phabricator instance.

[ConstantFolding] fold abs intrinsic
ClosedPublic

Authored by spatel on Jul 30 2020, 6:36 AM.

Details

Summary

The handling for minimum value is similar to cttz/ctlz with 0 just above this case.

Diff Detail

Event Timeline

spatel created this revision.Jul 30 2020, 6:36 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 30 2020, 6:36 AM
spatel requested review of this revision.Jul 30 2020, 6:36 AM
aqjune added inline comments.Jul 30 2020, 8:59 AM
llvm/test/Analysis/ConstantFolding/abs.ll
46

(a silly question) abs with a vector input is optimized here, but this patch is about non-vector integers; do you have any idea which part of ConstantFolding.cpp is responsible for this?

spatel marked an inline comment as done.Jul 30 2020, 9:11 AM
spatel added inline comments.
llvm/lib/Analysis/ConstantFolding.cpp
2858

Vector types are handled by calling the scalar fold for each element.

llvm/test/Analysis/ConstantFolding/abs.ll
46

Not silly - I used the vector test to reduce the number of tests needed, and it's not obvious from just this patch how that works. :)
I put an inline comment at the place where vectors get expanded. So this test is sequentially calling into the scalar code 8 times (once for each element of the vector).

aqjune accepted this revision.Jul 30 2020, 9:23 AM

LGTM

llvm/test/Analysis/ConstantFolding/abs.ll
46

Thank you for the kind explanation! :)

This revision is now accepted and ready to land.Jul 30 2020, 9:23 AM
This revision was automatically updated to reflect the committed changes.
spatel marked an inline comment as done.