[SystemZ, TableGen] Fix shift count handling
authorUlrich Weigand <ulrich.weigand@de.ibm.com>
Wed, 1 Aug 2018 11:57:58 +0000 (11:57 +0000)
committerUlrich Weigand <ulrich.weigand@de.ibm.com>
Wed, 1 Aug 2018 11:57:58 +0000 (11:57 +0000)
commit58a9786e8188eef25182a0cd6409e89f5216d45b
tree6abf7f4fd5583d7240e9b265c4b834ce141f3933
parent2b5f3fd7ab1343583cea30a2b96fd3abc9f90c8e
[SystemZ, TableGen] Fix shift count handling

The DAG combiner logic to simplify AND masks in shift counts is invalid.
While it is true that the SystemZ shift instructions ignore all but the
low 6 bits of the shift count, it is still invalid to simplify the AND
masks while the DAG still uses the standard shift operators (which are
*not* defined to match the SystemZ instruction behavior).

Instead, this patch performs equivalent operations during instruction
selection. For completely removing the AND, this now happens via
additional DAG match patterns implemented by a multi-alternative
PatFrags. For simplifying a 32-bit AND to a 16-bit AND, the existing DAG
patterns were already mostly OK, they just needed an output XForm to
actually truncate the immediate value.

Unfortunately, the latter change also exposed a bug in TableGen: it
seems XForms are currently only handled correctly for direct operands of
the outermost operation node. This patch also fixes that bug by simply
recurring through the whole pattern. This should be NFC for all other
targets.

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

llvm-svn: 338521
llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
llvm/lib/Target/SystemZ/SystemZISelLowering.h
llvm/lib/Target/SystemZ/SystemZInstrInfo.td
llvm/lib/Target/SystemZ/SystemZOperands.td
llvm/lib/Target/SystemZ/SystemZOperators.td
llvm/test/CodeGen/SystemZ/shift-12.ll
llvm/utils/TableGen/CodeGenDAGPatterns.cpp