[SystemZ] Be more careful about inverting CC masks
authorRichard Sandiford <rsandifo@linux.vnet.ibm.com>
Wed, 31 Jul 2013 12:30:20 +0000 (12:30 +0000)
committerRichard Sandiford <rsandifo@linux.vnet.ibm.com>
Wed, 31 Jul 2013 12:30:20 +0000 (12:30 +0000)
commit6824f127f90197b26af93cf5d6c13b7941567e54
treed5108ab426eae97930ad3b1bbd034fe0802403d8
parent0416e3c599c22dc656a1115ac983116ad0b2d9da
[SystemZ] Be more careful about inverting CC masks

System z branches have a mask to select which of the 4 CC values should
cause the branch to be taken.  We can invert a branch by inverting the mask.
However, not all instructions can produce all 4 CC values, so inverting
the branch like this can lead to some oddities.  For example, integer
comparisons only produce a CC of 0 (equal), 1 (less) or 2 (greater).
If an integer EQ is reversed to NE before instruction selection,
the branch will test for 1 or 2.  If instead the branch is reversed
after instruction selection (by inverting the mask), it will test for
1, 2 or 3.  Both are correct, but the second isn't really canonical.
This patch therefore keeps track of which CC values are possible
and uses this when inverting a mask.

Although this is mostly cosmestic, it fixes undefined behavior
for the CIJNLH in branch-08.ll.  Another fix would have been
to mask out bit 0 when generating the fused compare and branch,
but the point of this patch is that we shouldn't need to do that
in the first place.

The patch also makes it easier to reuse CC results from other instructions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187495 91177308-0d34-0410-b5e6-96231b3b80d8
56 files changed:
lib/Target/SystemZ/SystemZ.h
lib/Target/SystemZ/SystemZISelLowering.cpp
lib/Target/SystemZ/SystemZInstrFormats.td
lib/Target/SystemZ/SystemZInstrInfo.cpp
lib/Target/SystemZ/SystemZInstrInfo.h
lib/Target/SystemZ/SystemZInstrInfo.td
lib/Target/SystemZ/SystemZLongBranch.cpp
lib/Target/SystemZ/SystemZOperators.td
lib/Target/SystemZ/SystemZPatterns.td
test/CodeGen/SystemZ/atomic-store-03.ll
test/CodeGen/SystemZ/atomic-store-04.ll
test/CodeGen/SystemZ/atomicrmw-add-01.ll
test/CodeGen/SystemZ/atomicrmw-add-02.ll
test/CodeGen/SystemZ/atomicrmw-add-03.ll
test/CodeGen/SystemZ/atomicrmw-add-04.ll
test/CodeGen/SystemZ/atomicrmw-and-01.ll
test/CodeGen/SystemZ/atomicrmw-and-02.ll
test/CodeGen/SystemZ/atomicrmw-and-03.ll
test/CodeGen/SystemZ/atomicrmw-and-04.ll
test/CodeGen/SystemZ/atomicrmw-minmax-01.ll
test/CodeGen/SystemZ/atomicrmw-minmax-02.ll
test/CodeGen/SystemZ/atomicrmw-minmax-03.ll
test/CodeGen/SystemZ/atomicrmw-minmax-04.ll
test/CodeGen/SystemZ/atomicrmw-nand-01.ll
test/CodeGen/SystemZ/atomicrmw-nand-02.ll
test/CodeGen/SystemZ/atomicrmw-nand-03.ll
test/CodeGen/SystemZ/atomicrmw-nand-04.ll
test/CodeGen/SystemZ/atomicrmw-or-01.ll
test/CodeGen/SystemZ/atomicrmw-or-02.ll
test/CodeGen/SystemZ/atomicrmw-or-03.ll
test/CodeGen/SystemZ/atomicrmw-or-04.ll
test/CodeGen/SystemZ/atomicrmw-sub-01.ll
test/CodeGen/SystemZ/atomicrmw-sub-02.ll
test/CodeGen/SystemZ/atomicrmw-sub-03.ll
test/CodeGen/SystemZ/atomicrmw-sub-04.ll
test/CodeGen/SystemZ/atomicrmw-xchg-01.ll
test/CodeGen/SystemZ/atomicrmw-xchg-02.ll
test/CodeGen/SystemZ/atomicrmw-xchg-03.ll
test/CodeGen/SystemZ/atomicrmw-xchg-04.ll
test/CodeGen/SystemZ/atomicrmw-xor-01.ll
test/CodeGen/SystemZ/atomicrmw-xor-02.ll
test/CodeGen/SystemZ/atomicrmw-xor-03.ll
test/CodeGen/SystemZ/atomicrmw-xor-04.ll
test/CodeGen/SystemZ/branch-08.ll
test/CodeGen/SystemZ/cmpxchg-01.ll
test/CodeGen/SystemZ/cmpxchg-02.ll
test/CodeGen/SystemZ/cond-move-01.ll
test/CodeGen/SystemZ/cond-store-01.ll
test/CodeGen/SystemZ/cond-store-02.ll
test/CodeGen/SystemZ/cond-store-03.ll
test/CodeGen/SystemZ/cond-store-04.ll
test/CodeGen/SystemZ/cond-store-05.ll
test/CodeGen/SystemZ/cond-store-06.ll
test/CodeGen/SystemZ/cond-store-07.ll
test/CodeGen/SystemZ/cond-store-08.ll
test/CodeGen/SystemZ/int-cmp-02.ll