[PATCH] D23893: [DAGCombine] Don't fold a trunc if it feeds an anyext

Michael Kuperstein via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 26 10:01:10 PDT 2016


mkuper added a comment.

In https://reviews.llvm.org/D23893#525962, @RKSimon wrote:

> Are the mem-intrin-base-reg.ll changes relevant?


Surprisingly, yes.

The test was documented to use a vector pattern to create an "aligned temporary" from the vector compare and extract.
We used to generate:

  pcmpgtd %xmm1, %xmm0
  movdqa  %xmm0, 32(%esp)
  movzbl  32(%esp), %eax
  andl    $1, %eax

With this patch, we no longer have the temporary - we now get:

  pcmpgtd %xmm1, %xmm0
  movd    %xmm0, %eax
  andl    $1, %eax

This is clearly better - but the temporary at 32(%esp) is gone.
The alloca forces the stack back into alignment.


================
Comment at: lib/CodeGen/SelectionDAG/DAGCombiner.cpp:7139
@@ +7138,3 @@
+  // If this is anyext(trunc), don't fold it, allow ourselves to be folded.
+  if (N->hasOneUse() && (N->use_begin()->getOpcode() == ISD::ANY_EXTEND))
+    return SDValue();
----------------
RKSimon wrote:
> Should we limit this to AfterLegalizeTypes or later?
My motivation for this was a situation that occurs post-legalization, but I don't see anything specific to being post-legalization that makes this a good (or bad) idea.
Why do you think we should limit this?


https://reviews.llvm.org/D23893





More information about the llvm-commits mailing list