[PATCH] D148440: [InstCombine] Fold zext(shl(trunc)) into and(shl)

Kazu Hirata via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 17 12:27:57 PDT 2023


kazu added a comment.

In D148440#4271660 <https://reviews.llvm.org/D148440#4271660>, @kazu wrote:

> I missed the entire block of code in `InstCombinerImpl::visitZExt` to widen an expression tree:
>
>   // Try to extend the entire expression tree to the wide destination type.                                            
>   unsigned BitsToClear;
>   if (shouldChangeType(SrcTy, DestTy) &&
>       canEvaluateZExtd(Src, DestTy, BitsToClear, *this, &Zext)) {
>
> Let me see if I could modify this block code to accommodate our trunc-shl-zext sequence.

On X86 at least, `shouldChangeType` returns `false` on going from 16-bit integers to 32-bit integers because `DataLayout::isLegalInteger` always returns `false`.  Note that `LegalIntWidths` is empty on X86.

Widening narrow computation to well supported types like i32 or i64 seems to be a worthwhile transformation.

Do we happen to know why `LegalIntWidths` is empty on X86?  Anyone?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148440/new/

https://reviews.llvm.org/D148440



More information about the llvm-commits mailing list