Path: blob/main/contrib/llvm-project/llvm/lib/Target/SystemZ/README.txt
35269 views
//===---------------------------------------------------------------------===//1// Random notes about and ideas for the SystemZ backend.2//===---------------------------------------------------------------------===//34The initial backend is deliberately restricted to z10. We should add support5for later architectures at some point.67--89If an inline asm ties an i32 "r" result to an i64 input, the input10will be treated as an i32, leaving the upper bits uninitialised.11For example:1213define void @f4(i32 *%dst) {14%val = call i32 asm "blah $0", "=r,0" (i64 103)15store i32 %val, i32 *%dst16ret void17}1819from CodeGen/SystemZ/asm-09.ll will use LHI rather than LGHI.20to load 103. This seems to be a general target-independent problem.2122--2324The tuning of the choice between LOAD ADDRESS (LA) and addition in25SystemZISelDAGToDAG.cpp is suspect. It should be tweaked based on26performance measurements.2728--2930There is no scheduling support.3132--3334We don't use the BRANCH ON INDEX instructions.3536--3738We only use MVC, XC and CLC for constant-length block operations.39We could extend them to variable-length operations too,40using EXECUTE RELATIVE LONG.4142MVCIN, MVCLE and CLCLE may be worthwhile too.4344--4546We don't use CUSE or the TRANSLATE family of instructions for string47operations. The TRANSLATE ones are probably more difficult to exploit.4849--5051We don't take full advantage of builtins like fabsl because the calling52conventions require f128s to be returned by invisible reference.5354--5556ADD LOGICAL WITH SIGNED IMMEDIATE could be useful when we need to57produce a carry. SUBTRACT LOGICAL IMMEDIATE could be useful when we58need to produce a borrow. (Note that there are no memory forms of59ADD LOGICAL WITH CARRY and SUBTRACT LOGICAL WITH BORROW, so the high60part of 128-bit memory operations would probably need to be done61via a register.)6263--6465We don't use ICM, STCM, or CLM.6667--6869We don't use ADD (LOGICAL) HIGH, SUBTRACT (LOGICAL) HIGH,70or COMPARE (LOGICAL) HIGH yet.7172--7374DAGCombiner doesn't yet fold truncations of extended loads. Functions like:7576unsigned long f (unsigned long x, unsigned short *y)77{78return (x << 32) | *y;79}8081therefore end up as:8283sllg %r2, %r2, 3284llgh %r0, 0(%r3)85lr %r2, %r086br %r148788but truncating the load would give:8990sllg %r2, %r2, 3291lh %r2, 0(%r3)92br %r149394--9596Functions like:9798define i64 @f1(i64 %a) {99%and = and i64 %a, 1100ret i64 %and101}102103ought to be implemented as:104105lhi %r0, 1106ngr %r2, %r0107br %r14108109but two-address optimizations reverse the order of the AND and force:110111lhi %r0, 1112ngr %r0, %r2113lgr %r2, %r0114br %r14115116CodeGen/SystemZ/and-04.ll has several examples of this.117118--119120Out-of-range displacements are usually handled by loading the full121address into a register. In many cases it would be better to create122an anchor point instead. E.g. for:123124define void @f4a(i128 *%aptr, i64 %base) {125%addr = add i64 %base, 524288126%bptr = inttoptr i64 %addr to i128 *127%a = load volatile i128 *%aptr128%b = load i128 *%bptr129%add = add i128 %a, %b130store i128 %add, i128 *%aptr131ret void132}133134(from CodeGen/SystemZ/int-add-08.ll) we load %base+524288 and %base+524296135into separate registers, rather than using %base+524288 as a base for both.136137--138139Dynamic stack allocations round the size to 8 bytes and then allocate140that rounded amount. It would be simpler to subtract the unrounded141size from the copy of the stack pointer and then align the result.142See CodeGen/SystemZ/alloca-01.ll for an example.143144--145146If needed, we can support 16-byte atomics using LPQ, STPQ and CSDG.147148--149150We might want to model all access registers and use them to spill15132-bit values.152153--154155We might want to use the 'overflow' condition of eg. AR to support156llvm.sadd.with.overflow.i32 and related instructions - the generated code157for signed overflow check is currently quite bad. This would improve158the results of using -ftrapv.159160161