This is an archive of the discontinued LLVM Phabricator instance.

[ValueTracking] Improve llvm.abs handling in computeKnownBits.
ClosedPublic

Authored by craig.topper on Jul 30 2020, 9:32 PM.

Details

Summary

Add the optimizations we have in the SelectionDAG version.
Known non-negative copies all known bits. Any known one other than
the sign bit makes result non-negative.

Diff Detail

Event Timeline

craig.topper created this revision.Jul 30 2020, 9:32 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 30 2020, 9:32 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
craig.topper requested review of this revision.Jul 30 2020, 9:32 PM

please can you add some vector tests?

spatel added inline comments.Jul 31 2020, 7:39 AM
llvm/test/Transforms/InstCombine/abs-intrinsic.ll
88

This test folds, so FIXME here is confusing. Do we want a reduced test without the icmp?

define i32 @abs_of_zext(i31 %x) {
  %zext = zext i31 %x to i32
  %abs = call i32 @llvm.abs.i32(i32 %zext, i1 false)
  ret i32 %abs
}

Add vector tests. Remove FIXME from test

llvm/test/Transforms/InstCombine/abs-intrinsic.ll
88

I assume this will be covered by your InstSimplify change?

Upload full patch

LGTM

llvm/test/Transforms/InstCombine/abs-intrinsic.ll
88

Yes, that will get it. No need to duplicate here.

spatel accepted this revision.Jul 31 2020, 3:40 PM
This revision is now accepted and ready to land.Jul 31 2020, 3:40 PM