Hi Hal,
yes, it's all about the induction variable. SystemZ has a late pass
(pre-emit) that looks for MI sequences that can be rewritten to 'branch
on count'. Currently only about half the number of BRCTs are output
compared to gcc on the same benchmarks. One reason for this is that when
a loop gets unrolled, the loop gets a greater increment / decrement than
1, which makes the late peephole transformation not work.
Since LSR generates formula for induction variables and evaluates them,
I thought this pass could somehow be made to generate and emit preferred
forms of induction variables. This seems like a good idea since this
should generally help all targets with similar h/w loop instructions
that begins with the trip count in a register and decrements and loops
until zero.
Could this be done somehow, or is it really so that all targets have to
have their own passes to do this?
/Jonas
On 2016-03-29 03:50, Hal Finkel wrote:> Hi Jonas,
>
> Are you talking specifically about the induction variable? You might look
at what I did for PowerPC's counter-based loops
(lib/Target/PowerPC/PPCCTRLoops.cpp, etc.).
>
> -Hal
>
> ----- Original Message -----
>> From: "Jonas Paulsson via llvm-dev" <llvm-dev at
lists.llvm.org>
>> To: "llvm-dev" <llvm-dev at lists.llvm.org>
>> Sent: Monday, March 28, 2016 8:02:40 AM
>> Subject: [llvm-dev] LoopStrengthReduce.cpp
>>
>> Hi,
>>
>> I am looking for a way to rewrite induction variables to use an
>> addition
>> of -1 whenever possible (and not otherwise unprofitable). This is
>> needed
>> to utilize hardware loop instructions, which are present on SystemZ
>> (branch on count). Later in the backend, an 'add -1; compare w/ 0;
>> jne
>> 0'-sequence can be replaced with a brct instruction.
>>
>> I could not find any way in the LSR pass to generate a formula for
>> this
>> (neither to express the lower target cost). I would like to generate
>> a
>> formula with a step of -1 and make the cost for it to be less than
>> that
>> of a similar formula with another constant.
>>
>> Could someone please give me any clue as to if there is a way to
>> currently do this, or if not, what would be the normal way?
>>
>> thanks,
>>
>> Jonas paulsson
>>
>> _______________________________________________
>> LLVM Developers mailing list
>> llvm-dev at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>>