Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(348)

Side by Side Diff: lib/Target/X86/X86ISelLowering.cpp

Issue 183273009: Prep for merging 3.4: Undo changes from 3.3 branch (Closed) Base URL: http://git.chromium.org/native_client/pnacl-llvm.git@master
Patch Set: Retry Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « lib/Target/X86/X86FrameLowering.cpp ('k') | lib/Target/X86/X86Subtarget.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===-- X86ISelLowering.cpp - X86 DAG Lowering Implementation -------------===// 1 //===-- X86ISelLowering.cpp - X86 DAG Lowering Implementation -------------===//
2 // 2 //
3 // The LLVM Compiler Infrastructure 3 // The LLVM Compiler Infrastructure
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 // 9 //
10 // This file defines the interfaces that X86 uses to lower LLVM code into a 10 // This file defines the interfaces that X86 uses to lower LLVM code into a
(...skipping 9430 matching lines...) Expand 10 before | Expand all | Expand 10 after
9441 case ISD::SETGE: Swap = true; 9441 case ISD::SETGE: Swap = true;
9442 case ISD::SETLE: Opc = X86ISD::PCMPGT; Invert = true; break; 9442 case ISD::SETLE: Opc = X86ISD::PCMPGT; Invert = true; break;
9443 case ISD::SETULT: Swap = true; 9443 case ISD::SETULT: Swap = true;
9444 case ISD::SETUGT: Opc = X86ISD::PCMPGT; FlipSigns = true; break; 9444 case ISD::SETUGT: Opc = X86ISD::PCMPGT; FlipSigns = true; break;
9445 case ISD::SETUGE: Swap = true; 9445 case ISD::SETUGE: Swap = true;
9446 case ISD::SETULE: Opc = X86ISD::PCMPGT; FlipSigns = true; Invert = true; break ; 9446 case ISD::SETULE: Opc = X86ISD::PCMPGT; FlipSigns = true; Invert = true; break ;
9447 } 9447 }
9448 if (Swap) 9448 if (Swap)
9449 std::swap(Op0, Op1); 9449 std::swap(Op0, Op1);
9450 9450
9451 // Since SSE has no unsigned integer comparisons, we need to flip the sign
9452 // bits of the inputs before performing those operations.
9453 if (FlipSigns) {
9454 EVT EltVT = VT.getVectorElementType();
9455 SDValue SignBit = DAG.getConstant(APInt::getSignBit(EltVT.getSizeInBits()),
9456 EltVT);
9457 std::vector<SDValue> SignBits(VT.getVectorNumElements(), SignBit);
9458 SDValue SignVec = DAG.getNode(ISD::BUILD_VECTOR, dl, VT, &SignBits[0],
9459 SignBits.size());
9460 Op0 = DAG.getNode(ISD::XOR, dl, VT, Op0, SignVec);
9461 Op1 = DAG.getNode(ISD::XOR, dl, VT, Op1, SignVec);
9462 }
9463
9451 // Check that the operation in question is available (most are plain SSE2, 9464 // Check that the operation in question is available (most are plain SSE2,
9452 // but PCMPGTQ and PCMPEQQ have different requirements). 9465 // but PCMPGTQ and PCMPEQQ have different requirements).
9453 if (VT == MVT::v2i64) { 9466 if (VT == MVT::v2i64) {
9454 if (Opc == X86ISD::PCMPGT && !Subtarget->hasSSE42()) { 9467 if (Opc == X86ISD::PCMPGT && !Subtarget->hasSSE42()) {
9455 assert(Subtarget->hasSSE2() && "Don't know how to lower!"); 9468 assert(Subtarget->hasSSE2() && "Don't know how to lower!");
9456 9469
9457 // First cast everything to the right type. 9470 // First cast everything to the right type,
9458 Op0 = DAG.getNode(ISD::BITCAST, dl, MVT::v4i32, Op0); 9471 Op0 = DAG.getNode(ISD::BITCAST, dl, MVT::v4i32, Op0);
9459 Op1 = DAG.getNode(ISD::BITCAST, dl, MVT::v4i32, Op1); 9472 Op1 = DAG.getNode(ISD::BITCAST, dl, MVT::v4i32, Op1);
9460 9473
9461 // Since SSE has no unsigned integer comparisons, we need to flip the sign
9462 // bits of the inputs before performing those operations. The lower
9463 // compare is always unsigned.
9464 SDValue SB;
9465 if (FlipSigns) {
9466 SB = DAG.getConstant(0x80000000U, MVT::v4i32);
9467 } else {
9468 SDValue Sign = DAG.getConstant(0x80000000U, MVT::i32);
9469 SDValue Zero = DAG.getConstant(0x00000000U, MVT::i32);
9470 SB = DAG.getNode(ISD::BUILD_VECTOR, dl, MVT::v4i32,
9471 Sign, Zero, Sign, Zero);
9472 }
9473 Op0 = DAG.getNode(ISD::XOR, dl, MVT::v4i32, Op0, SB);
9474 Op1 = DAG.getNode(ISD::XOR, dl, MVT::v4i32, Op1, SB);
9475
9476 // Emulate PCMPGTQ with (hi1 > hi2) | ((hi1 == hi2) & (lo1 > lo2)) 9474 // Emulate PCMPGTQ with (hi1 > hi2) | ((hi1 == hi2) & (lo1 > lo2))
9477 SDValue GT = DAG.getNode(X86ISD::PCMPGT, dl, MVT::v4i32, Op0, Op1); 9475 SDValue GT = DAG.getNode(X86ISD::PCMPGT, dl, MVT::v4i32, Op0, Op1);
9478 SDValue EQ = DAG.getNode(X86ISD::PCMPEQ, dl, MVT::v4i32, Op0, Op1); 9476 SDValue EQ = DAG.getNode(X86ISD::PCMPEQ, dl, MVT::v4i32, Op0, Op1);
9479 9477
9480 // Create masks for only the low parts/high parts of the 64 bit integers. 9478 // Create masks for only the low parts/high parts of the 64 bit integers.
9481 const int MaskHi[] = { 1, 1, 3, 3 }; 9479 const int MaskHi[] = { 1, 1, 3, 3 };
9482 const int MaskLo[] = { 0, 0, 2, 2 }; 9480 const int MaskLo[] = { 0, 0, 2, 2 };
9483 SDValue EQHi = DAG.getVectorShuffle(MVT::v4i32, dl, EQ, EQ, MaskHi); 9481 SDValue EQHi = DAG.getVectorShuffle(MVT::v4i32, dl, EQ, EQ, MaskHi);
9484 SDValue GTLo = DAG.getVectorShuffle(MVT::v4i32, dl, GT, GT, MaskLo); 9482 SDValue GTLo = DAG.getVectorShuffle(MVT::v4i32, dl, GT, GT, MaskLo);
9485 SDValue GTHi = DAG.getVectorShuffle(MVT::v4i32, dl, GT, GT, MaskHi); 9483 SDValue GTHi = DAG.getVectorShuffle(MVT::v4i32, dl, GT, GT, MaskHi);
9486 9484
9487 SDValue Result = DAG.getNode(ISD::AND, dl, MVT::v4i32, EQHi, GTLo); 9485 SDValue Result = DAG.getNode(ISD::AND, dl, MVT::v4i32, EQHi, GTLo);
9488 Result = DAG.getNode(ISD::OR, dl, MVT::v4i32, Result, GTHi); 9486 Result = DAG.getNode(ISD::OR, dl, MVT::v4i32, Result, GTHi);
9489 9487
9490 if (Invert) 9488 if (Invert)
9491 Result = DAG.getNOT(dl, Result, MVT::v4i32); 9489 Result = DAG.getNOT(dl, Result, MVT::v4i32);
9492 9490
9493 return DAG.getNode(ISD::BITCAST, dl, VT, Result); 9491 return DAG.getNode(ISD::BITCAST, dl, VT, Result);
9494 } 9492 }
9495 9493
9496 if (Opc == X86ISD::PCMPEQ && !Subtarget->hasSSE41()) { 9494 if (Opc == X86ISD::PCMPEQ && !Subtarget->hasSSE41()) {
9497 // If pcmpeqq is missing but pcmpeqd is available synthesize pcmpeqq with 9495 // If pcmpeqq is missing but pcmpeqd is available synthesize pcmpeqq with
9498 // pcmpeqd + pshufd + pand. 9496 // pcmpeqd + pshufd + pand.
9499 assert(Subtarget->hasSSE2() && !FlipSigns && "Don't know how to lower!"); 9497 assert(Subtarget->hasSSE2() && !FlipSigns && "Don't know how to lower!");
9500 9498
9501 // First cast everything to the right type. 9499 // First cast everything to the right type,
9502 Op0 = DAG.getNode(ISD::BITCAST, dl, MVT::v4i32, Op0); 9500 Op0 = DAG.getNode(ISD::BITCAST, dl, MVT::v4i32, Op0);
9503 Op1 = DAG.getNode(ISD::BITCAST, dl, MVT::v4i32, Op1); 9501 Op1 = DAG.getNode(ISD::BITCAST, dl, MVT::v4i32, Op1);
9504 9502
9505 // Do the compare. 9503 // Do the compare.
9506 SDValue Result = DAG.getNode(Opc, dl, MVT::v4i32, Op0, Op1); 9504 SDValue Result = DAG.getNode(Opc, dl, MVT::v4i32, Op0, Op1);
9507 9505
9508 // Make sure the lower and upper halves are both all-ones. 9506 // Make sure the lower and upper halves are both all-ones.
9509 const int Mask[] = { 1, 0, 3, 2 }; 9507 const int Mask[] = { 1, 0, 3, 2 };
9510 SDValue Shuf = DAG.getVectorShuffle(MVT::v4i32, dl, Result, Result, Mask); 9508 SDValue Shuf = DAG.getVectorShuffle(MVT::v4i32, dl, Result, Result, Mask);
9511 Result = DAG.getNode(ISD::AND, dl, MVT::v4i32, Result, Shuf); 9509 Result = DAG.getNode(ISD::AND, dl, MVT::v4i32, Result, Shuf);
9512 9510
9513 if (Invert) 9511 if (Invert)
9514 Result = DAG.getNOT(dl, Result, MVT::v4i32); 9512 Result = DAG.getNOT(dl, Result, MVT::v4i32);
9515 9513
9516 return DAG.getNode(ISD::BITCAST, dl, VT, Result); 9514 return DAG.getNode(ISD::BITCAST, dl, VT, Result);
9517 } 9515 }
9518 } 9516 }
9519 9517
9520 // Since SSE has no unsigned integer comparisons, we need to flip the sign
9521 // bits of the inputs before performing those operations.
9522 if (FlipSigns) {
9523 EVT EltVT = VT.getVectorElementType();
9524 SDValue SB = DAG.getConstant(APInt::getSignBit(EltVT.getSizeInBits()), VT);
9525 Op0 = DAG.getNode(ISD::XOR, dl, VT, Op0, SB);
9526 Op1 = DAG.getNode(ISD::XOR, dl, VT, Op1, SB);
9527 }
9528
9529 SDValue Result = DAG.getNode(Opc, dl, VT, Op0, Op1); 9518 SDValue Result = DAG.getNode(Opc, dl, VT, Op0, Op1);
9530 9519
9531 // If the logical-not of the result is required, perform that now. 9520 // If the logical-not of the result is required, perform that now.
9532 if (Invert) 9521 if (Invert)
9533 Result = DAG.getNOT(dl, Result, VT); 9522 Result = DAG.getNOT(dl, Result, VT);
9534 9523
9535 return Result; 9524 return Result;
9536 } 9525 }
9537 9526
9538 SDValue X86TargetLowering::LowerSETCC(SDValue Op, SelectionDAG &DAG) const { 9527 SDValue X86TargetLowering::LowerSETCC(SDValue Op, SelectionDAG &DAG) const {
(...skipping 9273 matching lines...) Expand 10 before | Expand all | Expand 10 after
18812 else if (VT == MVT::f64 || VT == MVT::i64) 18801 else if (VT == MVT::f64 || VT == MVT::i64)
18813 Res.second = &X86::FR64RegClass; 18802 Res.second = &X86::FR64RegClass;
18814 else if (X86::VR128RegClass.hasType(VT)) 18803 else if (X86::VR128RegClass.hasType(VT))
18815 Res.second = &X86::VR128RegClass; 18804 Res.second = &X86::VR128RegClass;
18816 else if (X86::VR256RegClass.hasType(VT)) 18805 else if (X86::VR256RegClass.hasType(VT))
18817 Res.second = &X86::VR256RegClass; 18806 Res.second = &X86::VR256RegClass;
18818 } 18807 }
18819 18808
18820 return Res; 18809 return Res;
18821 } 18810 }
OLDNEW
« no previous file with comments | « lib/Target/X86/X86FrameLowering.cpp ('k') | lib/Target/X86/X86Subtarget.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698