[PATCH] D157972: [DAG] SimplifyDemandedBits - add sra(shl(x,c1),c1) -> sign_extend_inreg(x) demanded elts fold
Simon Pilgrim via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 15 05:57:25 PDT 2023
RKSimon created this revision.
RKSimon added reviewers: goldstein.w.n, pengfei, craig.topper.
Herald added subscribers: steven.zhang, atanasyan, hiraditya, arichardson, sdardis.
Herald added a project: All.
RKSimon requested review of this revision.
Herald added a subscriber: wangpc.
Herald added a project: LLVM.
Begin moving the sra(shl(x,c1),c1) -> sign_extend_inreg(x) fold inside SimplifyDemandedBits so we can recognize hidden splats with DemandedElts masks.
Because the c1 shift amount has multiple uses, hidden splats won't get simplified to a splat constant buildvector - meaning the existing fold in DAGCombiner::visitSRA can't fire as it won't see a uniform shift amount.
I had hoped to remove the DAGCombiner::visitSRA implementation entirely, but several targets (PPC + MIPS in particular) are missing ComputeNumSignBitsForTargetNode handling for their target nodes, making it tricky for superflous sign_extend_inreg nodes to be removed later on.
I also needed to add TLI preferSextInRegOfTruncate hook to help keep truncate(sign_extend_inreg(x)) vector patterns on X86 so we can use PACKSS more efficiently.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D157972
Files:
llvm/include/llvm/CodeGen/TargetLowering.h
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/lib/Target/X86/X86ISelLowering.h
llvm/test/CodeGen/X86/packss.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157972.550291.patch
Type: text/x-patch
Size: 13287 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230815/4cd65579/attachment.bin>
More information about the llvm-commits
mailing list