OSDN Git Service

Canonicalize -1 - x to ~x.
authorEvan Cheng <evan.cheng@apple.com>
Mon, 18 Jan 2010 21:38:44 +0000 (21:38 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Mon, 18 Jan 2010 21:38:44 +0000 (21:38 +0000)
commit1ad0e8b5769f25ca442f3d77bf374d03469010bc
treea4413ab41fe7bc56f036ec89728f80bde599b205
parent2d53c21eca34b77bbe12a5208af9da780d6465c8
Canonicalize -1 - x to ~x.

Instcombine does this but apparently there are situations where this pattern will escape the optimizer and / or created by isel. Here is a case that's seen in JavaScriptCore:
  %t1 = sub i32 0, %a
  %t2 = add i32 %t1, -1
The dag combiner pattern: ((c1-A)+c2) -> (c1+c2)-A
will fold it to -1 - %a.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93773 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/SelectionDAG/DAGCombiner.cpp
test/CodeGen/X86/xor.ll