[llvm-dev] isHardwareLoopProfitable() called with empty assumption cache in hwloops pass

Zheng CZ Chen via llvm-dev llvm-dev at lists.llvm.org
Thu Mar 25 03:49:52 PDT 2021


The usage of `AssumptionCache` in PPC hardware loop was introduced in
0724fea2da637883f1461e12ff46d596a816f758

For PPC hardware loop pass, we want to make sure we will not convert some
small loops into hardware loop. Small loop is identified by instruction
number of the loop. So we used `CodeMetrics` class to calculate the
instruction number.

And in the `CodeMetrics` class, when it calculates the instruction number,
it will exclude the ephemeral values(llvm.assume related instructions)
first, that's why we need assumption cache analysis.

I think it is ok to have empty `AssumptionCache`in PPC hardware loop pass
as it is true that after CGP there is no ephemeral values any more.

But maybe it makes more sense to have other APIs for `CodeMetrics` class to
calculate instruction number without `AssumptionCache`.

Thanks.

BRS//
Chen Zheng
Power Compiler Backend Developer




From:	Sam Parker <Sam.Parker at arm.com>
To:	Sjoerd Meijer <Sjoerd.Meijer at arm.com>, Janek Van Oirschot
            <janekvo at graphcore.ai>, "llvm-dev at lists.llvm.org"
            <llvm-dev at lists.llvm.org>
Cc:	David Green <David.Green at arm.com>, "czhengsz at cn.ibm.com"
            <czhengsz at cn.ibm.com>
Date:	2021/03/25 05:44 PM
Subject:	[EXTERNAL] Re: isHardwareLoopProfitable() called with empty
            assumption cache in hwloops pass



Indeed, it's just there because the original PPC implementation used it.
Looking back through the commits, I didn't move the pass into a different
phase so either PPC has either never had a populated assumption cache or
never noticed the change 
Indeed, it's just there because the original PPC implementation used it.
Looking back through the commits, I didn't move the pass into a different
phase so either PPC has either never had a populated assumption cache or
never noticed the change when it was cleared.

As Sjoerd said, can we re-populate it?

As long as it runs after LSR, I can't immediately think of anything that
would affect the Arm implementation (famous last words!) if we moved the
transform a bit earlier in the pipeline.

Regards,
Sam

Sam Parker
Compilation Tools Engineer | Arm
. . . . . . . . . . . . . . . . . . . . . . . . . . .
Arm.com



From: Sjoerd Meijer <Sjoerd.Meijer at arm.com>
Sent: 25 March 2021 09:32
To: Janek Van Oirschot <janekvo at graphcore.ai>; llvm-dev at lists.llvm.org
<llvm-dev at lists.llvm.org>
Cc: Sam Parker <Sam.Parker at arm.com>; David Green <David.Green at arm.com>
Subject: Re: isHardwareLoopProfitable() called with empty assumption cache
in hwloops pass

I can't imagine that being the intended behaviour. I don't think we have
paid much attention to the assumption cache in the ARM implementation. Some
parts of the hardware loop infrastructure were factored out from the
initial PPC implementation, which I think explains it is there and used by
PPC, but not in the ARM implementation. But perhaps Sam knows more.

I have never looked into the AssumptionCache, but I assume there's way to
retrigger and repopulate it (after CGP)?

Just out of curiousity, can you perhaps tell more how you would like to
persuade/force hardware loops with an assume? There are some options at the
moment (but would apply to all loops in the compilation unit), don't think
we e.g. looked into a pragma, so it sounds interesting. I guess this is a
hint about the iteration count?

Cheers,
Sjoerd.

From: Janek Van Oirschot <janekvo at graphcore.ai>
Sent: 24 March 2021 17:27
To: llvm-dev at lists.llvm.org <llvm-dev at lists.llvm.org>
Cc: Sam Parker <Sam.Parker at arm.com>; Sjoerd Meijer <Sjoerd.Meijer at arm.com>;
David Green <David.Green at arm.com>
Subject: isHardwareLoopProfitable() called with empty assumption cache in
hwloops pass

Hey all,

It seems that when HardwareLoops calls the isHardwareLoopProfitable TTI
hook, it never has a populated AssumptionCache. Some debugging revealed
that HardwareLoops runs during the PreISel phase for ARM and PPC. However,
the CodeGenPrepare pass runs before PreISel and removes all assumes meaning
that the AssumptionCache in HardwareLoops will end up empty.

>From what I gather (and let me know if I'm wrong), only PPC uses the
AssumptionCache in isHardwareLoopProfitable but only to aid in some cost
analysis. I was wondering whether it's intended behaviour to have an empty
AssumptionCache during HardwareLoops? I ask because I was looking into
using assumes to persuade HardwareLoops into emitting hardware intrinsics
for our (downstream) target.

Kind regards,
Janek van Oirschot





** We have updated our privacy policy, which contains important information
about how we collect and process your personal data. To read the policy,
please click here **

This email and its attachments are intended solely for the addressed
recipients and may contain confidential or legally privileged information.
If you are not the intended recipient you must not copy, distribute or
disseminate this email in any way; to do so may be unlawful.

Any personal data/special category personal data herein are processed in
accordance with UK data protection legislation.
All associated feasible security measures are in place. Further details are
available from the Privacy Notice on the website and/or from the Company.

Graphcore Limited (registered in England and Wales with registration number
10185006) is registered at 107 Cheapside, London, UK, EC2V 6DN.
This message was scanned for viruses upon transmission. However Graphcore
accepts no liability for any such transmission.





-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210325/cdada86e/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: graycol.gif
Type: image/gif
Size: 105 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210325/cdada86e/attachment.gif>


More information about the llvm-dev mailing list