This is an archive of the discontinued LLVM Phabricator instance.

[SelectionDAG] Add a freeze to ISD::ABS expansion.
ClosedPublic

Authored by craig.topper on May 22 2022, 12:46 PM.

Details

Summary

I had initially assumed this was the problem with
https://github.com/llvm/llvm-project/issues/55271#issuecomment-1133426243

But it turns out that was a simpler issue. This patch is still
more correct than what we were doing before so figured I'd submit
it anyway.

No test case because I'm not sure how to get an undef around
until expansion.

Looking at the test deltas I wonder if it be valid to combine
(sext_inreg (freeze (aextload X))) -> (freeze (sextload X)).

Diff Detail

Event Timeline

craig.topper created this revision.May 22 2022, 12:46 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 22 2022, 12:46 PM
craig.topper requested review of this revision.May 22 2022, 12:46 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 22 2022, 12:46 PM
Herald added a subscriber: aheejin. · View Herald Transcript
efriedma accepted this revision.May 22 2022, 2:06 PM

LGTM

Looking at the test deltas I wonder if it be valid to combine (sext_inreg (freeze (aextload X))) -> (freeze (sextload X)).

That doesn't directly work: if the loaded value is poison, it isn't sign-extended. You'd have to represent it some other way.

For example, you could introduce a "frozen sextload". Or you could combine abs(sextload(x)) -> y = (freeze (sextload X)); umin(y,sub(0,y)). Or you could introduce a form of "freeze" that freezes undef, but not poison.

This revision is now accepted and ready to land.May 22 2022, 2:06 PM
This revision was landed with ongoing or failed builds.May 22 2022, 2:30 PM
This revision was automatically updated to reflect the committed changes.