OSDN Git Service

[InstCombine] fold add(zext(xor X, C), C) --> sext X when C is INT_MIN in the source...
authorSanjay Patel <spatel@rotateright.com>
Tue, 19 Jul 2016 22:09:34 +0000 (22:09 +0000)
committerSanjay Patel <spatel@rotateright.com>
Tue, 19 Jul 2016 22:09:34 +0000 (22:09 +0000)
commit11faea381faa3e73d2532bde864df1936713be97
tree393b24c3074929d1af6dfed15802c46ba7d9c7d5
parentfed9fd5a7a75e3baa14b062d282a8d92f8ed053d
[InstCombine] fold add(zext(xor X, C), C) --> sext X when C is INT_MIN in the source type

The pattern may look more obviously like a sext if written as:

  define i32 @g(i16 %x) {
    %zext = zext i16 %x to i32
    %xor = xor i32 %zext, 32768
    %add = add i32 %xor, -32768
    ret i32 %add
  }

We already have that fold in visitAdd().

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@276035 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/InstCombine/InstCombineAddSub.cpp
test/Transforms/InstCombine/apint-add.ll