Added select flavour for ABS and NEG(ABS)
authorDinesh Dwivedi <dinesh.d@samsung.com>
Fri, 6 Jun 2014 06:54:45 +0000 (06:54 +0000)
committerDinesh Dwivedi <dinesh.d@samsung.com>
Fri, 6 Jun 2014 06:54:45 +0000 (06:54 +0000)
commit2c3e3b491eb60d61e0780c34fcf0b20355d2e431
tree9cb6894fd056136ec94df5b630ba06e9438f4a75
parent7a0e6972ce2e43fc006acd87a0f7b9cc5eb136bf
Added select flavour for ABS and NEG(ABS)

This patch can identify
  ABS(X) ==> (X >s 0) ? X : -X and (X >s -1) ? X : -X
  ABS(X) ==> (X <s 0) ? -X : X and (X <s 1) ? -X : X
  NABS(X) ==> (X >s 0) ? -X : X and (X >s -1) ? -X : X
  NABS(X) ==> (X <s 0) ? X : -X and (X <s 1) ? X : -X

and can transform
  ABS(ABS(X)) -> ABS(X)
  NABS(NABS(X)) -> NABS(X)

Differential Revision: http://reviews.llvm.org/D3658

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210312 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/InstCombine/InstCombine.h
lib/Transforms/InstCombine/InstCombineSelect.cpp
test/Transforms/InstCombine/abs_abs.ll [new file with mode: 0644]