What I didn't mention in r192119 is that mthi/lo clobbers the other sub-register only if the contents of hi and lo are produced by mult or other arithmetic instructions (div, madd, etc.) It doesn't have this side-effect if it is produced by another mthi/lo. So I don't think making mthi/lo clobber the other half would work.
For example, this is an illegal sequence of instructions, where instruction 3 makes $hi unpredictable:1. mult $lo<def>, $hi<def>, $2, $3 // $lo<def>, $hi<def> = $2 * $32. mflo $4, $lo<use> // $4 <- $lo3. mtlo $lo<def>, $6 // $lo <- $6. effectively clobbers $hi too.4. mfhi $5, $hi<use> // $5 <- $hi5. mthi $hi<def>, $7 // $hi <- $76. madd $lo<def>, $hi<def>, $8, $9, $lo<use>, $hi<use> // $lo<def>, $hi<def> = $2 * $3 + (lo,hi)Unlike the mtlo instruction in the example above, instruction 5 in the next example does not clobber $hi:1. mult $lo<def>, $hi<def>, $2, $3 // $lo<def>, $hi<def> = $2 * $32. mflo $4, $lo<use> // $4 <- $lo3. mfhi $5, $hi<use> // $5 <- $hi
4. mthi $hi<def>, $7 // $hi <- $7.5. mtlo $lo<def>, $6 // $lo <- $6. This does not clobber $hi.6. madd $lo<def>, $hi<def>, $8, $9, $lo<use>, $hi<use> // $lo<def>, $hi<def> = $2 * $3 + (lo,hi)Probably I can define a pseudo instruction "mthilo" that defines both lo and hi and expands to mthi and mtlo after register allocation, which will force register allocator to spill/restore the whole register in most cases (the only exception I can think of is the inline-assembly constraint 'l' for 'lo' register).
"These are the remaining steps to get Matthias' subregister liveness fully integrated: - Fix LiveRegUnits to correctly handle regmasks. - Benchmark/tune compile time. - Enable subreg liveness on x86 for testing purposes. - Use LiveRegUnits to fix ARM VMOV widening. - Fix the scheduler's DAG builder to use bundler iterator, not operand index. - Discard the master live range after coalescing so that LiveInterval updates don't need to preserve it when we reorder subregister defs. - Enable subreg scheduling on all targets that enable MI scheduler."
On Jul 19, 2016, at 1:11 PM, Sergey Yakoushkin <sergey.y...@gmail.com> wrote:Hi Matthias,Thanks for quick reply. I have few questions about sub-register support.I'm currently using LLVM 3.8. Could you send links to recent patches/reviews?
1) Does LLVM maintain sub-register liveness while splitting live intervals?
2) How sub-register kill/dead flags and BB liveins should look after regalloc?
E.g. target has instructions both for sub-registers and registers.Composite 64b reg contains 2x32b regs: Rxy = { Rx, Ry }. and scalar/vector add/ld/etc.LiveRangeCalc::findReachingDefs expects to see all sub-registers in BB liveins together with pair registers.BB1:Rxy<def> = ...BB2: LiveIn: Rxy and Rx ?
... = ADD Rx<use>... = VADD Rxy<use>00284 if (TargetRegisterInfo::isPhysicalRegister(PhysReg) && 00285 !MBB->isLiveIn(PhysReg)) { 00286 MBB->getParent()->verify(); 00287 errs() << "The register " << PrintReg(PhysReg) 00288 << " needs to be live in to BB#" << MBB->getNumber() 00289 << ", but is missing from the live-in list.\n"; 00290 llvm_unreachable("Invalid global physical register"); 00291 }
3) LLVM coalesces composite register and sub-registers, leaving some sub-registers undefined, but information is lost after regalloc rewriting.Is it expected?before regalloc:%vreg:item1<def,read-undef> = MOV_imm 0STORE <..#0>, 0, %vreg56
after regalloc:
%Rx<def> = MOV_imm 0
STORE <..#0>, 0, %RxyRegards,Sergey
I have a different version of isDefOnEntry coming that should reduce the
actual complexity. I have run into an unrelated problem though and I'm
getting that fixed now...
-Krzysztof
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation
_______________________________________________
LLVM Developers mailing list
llvm...@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev