mirror of
https://github.com/RPCS3/llvm.git
synced 2024-12-21 03:28:31 +00:00
The semantics of cast X to bool are a comparison against zero, not a truncation!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21833 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
edcee6f5fd
commit
ef311aa7cf
@ -493,6 +493,11 @@ void SelectionDAGLowering::visitCast(User &I) {
|
||||
|
||||
if (N.getValueType() == DestTy) {
|
||||
setValue(&I, N); // noop cast.
|
||||
} else if (DestTy == MVT::i1) {
|
||||
// Cast to bool is a comparison against zero, not truncation to zero.
|
||||
SDOperand Zero = isInteger(SrcTy) ? DAG.getConstant(0, N.getValueType()) :
|
||||
DAG.getConstantFP(0.0, N.getValueType());
|
||||
setValue(&I, DAG.getSetCC(ISD::SETNE, MVT::i1, N, Zero));
|
||||
} else if (isInteger(SrcTy)) {
|
||||
if (isInteger(DestTy)) { // Int -> Int cast
|
||||
if (DestTy < SrcTy) // Truncating cast?
|
||||
|
Loading…
Reference in New Issue
Block a user