[DAG] optimize negation of bool
authorSanjay Patel <spatel@rotateright.com>
Wed, 19 Oct 2016 16:58:59 +0000 (16:58 +0000)
committerSanjay Patel <spatel@rotateright.com>
Wed, 19 Oct 2016 16:58:59 +0000 (16:58 +0000)
commit3a3aaf67e07ade866b9500a9466086a68d0dd70c
tree15006d3cec17160af880cfd3669c039ad95dd5ea
parent383803230bba0c0dea3d93d9eb4f97d6fa8f3718
[DAG] optimize negation of bool

Use mask and negate for legalization of i1 source type with SIGN_EXTEND_INREG.
With the mask, this should be no worse than 2 shifts. The mask can be eliminated
in some cases, so that should be better than 2 shifts.

This change exposed some missing folds related to negation:
https://reviews.llvm.org/rL284239
https://reviews.llvm.org/rL284395

There may be others, so please let me know if you see any regressions.

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

llvm-svn: 284611
14 files changed:
llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
llvm/test/CodeGen/ARM/negate-i1.ll
llvm/test/CodeGen/Mips/llvm-ir/add.ll
llvm/test/CodeGen/Mips/llvm-ir/mul.ll
llvm/test/CodeGen/Mips/llvm-ir/sdiv.ll
llvm/test/CodeGen/Mips/llvm-ir/srem.ll
llvm/test/CodeGen/Mips/llvm-ir/sub.ll
llvm/test/CodeGen/Mips/llvm-ir/urem.ll
llvm/test/CodeGen/Mips/select.ll
llvm/test/CodeGen/PowerPC/negate-i1.ll
llvm/test/CodeGen/SystemZ/branch-07.ll
llvm/test/CodeGen/SystemZ/risbg-01.ll
llvm/test/CodeGen/SystemZ/shift-10.ll
llvm/test/CodeGen/X86/negate-i1.ll