@@ -124,6 +124,7 @@ class X86FastISel final : public FastISel {
124
124
bool X86SelectSIToFP (const Instruction *I);
125
125
bool X86SelectUIToFP (const Instruction *I);
126
126
bool X86SelectIntToFP (const Instruction *I, bool IsSigned);
127
+ bool X86SelectBitCast (const Instruction *I);
127
128
128
129
const X86InstrInfo *getInstrInfo () const {
129
130
return Subtarget->getInstrInfo ();
@@ -2546,6 +2547,36 @@ bool X86FastISel::X86SelectTrunc(const Instruction *I) {
2546
2547
return true ;
2547
2548
}
2548
2549
2550
+ bool X86FastISel::X86SelectBitCast (const Instruction *I) {
2551
+ // Select SSE2/AVX bitcasts between 128/256/512 bit vector types.
2552
+ MVT SrcVT, DstVT;
2553
+ if (!Subtarget->hasSSE2 () ||
2554
+ !isTypeLegal (I->getOperand (0 )->getType (), SrcVT) ||
2555
+ !isTypeLegal (I->getType (), DstVT))
2556
+ return false ;
2557
+
2558
+ // Only allow vectors that use xmm/ymm/zmm.
2559
+ if (!SrcVT.isVector () || !DstVT.isVector () ||
2560
+ SrcVT.getVectorElementType () == MVT::i1 ||
2561
+ DstVT.getVectorElementType () == MVT::i1)
2562
+ return false ;
2563
+
2564
+ Register Reg = getRegForValue (I->getOperand (0 ));
2565
+ if (!Reg)
2566
+ return false ;
2567
+
2568
+ // Emit a reg-reg copy so we don't propagate cached known bits information
2569
+ // with the wrong VT if we fall out of fast isel after selecting this.
2570
+ const TargetRegisterClass *DstClass = TLI.getRegClassFor (DstVT);
2571
+ Register ResultReg = createResultReg (DstClass);
2572
+ BuildMI (*FuncInfo.MBB , FuncInfo.InsertPt , MIMD, TII.get (TargetOpcode::COPY),
2573
+ ResultReg)
2574
+ .addReg (Reg);
2575
+
2576
+ updateValueMap (I, ResultReg);
2577
+ return true ;
2578
+ }
2579
+
2549
2580
bool X86FastISel::IsMemcpySmall (uint64_t Len) {
2550
2581
return Len <= (Subtarget->is64Bit () ? 32 : 16 );
2551
2582
}
@@ -3693,36 +3724,8 @@ X86FastISel::fastSelectInstruction(const Instruction *I) {
3693
3724
updateValueMap (I, Reg);
3694
3725
return true ;
3695
3726
}
3696
- case Instruction::BitCast: {
3697
- // Select SSE2/AVX bitcasts between 128/256/512 bit vector types.
3698
- if (!Subtarget->hasSSE2 ())
3699
- return false ;
3700
-
3701
- MVT SrcVT, DstVT;
3702
- if (!isTypeLegal (I->getOperand (0 )->getType (), SrcVT) ||
3703
- !isTypeLegal (I->getType (), DstVT))
3704
- return false ;
3705
-
3706
- // Only allow vectors that use xmm/ymm/zmm.
3707
- if (!SrcVT.isVector () || !DstVT.isVector () ||
3708
- SrcVT.getVectorElementType () == MVT::i1 ||
3709
- DstVT.getVectorElementType () == MVT::i1)
3710
- return false ;
3711
-
3712
- Register Reg = getRegForValue (I->getOperand (0 ));
3713
- if (!Reg)
3714
- return false ;
3715
-
3716
- // Emit a reg-reg copy so we don't propagate cached known bits information
3717
- // with the wrong VT if we fall out of fast isel after selecting this.
3718
- const TargetRegisterClass *DstClass = TLI.getRegClassFor (DstVT);
3719
- Register ResultReg = createResultReg (DstClass);
3720
- BuildMI (*FuncInfo.MBB , FuncInfo.InsertPt , MIMD,
3721
- TII.get (TargetOpcode::COPY), ResultReg).addReg (Reg);
3722
-
3723
- updateValueMap (I, ResultReg);
3724
- return true ;
3725
- }
3727
+ case Instruction::BitCast:
3728
+ return X86SelectBitCast (I);
3726
3729
}
3727
3730
3728
3731
return false ;
0 commit comments