[LLVMdev] folding x * 0 = 0

David Greene dag at cray.com
Wed Mar 3 13:21:31 PST 2010


On Wednesday 03 March 2010 15:11:48 Török Edwin wrote:

> > We need to figure out exactly what "strict" means.  Is it like "restrict"
> > in C where it only has meaning with respect to other things marked
> > "restrict" or is it more general?  Can I reassociate a strict with a
> > relaxed?  Is it possible that "strict" will mean different things for
> > different operations?

> Lets note associative adds with a+, and strict ones with s+.
>
> For associativity for example you need 2 operations to be associative:
> (X a+ Y) a+ Z -> you can transform this to X a+ (Y a+ Z)
>
> (X s+ Y) a+ Z -> you can't transform this
>
> ((X s+ Y) a+ X) a+ Y, you can partially transform it,
>  1) lets note X s+ Y = Z
>  2) (Z a+ X) a+ Y -> Z a+ (X a+ Y) -> (X s+ Y) a+ (X a+ Y)
>  3) you can always choose to restrict a relaxed op (a+ -> s+)
>     (X s+ Y) a+ (X s+ Y) -> 2 a* (X s+ Y)

That's sort of along the lines of what I was thinking.  I was just trying to 
list the questions that immediately came to mind, not looking for solutions
just yet.  :)

> > We may need something akin to a fence over which no code motion can
> > occur.
>
> Maybe for signaling NaN, I don't know how those things work.
> I tend to avoid using any FP code in my code ;)

Signalling NaN is one case.  I'm sure there are others.

> > Some compilers use special operations to represent parentheses for
> > Fortran codes.  I don't think that will work very well for LLVM, however.
>
> With strict/relaxed flags for each operation (not value!) I think it can
> work, IF the frontend sets the flags appropriately.

I agree.

                                                          -Dave





More information about the llvm-dev mailing list