[PATCH] D79304: [DAG] Fold (mul(abs(x),abs(x))) -> (mul(x,x)) (PR39476)

Simon Pilgrim via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun May 3 10:37:29 PDT 2020


RKSimon created this revision.
RKSimon added reviewers: spatel, lebedev.ri, xbolva00, craig.topper.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.

This patch adds support for discarding integer absolutes from self-multiplications.

Alive2: http://volta.cs.utah.edu:8080/z/rwcc8W

As part of this I've pulled out various absolute pattern matching code snippets we have and moved them into a MatchABS helper, which returns the source operand on success. We can add other ABS patterns here as required (e.g. PR45691).

NOTE: We shouldn't move the select(0>X,0-X,X) pattern as this is always canonicalized to a branchless pattern in visitVSELECT even if ISD::ABS isn't legal.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79304

Files:
  llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  llvm/test/CodeGen/X86/combine-mul.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79304.261701.patch
Type: text/x-patch
Size: 6659 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200503/e7eb3101/attachment.bin>


More information about the llvm-commits mailing list