This is an archive of the discontinued LLVM Phabricator instance.

DAGCombiner: don't do (zext (trunc x)) -> (and x, 65535) if !hasOneUse(trunc x) and zext is free
AbandonedPublic

Authored by escha on Jan 26 2016, 12:54 PM.

Details

Reviewers
resistor
Summary

This came up in our out of tree target and results in a lot of cases where 'x' ends up used by both (trunc x) and (and x, 65535), causing x to no longer have one use when it really should (and ending up materializing wasted instructions later).

Diff Detail

Repository
rL LLVM

Event Timeline

escha updated this revision to Diff 46037.Jan 26 2016, 12:54 PM
escha retitled this revision from to DAGCombiner: don't do (zext (trunc x)) -> (and x, 65535) if !hasOneUse(trunc x) and zext is free.
escha updated this object.
escha added a reviewer: resistor.
escha set the repository for this revision to rL LLVM.
escha added a subscriber: llvm-commits.
arsenm added a subscriber: arsenm.Jan 26 2016, 1:02 PM

Testcase? This should apply to AMDGPU for i64/i32. For AMDGPU at least, I don't think we would want this even if there are multiple uses

Actually shouldn't the and turn back into a trunc if it is free?

escha abandoned this revision.Jan 26 2016, 1:53 PM

ANDs can't turn back into truncs; trunc changes the width, AND doesn't; so I'm not *quite* sure what you mean. Either way, sounds like I need to reopen this with a (truncfree && zextfree) case, update the code to the latest revision, and find a test case.