This is an archive of the discontinued LLVM Phabricator instance.

[X86] Promote i16 SRA instructions to i32
ClosedPublic

Authored by craig.topper on Apr 4 2019, 11:21 AM.

Details

Summary

We already promote SRL and SHL to i32.

This will introduce sign extends sometimes which might be harder to deal with than the zero we use for promoting SRL. I ran this through some of our internal benchmark lists and didn't see any major regressions.

I think there might be some DAG combine improvement opportunities in the test changes here.

Diff Detail

Repository
rL LLVM

Event Timeline

craig.topper created this revision.Apr 4 2019, 11:21 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 4 2019, 11:21 AM
Herald added subscribers: jfb, hiraditya. · View Herald Transcript
spatel accepted this revision.Apr 4 2019, 3:11 PM

LGTM.

It would be nice to fix some of these cases, but I suspect it's going to take several steps starting with something like D60286. That's a response to trying to add the DAG equivalent of this instcombine:

// shl (zext X), ShAmt --> zext (shl X, ShAmt)
// This is only valid if X would have zeros shifted out.
Value *X;
if (match(Op0, m_ZExt(m_Value(X)))) {
  unsigned SrcWidth = X->getType()->getScalarSizeInBits();
  if (ShAmt < SrcWidth &&
      MaskedValueIsZero(X, APInt::getHighBitsSet(SrcWidth, ShAmt), 0, &I))
    return new ZExtInst(Builder.CreateShl(X, ShAmt), Ty);
}
This revision is now accepted and ready to land.Apr 4 2019, 3:11 PM
This revision was automatically updated to reflect the committed changes.