[llvm-dev] Help request: Output reshuffling

Dr. ÉRDI Gergő via llvm-dev llvm-dev at lists.llvm.org
Sat Jul 15 00:36:11 PDT 2017


Hi,

I'm still completely stuck on this one. To recap, during instruction
selection, I'm trying to use something of type (i16, i16, ch) as the
selection for an instruction which has type (i16, ch) by not using the
second i16 returned. Using getMergeValues I created something that almost
looks right, but fails scheduling; my suspicion is that it doesn't tunnel
the ch result through properly.

On Tue, Jun 6, 2017 at 11:46 PM, Dr. ERDI Gergo <gergo at erdi.hu> wrote:

> On Sun, 4 Jun 2017, Dr. ERDI Gergo wrote:
>
> OK I managed to make some progress on this, by using a MergeValues node:
>>
>>      SDNode* LDW = CurDAG->getMachineNode(
>>        AVR::LDWRdPtr, SDLoc(N), VT, PtrVT, MVT::Other,
>>        LD->getBasePtr(), LD->getChain());
>>      SDValue Unpack[] = { SDValue(LDW, 0), SDValue(LDW, 2) };
>>      SDNode* NN = CurDAG->getMergeValues(Unpack, SDLoc(N)).getNode();
>>
>>      ReplaceNode(N, NN);
>>
>>
>> which gets me from
>>
>>  t17: i16,ch = load<LD2[%v25](align=1)(dereferenceable)> t16:1, t2,
>> undef:i16
>>
>> to
>>
>>  t24: i16,i16,ch = LDWRdPtr t2, t16:1
>>
>> looking tood; but then it fails during scheduling with
>>
>> llc: CodeGen/SelectionDAG/InstrEmitter.cpp:303: unsigned int
>> llvm::InstrEmitter::getVR(
>>    llvm::SDValue,
>>    llvm::DenseMap<llvm::SDValue, unsigned int>&):
>> Assertion `I != VRBaseMap.end() && "Node emitted out of order - late"'
>> failed.
>>
>
> Looking at the result of selection again, I now noticed that here:
>
> t26: i16,i16,ch = LDWRdPtr t2, t0
> t27: i16,ch = merge_values t26, t26:2
>
> I'm not sure what that t26:2 means, and why it's not
>
> t27: i16,ch = merge_values t26, ch
>
> Could that be a hint to what's going wrong?
>
>
>
>> For reference, the full DAG before and after ISEL:
>>
>>
>> SelectionDAG has 22 nodes:
>>  t0: ch = EntryToken
>>  t2: i16,ch = CopyFromReg t0, Register:i16 %vreg0
>>  t5: i16,ch = load<LD2[%v25](align=1)(dereferenceable)> t0, t2, undef:i16
>>    t9: ch,glue = callseq_start t5:1, TargetConstant:i16<0>
>>  t11: ch,glue = CopyToReg t9, Register:i16 %R25R24, t5
>>  t13: ch,glue = CALL t11, TargetGlobalAddress:i16<i8 (i16)* @read_ram> 0,
>> Register:i16 %R25R24, RegisterMask:Untyped, t11:1
>>  t14: ch,glue = callseq_end t13, TargetConstant:i16<0>,
>> TargetConstant:i16<0>, t13:1
>>    t16: i8,ch,glue = CopyFromReg t14, Register:i8 %R24, t14:1
>>  t17: i16,ch = load<LD2[%v25](align=1)(dereferenceable)> t16:1, t2,
>> undef:i16
>>    t18: ch,glue = callseq_start t17:1, TargetConstant:i16<0>
>>  t19: ch,glue = CopyToReg t18, Register:i16 %R25R24, t17
>>  t20: ch,glue = CALL t19, TargetGlobalAddress:i16<i8 (i16)* @read_ram> 0,
>> Register:i16 %R25R24, RegisterMask:Untyped, t19:1
>>  t21: ch,glue = callseq_end t20, TargetConstant:i16<0>,
>> TargetConstant:i16<0>, t20:1
>>    t22: i8,ch,glue = CopyFromReg t21, Register:i8 %R24, t21:1
>>  t23: ch = RET_FLAG t22:1
>>
>>
>>
>> SelectionDAG has 23 nodes:
>>  t0: ch = EntryToken
>>  t2: i16,ch = CopyFromReg t0, Register:i16 %vreg0
>>    t9: i16,ch,glue = ADJCALLSTACKDOWN TargetConstant:i16<0>, t27:1
>>  t11: ch,glue = CopyToReg t9:1, Register:i16 %R25R24, t27
>>  t13: ch,glue = CALLk TargetGlobalAddress:i16<i8 (i16)* @read_ram> 0,
>> Register:i16 %R25R24, RegisterMask:Untyped, t11, t11:1
>>  t14: i16,ch,glue = ADJCALLSTACKUP TargetConstant:i16<0>,
>> TargetConstant:i16<0>, t13, t13:1
>>    t18: i16,ch,glue = ADJCALLSTACKDOWN TargetConstant:i16<0>, t25:1
>>  t19: ch,glue = CopyToReg t18:1, Register:i16 %R25R24, t25
>>  t20: ch,glue = CALLk TargetGlobalAddress:i16<i8 (i16)* @read_ram> 0,
>> Register:i16 %R25R24, RegisterMask:Untyped, t19, t19:1
>>  t21: i16,ch,glue = ADJCALLSTACKUP TargetConstant:i16<0>,
>> TargetConstant:i16<0>, t20, t20:1
>>    t16: i8,ch,glue = CopyFromReg t14:1, Register:i8 %R24, t14:2
>>  t24: i16,i16,ch = LDWRdPtr t2, t16:1
>>  t25: i16,ch = merge_values t24, t24:2
>>  t26: i16,i16,ch = LDWRdPtr t2, t0
>>  t27: i16,ch = merge_values t26, t26:2
>>    t22: i8,ch,glue = CopyFromReg t21:1, Register:i8 %R24, t21:2
>>  t23: ch = RET t22:1
>>
>>
>>
> --
>
>   .--= ULLA! =-----------------.
>    \     http://gergo.erdi.hu   \
>     `---= gergo at erdi.hu =-------'
> Why is it called tourist season if we can't shoot at them?
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170715/b5747961/attachment.html>


More information about the llvm-dev mailing list