[PATCH] D104440: [X86] Fix bug when X86 stackify pass handle one ArgFPRW.

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 20 19:09:52 PDT 2021


craig.topper added a comment.

In D104440#2829512 <https://reviews.llvm.org/D104440#2829512>, @LuoYuanke wrote:

>> Does this fix your test
>>
>>   diff --git a/llvm/lib/Target/X86/X86FastISel.cpp b/llvm/lib/Target/X86/X86FastISel.cpp
>>   index 44670a9..3e5d45b 100644
>>   --- a/llvm/lib/Target/X86/X86FastISel.cpp
>>   +++ b/llvm/lib/Target/X86/X86FastISel.cpp
>>   @@ -3842,6 +3842,30 @@ unsigned X86FastISel::fastMaterializeConstant(const Constant *C) {
>>        return X86MaterializeFP(CFP, VT);
>>      else if (const GlobalValue *GV = dyn_cast<GlobalValue>(C))
>>        return X86MaterializeGV(GV, VT);
>>   +  else if (isa<UndefValue>(C)) {
>>   +    unsigned Opc = 0;
>>   +    switch (VT.SimpleTy) {
>>   +    default:
>>   +      break;
>>   +    case MVT::f32:
>>   +      if (!X86ScalarSSEf32)
>>   +        Opc = X86::LD_Fp032;
>>   +      break;
>>   +    case MVT::f64:
>>   +      if (!X86ScalarSSEf64)
>>   +        Opc = X86::LD_Fp064;
>>   +      break;
>>   +    case MVT::f80:
>>   +      Opc = X86::LD_Fp080;
>>   +      break;
>>   +    }
>>   +
>>   +    if (Opc) {
>>   +      Register ResultReg = createResultReg(TLI.getRegClassFor(VT));
>>   +      BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, TII.get(Opc), ResultReg);
>>   +      return ResultReg;
>>   +    }
>>   +  }
>>    
>>      return 0;
>>    }
>
> Yes. It can fix. Thank you! One question, is there any other consideration to prevent undef float value in MIR? Otherwise stackify pass can support undef value by insert fld0 instruction, so that all ISel passes don't have to handle it specially.

I'm not sure. To do it in the stackifier you need to do it any time the undef flag is present regardless of whether StackTop is 0. You instead would need to check whether the register is already present in the stack and only insert if it isn't. But there may be some complications with removing it from the stack later. I think removing things from the stack is based on kill flags, but I don't know if the undef would have a kill flag. So I guess you'd have to remember you inserted it and immediately remove it after the instruction? You would need to do this for any FP instruction not just ArgFPRW.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104440/new/

https://reviews.llvm.org/D104440



More information about the llvm-commits mailing list