[PATCH] D136559: [DAG] Fold (abs (sign_extend_inreg x)) -> (zero_extend (abs (truncate x))) (PR43370)
Simon Pilgrim via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 23 11:18:59 PDT 2022
RKSimon created this revision.
RKSimon added reviewers: spatel, craig.topper, nikic, lebedev.ri.
Herald added subscribers: StephenFan, ecnelises, pengfei, hiraditya.
Herald added a project: All.
RKSimon requested review of this revision.
Herald added a project: LLVM.
If the upper half of an abs() is all sign bits, then we can perform the abs() using just the lower half and then zero extend.
I've limited the DAG combine to only sign_extend_inreg (and free truncate/zero_extend) to minimise any later promotion issues, but for legalization a similar fold can use ComputeNumSignBits to be more aggressive.
Alive2: https://alive2.llvm.org/ce/z/y32fS4
Fixes #43370
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D136559
Files:
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
llvm/test/CodeGen/X86/abs.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136559.469995.patch
Type: text/x-patch
Size: 4162 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221023/7fe67b96/attachment.bin>
More information about the llvm-commits
mailing list