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)
commit3217b6c66195ba593c9caa428c1c911f85998f00
treeb8d79e9e2c10cd82414cfe7dc2b5251b797c0c12
parent6ae079ee4ae0b33c393de1b2a16e70d2ae57a35a
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

llvm-svn: 210312
llvm/lib/Transforms/InstCombine/InstCombine.h
llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
llvm/test/Transforms/InstCombine/abs_abs.ll [new file with mode: 0644]