[InstCombine] fold mul-with-overflow intrinsic with -1 operand
authorSanjay Patel <spatel@rotateright.com>
Mon, 28 Feb 2022 17:13:55 +0000 (12:13 -0500)
committerSanjay Patel <spatel@rotateright.com>
Mon, 28 Feb 2022 19:13:48 +0000 (14:13 -0500)
commit278b407a30857ef12b8599cc1754179a289e8680
treefc6b26b166a4e3771fa51df8c8a45551fc015c83
parent6e9a8cdcfb15ec01af91d1be29eb1899b37f285c
[InstCombine] fold mul-with-overflow intrinsic with -1 operand

extractvalue (any_mul_with_overflow X, -1), 0 --> -X

There are similar other potential transforms that we could do as
noted by the last TODO in the test diffs.

Fixes #54053
llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
llvm/test/Transforms/InstCombine/with_overflow.ll