[llvm-commits] [llvm] r171136 - /llvm/trunk/lib/Target/X86/X86InstrArithmetic.td

Jakob Stoklund Olesen stoklund at 2pi.dk
Wed Jan 2 11:04:41 PST 2013


On Dec 26, 2012, at 7:01 PM, Craig Topper <craig.topper at gmail.com> wrote:

> Author: ctopper
> Date: Wed Dec 26 21:01:18 2012
> New Revision: 171136
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=171136&view=rev
> Log:
> Mark the divide instructions as hasSideEffects=0.

Hi Craig,

I don't think this is safe because div instructions can trap when the divisor is 0, and that means it is not safe to move them between basic blocks. See also llvm::isSafeToSpeculativelyExecute().

It would be nice if we had an 'unsafeToSpeculate' instruction flag, but currently UnmodeledSideEffects is all we have.

/jakob

> 
> Modified:
>    llvm/trunk/lib/Target/X86/X86InstrArithmetic.td
> 
> Modified: llvm/trunk/lib/Target/X86/X86InstrArithmetic.td
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrArithmetic.td?rev=171136&r1=171135&r2=171136&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/X86/X86InstrArithmetic.td (original)
> +++ llvm/trunk/lib/Target/X86/X86InstrArithmetic.td Wed Dec 26 21:01:18 2012
> @@ -266,6 +266,7 @@
> 
> 
> // unsigned division/remainder
> +let hasSideEffects = 0 in {
> let Defs = [AL,EFLAGS,AX], Uses = [AX] in
> def DIV8r  : I<0xF6, MRM6r, (outs),  (ins GR8:$src),    // AX/r8 = AL,AH
>                "div{b}\t$src", [], IIC_DIV8_REG>;
> @@ -325,6 +326,7 @@
> def IDIV64m: RI<0xF7, MRM7m, (outs), (ins i64mem:$src),
>                 "idiv{q}\t$src", [], IIC_IDIV64>;
> }
> +} // hasSideEffects = 0
> 
> //===----------------------------------------------------------------------===//
> //  Two address Instructions.
> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list