This is an archive of the discontinued LLVM Phabricator instance.

Implement SystemZIselLowering::hasAndNot
AbandonedPublic

Authored by MatzeB on Sep 15 2021, 1:36 PM.

Details

Summary
  • SystemZ appears to have the vnc instruction producing an "and-not" effect. Therefore SystemZIselLowering::hasAndNot can return true.
  • This led to different patterns generated for abs which are added here as well.

This change improves SystemZ codegen and will avoid code generation regressions with https://reviews.llvm.org/D109194

Diff Detail

Event Timeline

MatzeB created this revision.Sep 15 2021, 1:36 PM
MatzeB requested review of this revision.Sep 15 2021, 1:36 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 15 2021, 1:36 PM
uweigand added inline comments.Sep 16 2021, 7:13 AM
llvm/lib/Target/SystemZ/SystemZInstrVector.td
933

Are you sure these are right? Unless I'm missing something, they appear to be swapped:

Looking at the first pattern, if x is positive then the shift value will be 0, therefore the and will be 0, therefore the xor will be a no-op and the return is -x. If x is negative, the shift value will be -1, so the and is a no-op, and the result is -x ^ x ^ -x, which is x. So in summary the pattern matches x >= 0 ? -x : x, which is the *negated* absolute value, while the pattern resolves to lp, which compute the absolute value.

Also, I think these patterns would be more readable if broken up into multiple lines like the other patterns in this group - the indentation shows more easily how the operations are grouped.

MatzeB abandoned this revision.Oct 28 2021, 1:52 PM

I abandoned D109194 in favor of a SelectionDAG/X86 solution in D112754 so this is not necessary anymore to avoid regressions. Abandoning.