This simplification allows to avoid generating v_cndmask_b32 to serialize condition code between compare and use.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
Why does this need to be a target combine? Can't we use the sub with overflow generic nodes?
Surprisingly ISD::ADDE and ISD::SUBE expect two operands, regardless of what is written in documentation. See for example this pattern with two inputs:
let Uses = [SCC] in { // Carry in comes from SCC let isCommutable = 1 in { def S_ADDC_U32 : SOP2_32 <"s_addc_u32", [(set i32:$sdst, (adde (i32 SSrc_b32:$src0), (i32 SSrc_b32:$src1)))]>; } // End isCommutable = 1
So I did it the same way as ARM.
I meant the other sets of add/sub nodes, like ISD::SADDO. The input is a n allocatable register bool like how the instructions work rather than a flag relying on glue like ADDE
I think the right one is ADDCARRY, SUBCARRY:
The use of this opcode is preferable to adde/sube if the
/// target supports it, as the carry is a regular value rather than a /// glue, which allows further optimisation.
It seems to be so new that I do not even see a def for them in TargTargetSelectionDAG.td. Am I missing something?
It seems to be so new that I do not even see a def for them in TargTargetSelectionDAG.td. Am I missing something?
They do not look like normal nodes. They would require custom select I guess.
Looks like I can base AMDGPUadde and AMDGPUsube on these ISD opcodes instead of AMDGPUISD though. That way we will have selection working.
lib/Target/AMDGPU/AMDGPUInstrInfo.td | ||
---|---|---|
186 | Weird that the td generic nodes don't exist already for this. Looks like this was added only in April, so you should probably add the generic addcarry/subcarry to TargetSelectionDAG.td | |
lib/Target/AMDGPU/SIISelLowering.cpp | ||
473–474 | ADDCARRY/SUBCARRY should be marked as legal so more combines work on them | |
4866 | This is likely any i1 source. We have some other intrinsics that return i1 values, so maybe a todo? |
lib/Target/AMDGPU/AMDGPUInstrInfo.td | ||
---|---|---|
186 | I'm not sure really. The intent is to gradually switch from addc/subc, so probably new td defs were not assumed. | |
lib/Target/AMDGPU/SIISelLowering.cpp | ||
4866 | I have initially tried to use it with just any i1 input. That is worse though. |
lib/Target/AMDGPU/SIISelLowering.cpp | ||
---|---|---|
473–474 | Done, but I do not see any visible difference. |
Weird that the td generic nodes don't exist already for this. Looks like this was added only in April, so you should probably add the generic addcarry/subcarry to TargetSelectionDAG.td