[LLVMdev] Target description flags for instructions which may trap
gohman at apple.com
Thu Oct 30 09:08:08 PDT 2008
I think hasSideEffects is appropriate here. MachineLICM isn't intended
to be able to hoist every possible loop-invariant instruction. It's
intended to be able to hoist invariant instructions that aren't
the main LLVM-IR-level LICM pass, such as constant-pool loads.
I don't think the LLVM-IR-level LICM pass is currently smart enough to
hoist divides if it can be proven that the divisor is non-zero. But if
someone were looking to implement this feature, the LLVM-IR-level
LICM would be the place to do it, rather than MachineLICM.
I suspect the reason that other targets don't currently use
on their divide instructions is just that they haven't had to yet.
MachineLICM is yet not enabled by default on mainline.
On Oct 30, 2008, at 7:08 AM, Richard Osborne wrote:
> What are the correct target description side effect flags for
> instructions which may trap (e.g. divide / remainder)? The divide
> instruction in my backend currently has no flags set. I've enabled the
> MachineLICM pass and it's causing a miscompilation by hoisting a
> by zero instruction out of the loop. Clearly this pass needs to be
> aware that this is not safe. The current test in the MachineLICM is as
> // Ignore stuff that we obviously can't hoist.
> if (TID.mayStore() || TID.isCall() || TID.isReturn() ||
> TID.isBranch() ||
> return false;
> Setting hasSideEffects = 1 seems to work, but I'm not sure if that's
> intended use of this flag. I notice that divide / remainder
> for other architectures are not marked in this way. Also it is also
> pessimistic: if the divisor is know to be non zero then the
> couldn't trap and would be safe to motion.
> Richard Osborne | XMOS
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
More information about the llvm-dev