[LLVMdev] Vector LLVM extension v.s. DirectX Shaders
Tzu-Chien Chiu
tzuchien.chiu at gmail.com
Thu Dec 15 22:10:46 PST 2005
2005/12/16, Chris Lattner <sabre at nondot.org>:
> > _Almost each_ instruction specifies different write masks and
> > swizzles. There will be a lot of extract, combine, and permute LLVA
> > instructions. It may make the transformations difficult to match a
> > certain pattern in the program semantic tree. For example, to match
> > 'mul' and 'add', and merge them to a single instruction 'mad'
> > (multiple-and-add).
>
> I don't really buy that. Why do you think it will be hard? This is
> exactly what pattern-matching instruction selectors do.
For example, to match the 'mul' followed by an 'add' to be a single
'mad', there could be several patterns because of the vector
manipulation instructions.
y = A * B + C
They could simply be:
x = mul A, B
y = add x, C
or:
x = mul A, B
x_ = permute x
y = add x_, C
or:
x = mul A, B
x_ = permute x
C_ = permute C
y = add x_, C_
or:
x = mul A, B
C_ = permute C
y = add x, C_
or:
x = mul A, B
y_ = add x, C
y = apply_write_mask y (select and combine)
All of above instruction sequence could be selected to be the
following machine instruction:
// swizzle = permute
y.writemask = mad A.permute, B.permute, C.permute
This is probably not a good example for a frontend transformation, but
I just wanna to point out the potential difficulty to implement a
frontend pass.
--
Tzu-Chien Chiu - XGI Technology, Inc.
URL: http://www.csie.nctu.edu.tw/~jwchiu/
More information about the llvm-dev
mailing list