[PATCH] D106983: [DAGCombiner] don't try to partially reduce add-with-overflow ops

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 28 12:17:22 PDT 2021


spatel created this revision.
spatel added reviewers: deadalnix, RKSimon, lebedev.ri.
Herald added subscribers: ecnelises, pengfei, hiraditya, mcrosier.
spatel requested review of this revision.
Herald added a project: LLVM.

This transform was added with D58874 <https://reviews.llvm.org/D58874>, but there were no tests for overflow ops.
We need to change this one way or another because it can crash as shown in:
https://llvm.org/PR51238

Note that if there are no uses of an overflow op's bool overflow result, we reduce it to a regular math op, so we continue to fold that case either way.
If we have uses of both the math and the overflow bool, then we are likely not saving anything by creating an independent sub instruction as seen in the test diffs here.

This patch would make the behavior in SDAG consistent with what we do in instcombine AFAICT.


https://reviews.llvm.org/D106983

Files:
  llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  llvm/test/CodeGen/AArch64/addsub.ll
  llvm/test/CodeGen/X86/combine-add.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106983.362489.patch
Type: text/x-patch
Size: 3924 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210728/7cf648b9/attachment.bin>


More information about the llvm-commits mailing list