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

Side by Side Diff: src/IceTargetLoweringX86BaseImpl.h

Issue 1407143002: Merge compares and branches (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Created 5 years, 2 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
OLDNEW
1 //===- subzero/src/IceTargetLoweringX86BaseImpl.h - x86 lowering -*- C++ -*-==// 1 //===- subzero/src/IceTargetLoweringX86BaseImpl.h - x86 lowering -*- C++ -*-==//
2 // 2 //
3 // The Subzero Code Generator 3 // The Subzero Code Generator
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 /// \file 10 /// \file
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 template <class MachineTraits> 116 template <class MachineTraits>
117 BoolFoldingEntry<MachineTraits>::BoolFoldingEntry(Inst *I) 117 BoolFoldingEntry<MachineTraits>::BoolFoldingEntry(Inst *I)
118 : Instr(I), IsComplex(BoolFolding<MachineTraits>::hasComplexLowering(I)) {} 118 : Instr(I), IsComplex(BoolFolding<MachineTraits>::hasComplexLowering(I)) {}
119 119
120 template <class MachineTraits> 120 template <class MachineTraits>
121 typename BoolFolding<MachineTraits>::BoolFoldingProducerKind 121 typename BoolFolding<MachineTraits>::BoolFoldingProducerKind
122 BoolFolding<MachineTraits>::getProducerKind(const Inst *Instr) { 122 BoolFolding<MachineTraits>::getProducerKind(const Inst *Instr) {
123 if (llvm::isa<InstIcmp>(Instr)) { 123 if (llvm::isa<InstIcmp>(Instr)) {
124 if (MachineTraits::Is64Bit || Instr->getSrc(0)->getType() != IceType_i64) 124 if (MachineTraits::Is64Bit || Instr->getSrc(0)->getType() != IceType_i64)
125 return PK_Icmp32; 125 return PK_Icmp32;
126 return PK_None; // TODO(stichnot): actually PK_Icmp64; 126 return PK_Icmp64;
127 } 127 }
128 return PK_None; // TODO(stichnot): remove this 128 return PK_None; // TODO(stichnot): remove this
129 129
130 if (llvm::isa<InstFcmp>(Instr)) 130 if (llvm::isa<InstFcmp>(Instr))
131 return PK_Fcmp; 131 return PK_Fcmp;
132 if (auto *Cast = llvm::dyn_cast<InstCast>(Instr)) { 132 if (auto *Cast = llvm::dyn_cast<InstCast>(Instr)) {
133 switch (Cast->getCastKind()) { 133 switch (Cast->getCastKind()) {
134 default: 134 default:
135 return PK_None; 135 return PK_None;
136 case InstCast::Trunc: 136 case InstCast::Trunc:
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 Producers[Var->getIndex()] = BoolFoldingEntry<MachineTraits>(&Instr); 193 Producers[Var->getIndex()] = BoolFoldingEntry<MachineTraits>(&Instr);
194 } 194 }
195 // Check each src variable against the map. 195 // Check each src variable against the map.
196 FOREACH_VAR_IN_INST(Var, Instr) { 196 FOREACH_VAR_IN_INST(Var, Instr) {
197 SizeT VarNum = Var->getIndex(); 197 SizeT VarNum = Var->getIndex();
198 if (containsValid(VarNum)) { 198 if (containsValid(VarNum)) {
199 if (IndexOfVarOperandInInst(Var) != 199 if (IndexOfVarOperandInInst(Var) !=
200 0 // All valid consumers use Var as the first source operand 200 0 // All valid consumers use Var as the first source operand
201 || 201 ||
202 getConsumerKind(&Instr) == CK_None // must be white-listed 202 getConsumerKind(&Instr) == CK_None // must be white-listed
203 ||
204 (getConsumerKind(&Instr) != CK_Br && // Icmp64 only folds in branche s
Jim Stichnoth 2015/10/16 13:58:11 80-col
sehr 2015/10/16 18:10:22 Done.
205 getProducerKind(Producers[VarNum].Instr) != PK_Icmp32)
203 || (Producers[VarNum].IsComplex && // complex can't be multi-use 206 || (Producers[VarNum].IsComplex && // complex can't be multi-use
204 Producers[VarNum].NumUses > 0)) { 207 Producers[VarNum].NumUses > 0)) {
205 setInvalid(VarNum); 208 setInvalid(VarNum);
206 continue; 209 continue;
207 } 210 }
208 ++Producers[VarNum].NumUses; 211 ++Producers[VarNum].NumUses;
209 if (Instr.isLastUse(Var)) { 212 if (Instr.isLastUse(Var)) {
210 Producers[VarNum].IsLiveOut = false; 213 Producers[VarNum].IsLiveOut = false;
211 } 214 }
212 } 215 }
(...skipping 1695 matching lines...) Expand 10 before | Expand all | Expand 10 after
1908 return; 1911 return;
1909 } 1912 }
1910 Operand *Cond = Inst->getCondition(); 1913 Operand *Cond = Inst->getCondition();
1911 1914
1912 // Handle folding opportunities. 1915 // Handle folding opportunities.
1913 if (const class Inst *Producer = FoldingInfo.getProducerFor(Cond)) { 1916 if (const class Inst *Producer = FoldingInfo.getProducerFor(Cond)) {
1914 assert(Producer->isDeleted()); 1917 assert(Producer->isDeleted());
1915 switch (BoolFolding::getProducerKind(Producer)) { 1918 switch (BoolFolding::getProducerKind(Producer)) {
1916 default: 1919 default:
1917 break; 1920 break;
1918 case BoolFolding::PK_Icmp32: { 1921 case BoolFolding::PK_Icmp32:
1919 // TODO(stichnot): Refactor similarities between this block and the 1922 case BoolFolding::PK_Icmp64: {
1920 // corresponding code in lowerIcmp(). 1923 lowerIcmpAndBr(llvm::dyn_cast<InstIcmp>(Producer), Inst);
1921 auto *Cmp = llvm::dyn_cast<InstIcmp>(Producer);
1922 Operand *Src0 = Producer->getSrc(0);
1923 Operand *Src1 = legalize(Producer->getSrc(1));
1924 Operand *Src0RM = legalizeSrc0ForCmp(Src0, Src1);
1925 _cmp(Src0RM, Src1);
1926 _br(Traits::getIcmp32Mapping(Cmp->getCondition()), Inst->getTargetTrue(),
1927 Inst->getTargetFalse());
1928 return; 1924 return;
1929 } 1925 }
1930 } 1926 }
1931 } 1927 }
1932 1928
1933 Operand *Src0 = legalize(Cond, Legal_Reg | Legal_Mem); 1929 Operand *Src0 = legalize(Cond, Legal_Reg | Legal_Mem);
1934 Constant *Zero = Ctx->getConstantZero(IceType_i32); 1930 Constant *Zero = Ctx->getConstantZero(IceType_i32);
1935 _cmp(Src0, Zero); 1931 _cmp(Src0, Zero);
1936 _br(Traits::Cond::Br_ne, Inst->getTargetTrue(), Inst->getTargetFalse()); 1932 _br(Traits::Cond::Br_ne, Inst->getTargetTrue(), Inst->getTargetFalse());
1937 } 1933 }
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after
2651 inline bool isZero(const Operand *Opnd) { 2647 inline bool isZero(const Operand *Opnd) {
2652 if (auto *C64 = llvm::dyn_cast<ConstantInteger64>(Opnd)) 2648 if (auto *C64 = llvm::dyn_cast<ConstantInteger64>(Opnd))
2653 return C64->getValue() == 0; 2649 return C64->getValue() == 0;
2654 if (auto *C32 = llvm::dyn_cast<ConstantInteger32>(Opnd)) 2650 if (auto *C32 = llvm::dyn_cast<ConstantInteger32>(Opnd))
2655 return C32->getValue() == 0; 2651 return C32->getValue() == 0;
2656 return false; 2652 return false;
2657 } 2653 }
2658 2654
2659 template <class Machine> 2655 template <class Machine>
2660 void TargetX86Base<Machine>::lowerIcmp(const InstIcmp *Inst) { 2656 void TargetX86Base<Machine>::lowerIcmp(const InstIcmp *Inst) {
2661 Operand *Src0 = legalize(Inst->getSrc(0)); 2657 lowerIcmpAndBr(Inst, nullptr);
Jim Stichnoth 2015/10/16 13:58:11 Maybe use "constexpr InstBr *Br = nullptr;" for cl
sehr 2015/10/16 18:10:22 Done.
2662 Operand *Src1 = legalize(Inst->getSrc(1)); 2658 }
2663 Variable *Dest = Inst->getDest(); 2659
2660 template <class Machine>
2661 void TargetX86Base<Machine>::lowerIcmpAndBr(const InstIcmp *Icmp,
2662 const InstBr *Br) {
2663 Operand *Src0 = legalize(Icmp->getSrc(0));
2664 Operand *Src1 = legalize(Icmp->getSrc(1));
2665 Variable *Dest = Icmp->getDest();
2664 2666
2665 if (isVectorType(Dest->getType())) { 2667 if (isVectorType(Dest->getType())) {
2668 assert((Br == nullptr) && "not ready to fold vector compare/branch");
Jim Stichnoth 2015/10/16 13:58:11 Make this a report_fatal_error() instead? Also, I
sehr 2015/10/16 18:10:22 Done.
2666 Type Ty = Src0->getType(); 2669 Type Ty = Src0->getType();
2667 // Promote i1 vectors to 128 bit integer vector types. 2670 // Promote i1 vectors to 128 bit integer vector types.
2668 if (typeElementType(Ty) == IceType_i1) { 2671 if (typeElementType(Ty) == IceType_i1) {
2669 Type NewTy = IceType_NUM; 2672 Type NewTy = IceType_NUM;
2670 switch (Ty) { 2673 switch (Ty) {
2671 default: 2674 default:
2672 llvm_unreachable("unexpected type"); 2675 llvm_unreachable("unexpected type");
2673 break; 2676 break;
2674 case IceType_v4i1: 2677 case IceType_v4i1:
2675 NewTy = IceType_v4i32; 2678 NewTy = IceType_v4i32;
2676 break; 2679 break;
2677 case IceType_v8i1: 2680 case IceType_v8i1:
2678 NewTy = IceType_v8i16; 2681 NewTy = IceType_v8i16;
2679 break; 2682 break;
2680 case IceType_v16i1: 2683 case IceType_v16i1:
2681 NewTy = IceType_v16i8; 2684 NewTy = IceType_v16i8;
2682 break; 2685 break;
2683 } 2686 }
2684 Variable *NewSrc0 = Func->makeVariable(NewTy); 2687 Variable *NewSrc0 = Func->makeVariable(NewTy);
2685 Variable *NewSrc1 = Func->makeVariable(NewTy); 2688 Variable *NewSrc1 = Func->makeVariable(NewTy);
2686 lowerCast(InstCast::create(Func, InstCast::Sext, NewSrc0, Src0)); 2689 lowerCast(InstCast::create(Func, InstCast::Sext, NewSrc0, Src0));
2687 lowerCast(InstCast::create(Func, InstCast::Sext, NewSrc1, Src1)); 2690 lowerCast(InstCast::create(Func, InstCast::Sext, NewSrc1, Src1));
2688 Src0 = NewSrc0; 2691 Src0 = NewSrc0;
2689 Src1 = NewSrc1; 2692 Src1 = NewSrc1;
2690 Ty = NewTy; 2693 Ty = NewTy;
2691 } 2694 }
2692 2695
2693 InstIcmp::ICond Condition = Inst->getCondition(); 2696 InstIcmp::ICond Condition = Icmp->getCondition();
2694 2697
2695 Operand *Src0RM = legalize(Src0, Legal_Reg | Legal_Mem); 2698 Operand *Src0RM = legalize(Src0, Legal_Reg | Legal_Mem);
2696 Operand *Src1RM = legalize(Src1, Legal_Reg | Legal_Mem); 2699 Operand *Src1RM = legalize(Src1, Legal_Reg | Legal_Mem);
2697 2700
2698 // SSE2 only has signed comparison operations. Transform unsigned inputs in 2701 // SSE2 only has signed comparison operations. Transform unsigned inputs in
2699 // a manner that allows for the use of signed comparison operations by 2702 // a manner that allows for the use of signed comparison operations by
2700 // flipping the high order bits. 2703 // flipping the high order bits.
2701 if (Condition == InstIcmp::Ugt || Condition == InstIcmp::Uge || 2704 if (Condition == InstIcmp::Ugt || Condition == InstIcmp::Uge ||
2702 Condition == InstIcmp::Ult || Condition == InstIcmp::Ule) { 2705 Condition == InstIcmp::Ult || Condition == InstIcmp::Ule) {
2703 Variable *T0 = makeReg(Ty); 2706 Variable *T0 = makeReg(Ty);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
2765 _pxor(T, MinusOne); 2768 _pxor(T, MinusOne);
2766 } break; 2769 } break;
2767 } 2770 }
2768 2771
2769 _movp(Dest, T); 2772 _movp(Dest, T);
2770 eliminateNextVectorSextInstruction(Dest); 2773 eliminateNextVectorSextInstruction(Dest);
2771 return; 2774 return;
2772 } 2775 }
2773 2776
2774 if (!Traits::Is64Bit && Src0->getType() == IceType_i64) { 2777 if (!Traits::Is64Bit && Src0->getType() == IceType_i64) {
2775 lowerIcmp64(Inst); 2778 lowerIcmp64(Icmp, Br);
2776 return; 2779 return;
2777 } 2780 }
2778 2781
2779 // cmp b, c 2782 // cmp b, c
2780 if (isZero(Src1)) { 2783 if (isZero(Src1)) {
2781 switch (Inst->getCondition()) { 2784 switch (Icmp->getCondition()) {
2782 default: 2785 default:
2783 break; 2786 break;
2784 case InstIcmp::Uge: 2787 case InstIcmp::Uge:
2785 _mov(Dest, Ctx->getConstantInt(Dest->getType(), 1)); 2788 movOrBr(true, Dest, Br);
2786 return; 2789 return;
2787 case InstIcmp::Ult: 2790 case InstIcmp::Ult:
2788 _mov(Dest, Ctx->getConstantInt(Dest->getType(), 0)); 2791 movOrBr(false, Dest, Br);
2789 return; 2792 return;
2790 } 2793 }
2791 } 2794 }
2792 Operand *Src0RM = legalizeSrc0ForCmp(Src0, Src1); 2795 Operand *Src0RM = legalizeSrc0ForCmp(Src0, Src1);
2793 _cmp(Src0RM, Src1); 2796 _cmp(Src0RM, Src1);
2794 _setcc(Dest, Traits::getIcmp32Mapping(Inst->getCondition())); 2797 setccOrBr(Traits::getIcmp32Mapping(Icmp->getCondition()), Dest, Br);
2795 } 2798 }
2796 2799
2797 template <typename Machine> 2800 template <typename Machine>
2798 template <typename T> 2801 template <typename T>
2799 typename std::enable_if<!T::Is64Bit, void>::type 2802 typename std::enable_if<!T::Is64Bit, void>::type
2800 TargetX86Base<Machine>::lowerIcmp64(const InstIcmp *Inst) { 2803 TargetX86Base<Machine>::lowerIcmp64(const InstIcmp *Icmp, const InstBr *Br) {
2801 // a=icmp cond, b, c ==> cmp b,c; a=1; br cond,L1; FakeUse(a); a=0; L1: 2804 // a=icmp cond, b, c ==> cmp b,c; a=1; br cond,L1; FakeUse(a); a=0; L1:
2802 Operand *Src0 = legalize(Inst->getSrc(0)); 2805 Operand *Src0 = legalize(Icmp->getSrc(0));
2803 Operand *Src1 = legalize(Inst->getSrc(1)); 2806 Operand *Src1 = legalize(Icmp->getSrc(1));
2804 Variable *Dest = Inst->getDest(); 2807 Variable *Dest = Icmp->getDest();
2805 InstIcmp::ICond Condition = Inst->getCondition(); 2808 InstIcmp::ICond Condition = Icmp->getCondition();
2806 size_t Index = static_cast<size_t>(Condition); 2809 size_t Index = static_cast<size_t>(Condition);
2807 assert(Index < Traits::TableIcmp64Size); 2810 assert(Index < Traits::TableIcmp64Size);
2808 Constant *Zero = Ctx->getConstantZero(IceType_i32); 2811 Constant *Zero = Ctx->getConstantZero(IceType_i32);
2809 Constant *One = Ctx->getConstantInt32(1); 2812 Constant *One = Ctx->getConstantInt32(1);
2810 Operand *Src0LoRM = nullptr; 2813 Operand *Src0LoRM = nullptr;
2811 Operand *Src0HiRM = nullptr; 2814 Operand *Src0HiRM = nullptr;
2812 // Legalize the portions of Src0 that are going to be needed. 2815 // Legalize the portions of Src0 that are going to be needed.
2813 if (isZero(Src1)) { 2816 if (isZero(Src1)) {
2814 switch (Condition) { 2817 switch (Condition) {
2815 default: 2818 default:
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
2848 Variable *Temp = nullptr; 2851 Variable *Temp = nullptr;
2849 switch (Condition) { 2852 switch (Condition) {
2850 default: 2853 default:
2851 llvm_unreachable("unexpected condition"); 2854 llvm_unreachable("unexpected condition");
2852 break; 2855 break;
2853 case InstIcmp::Eq: 2856 case InstIcmp::Eq:
2854 case InstIcmp::Ule: 2857 case InstIcmp::Ule:
2855 _mov(Temp, Src0LoRM); 2858 _mov(Temp, Src0LoRM);
2856 _or(Temp, Src0HiRM); 2859 _or(Temp, Src0HiRM);
2857 Context.insert(InstFakeUse::create(Func, Temp)); 2860 Context.insert(InstFakeUse::create(Func, Temp));
2858 _setcc(Dest, Traits::Cond::Br_e); 2861 setccOrBr(Traits::Cond::Br_e, Dest, Br);
2859 return; 2862 return;
2860 case InstIcmp::Ne: 2863 case InstIcmp::Ne:
2861 case InstIcmp::Ugt: 2864 case InstIcmp::Ugt:
2862 _mov(Temp, Src0LoRM); 2865 _mov(Temp, Src0LoRM);
2863 _or(Temp, Src0HiRM); 2866 _or(Temp, Src0HiRM);
2864 Context.insert(InstFakeUse::create(Func, Temp)); 2867 Context.insert(InstFakeUse::create(Func, Temp));
2865 _setcc(Dest, Traits::Cond::Br_ne); 2868 setccOrBr(Traits::Cond::Br_ne, Dest, Br);
2866 return; 2869 return;
2867 case InstIcmp::Uge: 2870 case InstIcmp::Uge:
2868 _mov(Dest, Ctx->getConstantInt(Dest->getType(), 1)); 2871 movOrBr(true, Dest, Br);
2869 return; 2872 return;
2870 case InstIcmp::Ult: 2873 case InstIcmp::Ult:
2871 _mov(Dest, Ctx->getConstantInt(Dest->getType(), 0)); 2874 movOrBr(false, Dest, Br);
2872 return; 2875 return;
2873 case InstIcmp::Sgt: 2876 case InstIcmp::Sgt:
2874 break; 2877 break;
2875 case InstIcmp::Sge: 2878 case InstIcmp::Sge:
2876 _test(Src0HiRM, SignMask); 2879 _test(Src0HiRM, SignMask);
2877 _setcc(Dest, Traits::Cond::Br_e); 2880 setccOrBr(Traits::Cond::Br_e, Dest, Br);
2878 return; 2881 return;
2879 case InstIcmp::Slt: 2882 case InstIcmp::Slt:
2880 _test(Src0HiRM, SignMask); 2883 _test(Src0HiRM, SignMask);
2881 _setcc(Dest, Traits::Cond::Br_ne); 2884 setccOrBr(Traits::Cond::Br_ne, Dest, Br);
2882 return; 2885 return;
2883 case InstIcmp::Sle: 2886 case InstIcmp::Sle:
2884 break; 2887 break;
2885 } 2888 }
2886 } 2889 }
2887 // Handle general compares. 2890 // Handle general compares.
2888 Operand *Src1LoRI = legalize(loOperand(Src1), Legal_Reg | Legal_Imm); 2891 Operand *Src1LoRI = legalize(loOperand(Src1), Legal_Reg | Legal_Imm);
2889 Operand *Src1HiRI = legalize(hiOperand(Src1), Legal_Reg | Legal_Imm); 2892 Operand *Src1HiRI = legalize(hiOperand(Src1), Legal_Reg | Legal_Imm);
2890 typename Traits::Insts::Label *LabelFalse = 2893 if (Br == nullptr) {
2891 Traits::Insts::Label::create(Func, this); 2894 typename Traits::Insts::Label *LabelFalse =
2892 typename Traits::Insts::Label *LabelTrue = 2895 Traits::Insts::Label::create(Func, this);
2893 Traits::Insts::Label::create(Func, this); 2896 typename Traits::Insts::Label *LabelTrue =
2894 _mov(Dest, One); 2897 Traits::Insts::Label::create(Func, this);
2895 _cmp(Src0HiRM, Src1HiRI); 2898 _mov(Dest, One);
2896 if (Traits::TableIcmp64[Index].C1 != Traits::Cond::Br_None) 2899 _cmp(Src0HiRM, Src1HiRI);
2897 _br(Traits::TableIcmp64[Index].C1, LabelTrue); 2900 if (Traits::TableIcmp64[Index].C1 != Traits::Cond::Br_None)
2898 if (Traits::TableIcmp64[Index].C2 != Traits::Cond::Br_None) 2901 _br(Traits::TableIcmp64[Index].C1, LabelTrue);
2899 _br(Traits::TableIcmp64[Index].C2, LabelFalse); 2902 if (Traits::TableIcmp64[Index].C2 != Traits::Cond::Br_None)
2900 _cmp(Src0LoRM, Src1LoRI); 2903 _br(Traits::TableIcmp64[Index].C2, LabelFalse);
2901 _br(Traits::TableIcmp64[Index].C3, LabelTrue); 2904 _cmp(Src0LoRM, Src1LoRI);
2902 Context.insert(LabelFalse); 2905 _br(Traits::TableIcmp64[Index].C3, LabelTrue);
2903 _mov_redefined(Dest, Zero); 2906 Context.insert(LabelFalse);
2904 Context.insert(LabelTrue); 2907 _mov_redefined(Dest, Zero);
2908 Context.insert(LabelTrue);
2909 } else {
2910 _cmp(Src0HiRM, Src1HiRI);
2911 if (Traits::TableIcmp64[Index].C1 != Traits::Cond::Br_None)
2912 _br(Traits::TableIcmp64[Index].C1, Br->getTargetTrue());
2913 if (Traits::TableIcmp64[Index].C2 != Traits::Cond::Br_None)
2914 _br(Traits::TableIcmp64[Index].C2, Br->getTargetFalse());
2915 _cmp(Src0LoRM, Src1LoRI);
2916 _br(Traits::TableIcmp64[Index].C3, Br->getTargetTrue(), Br->getTargetFalse() );
Jim Stichnoth 2015/10/16 13:58:11 80-col
sehr 2015/10/16 18:10:22 Done.
2917 }
2905 } 2918 }
2906 2919
2907 template <class Machine> 2920 template <class Machine>
2921 void TargetX86Base<Machine>::setccOrBr(typename Traits::Cond::BrCond Condition,
2922 Variable *Dest, const InstBr *Br) {
2923 if (Br == nullptr) {
2924 _setcc(Dest, Condition);
2925 } else {
2926 _br(Condition, Br->getTargetTrue(), Br->getTargetFalse());
2927 }
2928 }
2929
2930 template <class Machine>
2931 void TargetX86Base<Machine>::movOrBr(bool IcmpResult, Variable *Dest,
2932 const InstBr *Br) {
2933 if (Br == nullptr) {
2934 _mov(Dest, Ctx->getConstantInt(Dest->getType(), (IcmpResult ? 1 : 0)));
2935 } else {
2936 // TODO(sehr,stichnot): This could be done with a single unconditional
2937 // branch instruction, but subzero doesn't know how to handle the resulting
2938 // control flow graph changes now. Make it do so to eliminate mov and cmp.
2939 _mov(Dest, Ctx->getConstantInt(Dest->getType(), (IcmpResult ? 1 : 0)));
2940 _cmp(Dest, Ctx->getConstantInt(Dest->getType(), 0));
2941 _br(Traits::Cond::Br_ne, Br->getTargetTrue(), Br->getTargetFalse());
2942 }
2943 }
2944
2945 template <class Machine>
2908 void TargetX86Base<Machine>::lowerInsertElement(const InstInsertElement *Inst) { 2946 void TargetX86Base<Machine>::lowerInsertElement(const InstInsertElement *Inst) {
2909 Operand *SourceVectNotLegalized = Inst->getSrc(0); 2947 Operand *SourceVectNotLegalized = Inst->getSrc(0);
2910 Operand *ElementToInsertNotLegalized = Inst->getSrc(1); 2948 Operand *ElementToInsertNotLegalized = Inst->getSrc(1);
2911 ConstantInteger32 *ElementIndex = 2949 ConstantInteger32 *ElementIndex =
2912 llvm::dyn_cast<ConstantInteger32>(Inst->getSrc(2)); 2950 llvm::dyn_cast<ConstantInteger32>(Inst->getSrc(2));
2913 // Only constant indices are allowed in PNaCl IR. 2951 // Only constant indices are allowed in PNaCl IR.
2914 assert(ElementIndex); 2952 assert(ElementIndex);
2915 unsigned Index = ElementIndex->getValue(); 2953 unsigned Index = ElementIndex->getValue();
2916 assert(Index < typeNumElements(SourceVectNotLegalized->getType())); 2954 assert(Index < typeNumElements(SourceVectNotLegalized->getType()));
2917 2955
(...skipping 2687 matching lines...) Expand 10 before | Expand all | Expand 10 after
5605 } 5643 }
5606 // the offset is not eligible for blinding or pooling, return the original 5644 // the offset is not eligible for blinding or pooling, return the original
5607 // mem operand 5645 // mem operand
5608 return MemOperand; 5646 return MemOperand;
5609 } 5647 }
5610 5648
5611 } // end of namespace X86Internal 5649 } // end of namespace X86Internal
5612 } // end of namespace Ice 5650 } // end of namespace Ice
5613 5651
5614 #endif // SUBZERO_SRC_ICETARGETLOWERINGX86BASEIMPL_H 5652 #endif // SUBZERO_SRC_ICETARGETLOWERINGX86BASEIMPL_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698