diff options
author | Li Jia He <hljhehlj@cn.ibm.com> | 2018-11-29 03:04:39 +0000 |
---|---|---|
committer | Li Jia He <hljhehlj@cn.ibm.com> | 2018-11-29 03:04:39 +0000 |
commit | bcae407a3ce959f089ab964f89b6e7654192a5b6 (patch) | |
tree | d885f0e8c8f4afae6f687a9822302fb3e481c092 /llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp | |
parent | db8dd23204fbda26f03a04dde65929f09b5e5896 (diff) | |
download | bcm5719-llvm-bcae407a3ce959f089ab964f89b6e7654192a5b6.tar.gz bcm5719-llvm-bcae407a3ce959f089ab964f89b6e7654192a5b6.zip |
[PowerPC] Fix a conversion is not considered when the ISD::BR_CC node making the instruction selection
Summary:
A signed comparison of i1 values produces the opposite result to an unsigned one if the condition code
includes less-than or greater-than. This is so because 1 is the most negative signed i1 number and the
most positive unsigned i1 number. The CR-logical operations used for such comparisons are non-commutative
so for signed comparisons vs. unsigned ones, the input operands just need to be swapped.
Reviewed By: steven.zhang
Differential Revision: https://reviews.llvm.org/D54825
llvm-svn: 347831
Diffstat (limited to 'llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp')
-rw-r--r-- | llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp b/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp index 19cad7a603a..8af96804ced 100644 --- a/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp +++ b/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp @@ -4832,6 +4832,15 @@ void PPCDAGToDAGISel::Select(SDNode *N) { case PPC::PRED_NE: Opc = PPC::CRXOR; Swap = false; break; } + // A signed comparison of i1 values produces the opposite result to an + // unsigned one if the condition code includes less-than or greater-than. + // This is because 1 is the most negative signed i1 number and the most + // positive unsigned i1 number. The CR-logical operations used for such + // comparisons are non-commutative so for signed comparisons vs. unsigned + // ones, the input operands just need to be swapped. + if (ISD::isSignedIntSetCC(CC)) + Swap = !Swap; + SDValue BitComp(CurDAG->getMachineNode(Opc, dl, MVT::i1, N->getOperand(Swap ? 3 : 2), N->getOperand(Swap ? 2 : 3)), 0); |