[InstCombine] Support (sub (sext x), (sext y)) --> (sext (sub x, y)) and (sub (zext...
authorCraig Topper <craig.topper@intel.com>
Sat, 15 Sep 2018 18:54:10 +0000 (18:54 +0000)
committerCraig Topper <craig.topper@intel.com>
Sat, 15 Sep 2018 18:54:10 +0000 (18:54 +0000)
commit2da738167886d4a56a74d351f9586f309c1bfb2e
treeaf1618c250b0a4c9d0e0b1c37159c48414ca9cdd
parent0bd2d304e672c4a573affa2b10f67304d03f415a
[InstCombine] Support (sub (sext x), (sext y)) --> (sext (sub x, y)) and (sub (zext x), (zext y)) --> (zext (sub x, y))

Summary:
If the sub doesn't overflow in the original type we can move it above the sext/zext.

This is similar to what we do for add. The overflow checking for sub is currently weaker than add, so the test cases are constructed for what is supported.

Reviewers: spatel

Reviewed By: spatel

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D52075

llvm-svn: 342335
llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
llvm/test/Transforms/InstCombine/narrow-math.ll