OSDN Git Service

Fix Frac() returning 1.0.
[android-x86/external-swiftshader.git] / src / Reactor / LLVMReactor.cpp
index 58d5aad..d8bda70 100644 (file)
 #include "Memory.hpp"
 #include "MutexLock.hpp"
 
-#include <xmmintrin.h>
 #include <fstream>
 
+#if defined(__i386__) || defined(__x86_64__)
+#include <xmmintrin.h>
+#endif
+
 #if defined(__x86_64__) && defined(_WIN32)
 extern "C" void X86CompilationCallback()
 {
@@ -68,9 +71,7 @@ namespace
        llvm::Module *module = nullptr;
        llvm::Function *function = nullptr;
 
-       sw::BackoffLock codegenMutex;
-
-       sw::BasicBlock *falseBB = nullptr;
+       sw::MutexLock codegenMutex;
 }
 
 namespace sw
@@ -81,6 +82,7 @@ namespace sw
 
        class Type : public llvm::Type {};
        class Value : public llvm::Value {};
+       class SwitchCases : public llvm::SwitchInst {};
        class BasicBlock : public llvm::BasicBlock {};
 
        inline Type *T(llvm::Type *t)
@@ -452,8 +454,13 @@ namespace sw
                return value;
        }
 
-       Value *Nucleus::createGEP(Value *ptr, Type *type, Value *index)
+       Value *Nucleus::createGEP(Value *ptr, Type *type, Value *index, bool unsignedIndex)
        {
+               if(unsignedIndex && sizeof(void*) == 8)
+               {
+                       index = createZExt(index, Long::getType());
+               }
+
                assert(ptr->getType()->getContainedType(0) == type);
                return V(::builder->CreateGEP(ptr, index));
        }
@@ -483,11 +490,6 @@ namespace sw
                return V(::builder->CreateFPToSI(v, destType));
        }
 
-       Value *Nucleus::createUIToFP(Value *v, Type *destType)
-       {
-               return V(::builder->CreateUIToFP(v, destType));
-       }
-
        Value *Nucleus::createSIToFP(Value *v, Type *destType)
        {
                return V(::builder->CreateSIToFP(v, destType));
@@ -661,14 +663,14 @@ namespace sw
                return V(::builder->CreateSelect(C, ifTrue, ifFalse));
        }
 
-       Value *Nucleus::createSwitch(Value *v, BasicBlock *Dest, unsigned NumCases)
+       SwitchCases *Nucleus::createSwitch(Value *control, BasicBlock *defaultBranch, unsigned numCases)
        {
-               return V(::builder->CreateSwitch(v, Dest, NumCases));
+               return reinterpret_cast<SwitchCases*>(::builder->CreateSwitch(control, defaultBranch, numCases));
        }
 
-       void Nucleus::addSwitchCase(Value *Switch, int Case, BasicBlock *Branch)
+       void Nucleus::addSwitchCase(SwitchCases *switchCases, int label, BasicBlock *branch)
        {
-               reinterpret_cast<SwitchInst*>(Switch)->addCase(llvm::ConstantInt::get(Type::getInt32Ty(*::context), Case, true), Branch);
+               switchCases->addCase(llvm::ConstantInt::get(Type::getInt32Ty(*::context), label, true), branch);
        }
 
        void Nucleus::createUnreachable()
@@ -706,26 +708,7 @@ namespace sw
                        mask[3] ? 7 : 3,
                };
 
-               Value *shuffle = Nucleus::createShuffleVector(lhs, rhs, swizzle);
-
-               return shuffle;
-       }
-
-       Value *Nucleus::createConstantPointer(const void *address, Type *Ty, unsigned int align)
-       {
-               const GlobalValue *existingGlobal = ::executionEngine->getGlobalValueAtAddress(const_cast<void*>(address));   // FIXME: Const
-
-               if(existingGlobal)
-               {
-                       return (Value*)existingGlobal;
-               }
-
-               llvm::GlobalValue *global = new llvm::GlobalVariable(*::module, Ty, true, llvm::GlobalValue::ExternalLinkage, 0, "");
-               global->setAlignment(align);
-
-               ::executionEngine->addGlobalMapping(global, const_cast<void*>(address));
-
-               return V(global);
+               return Nucleus::createShuffleVector(lhs, rhs, swizzle);
        }
 
        Type *Nucleus::getPointerType(Type *ElementType)
@@ -823,7 +806,7 @@ namespace sw
                return T(llvm::Type::getVoidTy(*::context));
        }
 
-       class MMX : public Variable<MMX>
+       class MMX : public LValue<MMX>
        {
        public:
                static Type *getType();
@@ -839,10 +822,6 @@ namespace sw
                storeValue(argument.value);
        }
 
-       Bool::Bool()
-       {
-       }
-
        Bool::Bool(bool x)
        {
                storeValue(Nucleus::createConstantBool(x));
@@ -865,14 +844,14 @@ namespace sw
                storeValue(value);
        }
 
-       RValue<Bool> Bool::operator=(RValue<Bool> rhs) const
+       RValue<Bool> Bool::operator=(RValue<Bool> rhs)
        {
                storeValue(rhs.value);
 
                return rhs;
        }
 
-       RValue<Bool> Bool::operator=(const Bool &rhs) const
+       RValue<Bool> Bool::operator=(const Bool &rhs)
        {
                Value *value = rhs.loadValue();
                storeValue(value);
@@ -880,7 +859,7 @@ namespace sw
                return RValue<Bool>(value);
        }
 
-       RValue<Bool> Bool::operator=(const Reference<Bool> &rhs) const
+       RValue<Bool> Bool::operator=(const Reference<Bool> &rhs)
        {
                Value *value = rhs.loadValue();
                storeValue(value);
@@ -934,10 +913,6 @@ namespace sw
                storeValue(integer);
        }
 
-       Byte::Byte()
-       {
-       }
-
        Byte::Byte(int x)
        {
                storeValue(Nucleus::createConstantByte((unsigned char)x));
@@ -965,14 +940,14 @@ namespace sw
                storeValue(value);
        }
 
-       RValue<Byte> Byte::operator=(RValue<Byte> rhs) const
+       RValue<Byte> Byte::operator=(RValue<Byte> rhs)
        {
                storeValue(rhs.value);
 
                return rhs;
        }
 
-       RValue<Byte> Byte::operator=(const Byte &rhs) const
+       RValue<Byte> Byte::operator=(const Byte &rhs)
        {
                Value *value = rhs.loadValue();
                storeValue(value);
@@ -980,7 +955,7 @@ namespace sw
                return RValue<Byte>(value);
        }
 
-       RValue<Byte> Byte::operator=(const Reference<Byte> &rhs) const
+       RValue<Byte> Byte::operator=(const Reference<Byte> &rhs)
        {
                Value *value = rhs.loadValue();
                storeValue(value);
@@ -1038,52 +1013,52 @@ namespace sw
                return RValue<Byte>(Nucleus::createLShr(lhs.value, rhs.value));
        }
 
-       RValue<Byte> operator+=(const Byte &lhs, RValue<Byte> rhs)
+       RValue<Byte> operator+=(Byte &lhs, RValue<Byte> rhs)
        {
                return lhs = lhs + rhs;
        }
 
-       RValue<Byte> operator-=(const Byte &lhs, RValue<Byte> rhs)
+       RValue<Byte> operator-=(Byte &lhs, RValue<Byte> rhs)
        {
                return lhs = lhs - rhs;
        }
 
-       RValue<Byte> operator*=(const Byte &lhs, RValue<Byte> rhs)
+       RValue<Byte> operator*=(Byte &lhs, RValue<Byte> rhs)
        {
                return lhs = lhs * rhs;
        }
 
-       RValue<Byte> operator/=(const Byte &lhs, RValue<Byte> rhs)
+       RValue<Byte> operator/=(Byte &lhs, RValue<Byte> rhs)
        {
                return lhs = lhs / rhs;
        }
 
-       RValue<Byte> operator%=(const Byte &lhs, RValue<Byte> rhs)
+       RValue<Byte> operator%=(Byte &lhs, RValue<Byte> rhs)
        {
                return lhs = lhs % rhs;
        }
 
-       RValue<Byte> operator&=(const Byte &lhs, RValue<Byte> rhs)
+       RValue<Byte> operator&=(Byte &lhs, RValue<Byte> rhs)
        {
                return lhs = lhs & rhs;
        }
 
-       RValue<Byte> operator|=(const Byte &lhs, RValue<Byte> rhs)
+       RValue<Byte> operator|=(Byte &lhs, RValue<Byte> rhs)
        {
                return lhs = lhs | rhs;
        }
 
-       RValue<Byte> operator^=(const Byte &lhs, RValue<Byte> rhs)
+       RValue<Byte> operator^=(Byte &lhs, RValue<Byte> rhs)
        {
                return lhs = lhs ^ rhs;
        }
 
-       RValue<Byte> operator<<=(const Byte &lhs, RValue<Byte> rhs)
+       RValue<Byte> operator<<=(Byte &lhs, RValue<Byte> rhs)
        {
                return lhs = lhs << rhs;
        }
 
-       RValue<Byte> operator>>=(const Byte &lhs, RValue<Byte> rhs)
+       RValue<Byte> operator>>=(Byte &lhs, RValue<Byte> rhs)
        {
                return lhs = lhs >> rhs;
        }
@@ -1103,7 +1078,7 @@ namespace sw
                return RValue<Byte>(Nucleus::createNot(val.value));
        }
 
-       RValue<Byte> operator++(const Byte &val, int)   // Post-increment
+       RValue<Byte> operator++(Byte &val, int)   // Post-increment
        {
                RValue<Byte> res = val;
 
@@ -1113,7 +1088,7 @@ namespace sw
                return res;
        }
 
-       const Byte &operator++(const Byte &val)   // Pre-increment
+       const Byte &operator++(Byte &val)   // Pre-increment
        {
                Value *inc = Nucleus::createAdd(val.loadValue(), V(Nucleus::createConstantByte((unsigned char)1)));
                val.storeValue(inc);
@@ -1121,7 +1096,7 @@ namespace sw
                return val;
        }
 
-       RValue<Byte> operator--(const Byte &val, int)   // Post-decrement
+       RValue<Byte> operator--(Byte &val, int)   // Post-decrement
        {
                RValue<Byte> res = val;
 
@@ -1131,7 +1106,7 @@ namespace sw
                return res;
        }
 
-       const Byte &operator--(const Byte &val)   // Pre-decrement
+       const Byte &operator--(Byte &val)   // Pre-decrement
        {
                Value *inc = Nucleus::createSub(val.loadValue(), V(Nucleus::createConstantByte((unsigned char)1)));
                val.storeValue(inc);
@@ -1193,10 +1168,6 @@ namespace sw
                storeValue(integer);
        }
 
-       SByte::SByte()
-       {
-       }
-
        SByte::SByte(signed char x)
        {
                storeValue(Nucleus::createConstantByte(x));
@@ -1219,14 +1190,14 @@ namespace sw
                storeValue(value);
        }
 
-       RValue<SByte> SByte::operator=(RValue<SByte> rhs) const
+       RValue<SByte> SByte::operator=(RValue<SByte> rhs)
        {
                storeValue(rhs.value);
 
                return rhs;
        }
 
-       RValue<SByte> SByte::operator=(const SByte &rhs) const
+       RValue<SByte> SByte::operator=(const SByte &rhs)
        {
                Value *value = rhs.loadValue();
                storeValue(value);
@@ -1234,7 +1205,7 @@ namespace sw
                return RValue<SByte>(value);
        }
 
-       RValue<SByte> SByte::operator=(const Reference<SByte> &rhs) const
+       RValue<SByte> SByte::operator=(const Reference<SByte> &rhs)
        {
                Value *value = rhs.loadValue();
                storeValue(value);
@@ -1292,52 +1263,52 @@ namespace sw
                return RValue<SByte>(Nucleus::createAShr(lhs.value, rhs.value));
        }
 
-       RValue<SByte> operator+=(const SByte &lhs, RValue<SByte> rhs)
+       RValue<SByte> operator+=(SByte &lhs, RValue<SByte> rhs)
        {
                return lhs = lhs + rhs;
        }
 
-       RValue<SByte> operator-=(const SByte &lhs, RValue<SByte> rhs)
+       RValue<SByte> operator-=(SByte &lhs, RValue<SByte> rhs)
        {
                return lhs = lhs - rhs;
        }
 
-       RValue<SByte> operator*=(const SByte &lhs, RValue<SByte> rhs)
+       RValue<SByte> operator*=(SByte &lhs, RValue<SByte> rhs)
        {
                return lhs = lhs * rhs;
        }
 
-       RValue<SByte> operator/=(const SByte &lhs, RValue<SByte> rhs)
+       RValue<SByte> operator/=(SByte &lhs, RValue<SByte> rhs)
        {
                return lhs = lhs / rhs;
        }
 
-       RValue<SByte> operator%=(const SByte &lhs, RValue<SByte> rhs)
+       RValue<SByte> operator%=(SByte &lhs, RValue<SByte> rhs)
        {
                return lhs = lhs % rhs;
        }
 
-       RValue<SByte> operator&=(const SByte &lhs, RValue<SByte> rhs)
+       RValue<SByte> operator&=(SByte &lhs, RValue<SByte> rhs)
        {
                return lhs = lhs & rhs;
        }
 
-       RValue<SByte> operator|=(const SByte &lhs, RValue<SByte> rhs)
+       RValue<SByte> operator|=(SByte &lhs, RValue<SByte> rhs)
        {
                return lhs = lhs | rhs;
        }
 
-       RValue<SByte> operator^=(const SByte &lhs, RValue<SByte> rhs)
+       RValue<SByte> operator^=(SByte &lhs, RValue<SByte> rhs)
        {
                return lhs = lhs ^ rhs;
        }
 
-       RValue<SByte> operator<<=(const SByte &lhs, RValue<SByte> rhs)
+       RValue<SByte> operator<<=(SByte &lhs, RValue<SByte> rhs)
        {
                return lhs = lhs << rhs;
        }
 
-       RValue<SByte> operator>>=(const SByte &lhs, RValue<SByte> rhs)
+       RValue<SByte> operator>>=(SByte &lhs, RValue<SByte> rhs)
        {
                return lhs = lhs >> rhs;
        }
@@ -1357,7 +1328,7 @@ namespace sw
                return RValue<SByte>(Nucleus::createNot(val.value));
        }
 
-       RValue<SByte> operator++(const SByte &val, int)   // Post-increment
+       RValue<SByte> operator++(SByte &val, int)   // Post-increment
        {
                RValue<SByte> res = val;
 
@@ -1367,7 +1338,7 @@ namespace sw
                return res;
        }
 
-       const SByte &operator++(const SByte &val)   // Pre-increment
+       const SByte &operator++(SByte &val)   // Pre-increment
        {
                Value *inc = Nucleus::createAdd(val.loadValue(), V(Nucleus::createConstantByte((signed char)1)));
                val.storeValue(inc);
@@ -1375,7 +1346,7 @@ namespace sw
                return val;
        }
 
-       RValue<SByte> operator--(const SByte &val, int)   // Post-decrement
+       RValue<SByte> operator--(SByte &val, int)   // Post-decrement
        {
                RValue<SByte> res = val;
 
@@ -1385,7 +1356,7 @@ namespace sw
                return res;
        }
 
-       const SByte &operator--(const SByte &val)   // Pre-decrement
+       const SByte &operator--(SByte &val)   // Pre-decrement
        {
                Value *inc = Nucleus::createSub(val.loadValue(), V(Nucleus::createConstantByte((signed char)1)));
                val.storeValue(inc);
@@ -1440,10 +1411,6 @@ namespace sw
                storeValue(integer);
        }
 
-       Short::Short()
-       {
-       }
-
        Short::Short(short x)
        {
                storeValue(Nucleus::createConstantShort(x));
@@ -1466,14 +1433,14 @@ namespace sw
                storeValue(value);
        }
 
-       RValue<Short> Short::operator=(RValue<Short> rhs) const
+       RValue<Short> Short::operator=(RValue<Short> rhs)
        {
                storeValue(rhs.value);
 
                return rhs;
        }
 
-       RValue<Short> Short::operator=(const Short &rhs) const
+       RValue<Short> Short::operator=(const Short &rhs)
        {
                Value *value = rhs.loadValue();
                storeValue(value);
@@ -1481,7 +1448,7 @@ namespace sw
                return RValue<Short>(value);
        }
 
-       RValue<Short> Short::operator=(const Reference<Short> &rhs) const
+       RValue<Short> Short::operator=(const Reference<Short> &rhs)
        {
                Value *value = rhs.loadValue();
                storeValue(value);
@@ -1539,52 +1506,52 @@ namespace sw
                return RValue<Short>(Nucleus::createAShr(lhs.value, rhs.value));
        }
 
-       RValue<Short> operator+=(const Short &lhs, RValue<Short> rhs)
+       RValue<Short> operator+=(Short &lhs, RValue<Short> rhs)
        {
                return lhs = lhs + rhs;
        }
 
-       RValue<Short> operator-=(const Short &lhs, RValue<Short> rhs)
+       RValue<Short> operator-=(Short &lhs, RValue<Short> rhs)
        {
                return lhs = lhs - rhs;
        }
 
-       RValue<Short> operator*=(const Short &lhs, RValue<Short> rhs)
+       RValue<Short> operator*=(Short &lhs, RValue<Short> rhs)
        {
                return lhs = lhs * rhs;
        }
 
-       RValue<Short> operator/=(const Short &lhs, RValue<Short> rhs)
+       RValue<Short> operator/=(Short &lhs, RValue<Short> rhs)
        {
                return lhs = lhs / rhs;
        }
 
-       RValue<Short> operator%=(const Short &lhs, RValue<Short> rhs)
+       RValue<Short> operator%=(Short &lhs, RValue<Short> rhs)
        {
                return lhs = lhs % rhs;
        }
 
-       RValue<Short> operator&=(const Short &lhs, RValue<Short> rhs)
+       RValue<Short> operator&=(Short &lhs, RValue<Short> rhs)
        {
                return lhs = lhs & rhs;
        }
 
-       RValue<Short> operator|=(const Short &lhs, RValue<Short> rhs)
+       RValue<Short> operator|=(Short &lhs, RValue<Short> rhs)
        {
                return lhs = lhs | rhs;
        }
 
-       RValue<Short> operator^=(const Short &lhs, RValue<Short> rhs)
+       RValue<Short> operator^=(Short &lhs, RValue<Short> rhs)
        {
                return lhs = lhs ^ rhs;
        }
 
-       RValue<Short> operator<<=(const Short &lhs, RValue<Short> rhs)
+       RValue<Short> operator<<=(Short &lhs, RValue<Short> rhs)
        {
                return lhs = lhs << rhs;
        }
 
-       RValue<Short> operator>>=(const Short &lhs, RValue<Short> rhs)
+       RValue<Short> operator>>=(Short &lhs, RValue<Short> rhs)
        {
                return lhs = lhs >> rhs;
        }
@@ -1604,7 +1571,7 @@ namespace sw
                return RValue<Short>(Nucleus::createNot(val.value));
        }
 
-       RValue<Short> operator++(const Short &val, int)   // Post-increment
+       RValue<Short> operator++(Short &val, int)   // Post-increment
        {
                RValue<Short> res = val;
 
@@ -1614,7 +1581,7 @@ namespace sw
                return res;
        }
 
-       const Short &operator++(const Short &val)   // Pre-increment
+       const Short &operator++(Short &val)   // Pre-increment
        {
                Value *inc = Nucleus::createAdd(val.loadValue(), V(Nucleus::createConstantShort((short)1)));
                val.storeValue(inc);
@@ -1622,7 +1589,7 @@ namespace sw
                return val;
        }
 
-       RValue<Short> operator--(const Short &val, int)   // Post-decrement
+       RValue<Short> operator--(Short &val, int)   // Post-decrement
        {
                RValue<Short> res = val;
 
@@ -1632,7 +1599,7 @@ namespace sw
                return res;
        }
 
-       const Short &operator--(const Short &val)   // Pre-decrement
+       const Short &operator--(Short &val)   // Pre-decrement
        {
                Value *inc = Nucleus::createSub(val.loadValue(), V(Nucleus::createConstantShort((short)1)));
                val.storeValue(inc);
@@ -1694,10 +1661,6 @@ namespace sw
                storeValue(integer);
        }
 
-       UShort::UShort()
-       {
-       }
-
        UShort::UShort(unsigned short x)
        {
                storeValue(Nucleus::createConstantShort(x));
@@ -1720,14 +1683,14 @@ namespace sw
                storeValue(value);
        }
 
-       RValue<UShort> UShort::operator=(RValue<UShort> rhs) const
+       RValue<UShort> UShort::operator=(RValue<UShort> rhs)
        {
                storeValue(rhs.value);
 
                return rhs;
        }
 
-       RValue<UShort> UShort::operator=(const UShort &rhs) const
+       RValue<UShort> UShort::operator=(const UShort &rhs)
        {
                Value *value = rhs.loadValue();
                storeValue(value);
@@ -1735,7 +1698,7 @@ namespace sw
                return RValue<UShort>(value);
        }
 
-       RValue<UShort> UShort::operator=(const Reference<UShort> &rhs) const
+       RValue<UShort> UShort::operator=(const Reference<UShort> &rhs)
        {
                Value *value = rhs.loadValue();
                storeValue(value);
@@ -1793,52 +1756,52 @@ namespace sw
                return RValue<UShort>(Nucleus::createLShr(lhs.value, rhs.value));
        }
 
-       RValue<UShort> operator+=(const UShort &lhs, RValue<UShort> rhs)
+       RValue<UShort> operator+=(UShort &lhs, RValue<UShort> rhs)
        {
                return lhs = lhs + rhs;
        }
 
-       RValue<UShort> operator-=(const UShort &lhs, RValue<UShort> rhs)
+       RValue<UShort> operator-=(UShort &lhs, RValue<UShort> rhs)
        {
                return lhs = lhs - rhs;
        }
 
-       RValue<UShort> operator*=(const UShort &lhs, RValue<UShort> rhs)
+       RValue<UShort> operator*=(UShort &lhs, RValue<UShort> rhs)
        {
                return lhs = lhs * rhs;
        }
 
-       RValue<UShort> operator/=(const UShort &lhs, RValue<UShort> rhs)
+       RValue<UShort> operator/=(UShort &lhs, RValue<UShort> rhs)
        {
                return lhs = lhs / rhs;
        }
 
-       RValue<UShort> operator%=(const UShort &lhs, RValue<UShort> rhs)
+       RValue<UShort> operator%=(UShort &lhs, RValue<UShort> rhs)
        {
                return lhs = lhs % rhs;
        }
 
-       RValue<UShort> operator&=(const UShort &lhs, RValue<UShort> rhs)
+       RValue<UShort> operator&=(UShort &lhs, RValue<UShort> rhs)
        {
                return lhs = lhs & rhs;
        }
 
-       RValue<UShort> operator|=(const UShort &lhs, RValue<UShort> rhs)
+       RValue<UShort> operator|=(UShort &lhs, RValue<UShort> rhs)
        {
                return lhs = lhs | rhs;
        }
 
-       RValue<UShort> operator^=(const UShort &lhs, RValue<UShort> rhs)
+       RValue<UShort> operator^=(UShort &lhs, RValue<UShort> rhs)
        {
                return lhs = lhs ^ rhs;
        }
 
-       RValue<UShort> operator<<=(const UShort &lhs, RValue<UShort> rhs)
+       RValue<UShort> operator<<=(UShort &lhs, RValue<UShort> rhs)
        {
                return lhs = lhs << rhs;
        }
 
-       RValue<UShort> operator>>=(const UShort &lhs, RValue<UShort> rhs)
+       RValue<UShort> operator>>=(UShort &lhs, RValue<UShort> rhs)
        {
                return lhs = lhs >> rhs;
        }
@@ -1858,7 +1821,7 @@ namespace sw
                return RValue<UShort>(Nucleus::createNot(val.value));
        }
 
-       RValue<UShort> operator++(const UShort &val, int)   // Post-increment
+       RValue<UShort> operator++(UShort &val, int)   // Post-increment
        {
                RValue<UShort> res = val;
 
@@ -1868,7 +1831,7 @@ namespace sw
                return res;
        }
 
-       const UShort &operator++(const UShort &val)   // Pre-increment
+       const UShort &operator++(UShort &val)   // Pre-increment
        {
                Value *inc = Nucleus::createAdd(val.loadValue(), V(Nucleus::createConstantShort((unsigned short)1)));
                val.storeValue(inc);
@@ -1876,7 +1839,7 @@ namespace sw
                return val;
        }
 
-       RValue<UShort> operator--(const UShort &val, int)   // Post-decrement
+       RValue<UShort> operator--(UShort &val, int)   // Post-decrement
        {
                RValue<UShort> res = val;
 
@@ -1886,7 +1849,7 @@ namespace sw
                return res;
        }
 
-       const UShort &operator--(const UShort &val)   // Pre-decrement
+       const UShort &operator--(UShort &val)   // Pre-decrement
        {
                Value *inc = Nucleus::createSub(val.loadValue(), V(Nucleus::createConstantShort((unsigned short)1)));
                val.storeValue(inc);
@@ -1931,15 +1894,11 @@ namespace sw
 
        Byte4::Byte4(RValue<Byte8> cast)
        {
-       //      xyzw.parent = this;
-
                storeValue(Nucleus::createTrunc(Nucleus::createBitCast(cast.value, Long::getType()), Int::getType()));
        }
 
        Byte4::Byte4(const Reference<Byte4> &rhs)
        {
-       //      xyzw.parent = this;
-
                Value *value = rhs.loadValue();
                storeValue(value);
        }
@@ -1962,15 +1921,8 @@ namespace sw
                #endif
        }
 
-       Byte8::Byte8()
-       {
-       //      xyzw.parent = this;
-       }
-
        Byte8::Byte8(uint8_t x0, uint8_t x1, uint8_t x2, uint8_t x3, uint8_t x4, uint8_t x5, uint8_t x6, uint8_t x7)
        {
-       //      xyzw.parent = this;
-
                int64_t constantVector[8] = {x0, x1, x2, x3, x4, x5, x6, x7};
                Value *vector = V(Nucleus::createConstantVector(constantVector, T(VectorType::get(Byte::getType(), 8))));
 
@@ -1979,35 +1931,29 @@ namespace sw
 
        Byte8::Byte8(RValue<Byte8> rhs)
        {
-       //      xyzw.parent = this;
-
                storeValue(rhs.value);
        }
 
        Byte8::Byte8(const Byte8 &rhs)
        {
-       //      xyzw.parent = this;
-
                Value *value = rhs.loadValue();
                storeValue(value);
        }
 
        Byte8::Byte8(const Reference<Byte8> &rhs)
        {
-       //      xyzw.parent = this;
-
                Value *value = rhs.loadValue();
                storeValue(value);
        }
 
-       RValue<Byte8> Byte8::operator=(RValue<Byte8> rhs) const
+       RValue<Byte8> Byte8::operator=(RValue<Byte8> rhs)
        {
                storeValue(rhs.value);
 
                return rhs;
        }
 
-       RValue<Byte8> Byte8::operator=(const Byte8 &rhs) const
+       RValue<Byte8> Byte8::operator=(const Byte8 &rhs)
        {
                Value *value = rhs.loadValue();
                storeValue(value);
@@ -2015,7 +1961,7 @@ namespace sw
                return RValue<Byte8>(value);
        }
 
-       RValue<Byte8> Byte8::operator=(const Reference<Byte8> &rhs) const
+       RValue<Byte8> Byte8::operator=(const Reference<Byte8> &rhs)
        {
                Value *value = rhs.loadValue();
                storeValue(value);
@@ -2108,52 +2054,52 @@ namespace sw
 //             return RValue<Byte8>(Nucleus::createLShr(lhs.value, rhs.value));
 //     }
 
-       RValue<Byte8> operator+=(const Byte8 &lhs, RValue<Byte8> rhs)
+       RValue<Byte8> operator+=(Byte8 &lhs, RValue<Byte8> rhs)
        {
                return lhs = lhs + rhs;
        }
 
-       RValue<Byte8> operator-=(const Byte8 &lhs, RValue<Byte8> rhs)
+       RValue<Byte8> operator-=(Byte8 &lhs, RValue<Byte8> rhs)
        {
                return lhs = lhs - rhs;
        }
 
-//     RValue<Byte8> operator*=(const Byte8 &lhs, RValue<Byte8> rhs)
+//     RValue<Byte8> operator*=(Byte8 &lhs, RValue<Byte8> rhs)
 //     {
 //             return lhs = lhs * rhs;
 //     }
 
-//     RValue<Byte8> operator/=(const Byte8 &lhs, RValue<Byte8> rhs)
+//     RValue<Byte8> operator/=(Byte8 &lhs, RValue<Byte8> rhs)
 //     {
 //             return lhs = lhs / rhs;
 //     }
 
-//     RValue<Byte8> operator%=(const Byte8 &lhs, RValue<Byte8> rhs)
+//     RValue<Byte8> operator%=(Byte8 &lhs, RValue<Byte8> rhs)
 //     {
 //             return lhs = lhs % rhs;
 //     }
 
-       RValue<Byte8> operator&=(const Byte8 &lhs, RValue<Byte8> rhs)
+       RValue<Byte8> operator&=(Byte8 &lhs, RValue<Byte8> rhs)
        {
                return lhs = lhs & rhs;
        }
 
-       RValue<Byte8> operator|=(const Byte8 &lhs, RValue<Byte8> rhs)
+       RValue<Byte8> operator|=(Byte8 &lhs, RValue<Byte8> rhs)
        {
                return lhs = lhs | rhs;
        }
 
-       RValue<Byte8> operator^=(const Byte8 &lhs, RValue<Byte8> rhs)
+       RValue<Byte8> operator^=(Byte8 &lhs, RValue<Byte8> rhs)
        {
                return lhs = lhs ^ rhs;
        }
 
-//     RValue<Byte8> operator<<=(const Byte8 &lhs, RValue<Byte8> rhs)
+//     RValue<Byte8> operator<<=(Byte8 &lhs, RValue<Byte8> rhs)
 //     {
 //             return lhs = lhs << rhs;
 //     }
 
-//     RValue<Byte8> operator>>=(const Byte8 &lhs, RValue<Byte8> rhs)
+//     RValue<Byte8> operator>>=(Byte8 &lhs, RValue<Byte8> rhs)
 //     {
 //             return lhs = lhs >> rhs;
 //     }
@@ -2198,6 +2144,14 @@ namespace sw
                return UnpackLow(RValue<Byte8>(byte8), RValue<Byte8>(byte8));
        }
 
+       RValue<Short4> Unpack(RValue<Byte4> x, RValue<Byte4> y)
+       {
+               Value *xx = Nucleus::createInsertElement(V(UndefValue::get(VectorType::get(Int::getType(), 2))), x.value, 0);
+               Value *yy = Nucleus::createInsertElement(V(UndefValue::get(VectorType::get(Int::getType(), 2))), y.value, 0);
+
+               return UnpackLow(As<Byte8>(xx), As<Byte8>(yy));
+       }
+
        RValue<Short4> UnpackLow(RValue<Byte8> x, RValue<Byte8> y)
        {
                if(CPUID::supportsMMX2())
@@ -2255,15 +2209,8 @@ namespace sw
                }
        }
 
-       SByte8::SByte8()
-       {
-       //      xyzw.parent = this;
-       }
-
        SByte8::SByte8(uint8_t x0, uint8_t x1, uint8_t x2, uint8_t x3, uint8_t x4, uint8_t x5, uint8_t x6, uint8_t x7)
        {
-       //      xyzw.parent = this;
-
                int64_t constantVector[8] = {x0, x1, x2, x3, x4, x5, x6, x7};
                Value *vector = V(Nucleus::createConstantVector(constantVector, T(VectorType::get(SByte::getType(), 8))));
 
@@ -2272,35 +2219,29 @@ namespace sw
 
        SByte8::SByte8(RValue<SByte8> rhs)
        {
-       //      xyzw.parent = this;
-
                storeValue(rhs.value);
        }
 
        SByte8::SByte8(const SByte8 &rhs)
        {
-       //      xyzw.parent = this;
-
                Value *value = rhs.loadValue();
                storeValue(value);
        }
 
        SByte8::SByte8(const Reference<SByte8> &rhs)
        {
-       //      xyzw.parent = this;
-
                Value *value = rhs.loadValue();
                storeValue(value);
        }
 
-       RValue<SByte8> SByte8::operator=(RValue<SByte8> rhs) const
+       RValue<SByte8> SByte8::operator=(RValue<SByte8> rhs)
        {
                storeValue(rhs.value);
 
                return rhs;
        }
 
-       RValue<SByte8> SByte8::operator=(const SByte8 &rhs) const
+       RValue<SByte8> SByte8::operator=(const SByte8 &rhs)
        {
                Value *value = rhs.loadValue();
                storeValue(value);
@@ -2308,7 +2249,7 @@ namespace sw
                return RValue<SByte8>(value);
        }
 
-       RValue<SByte8> SByte8::operator=(const Reference<SByte8> &rhs) const
+       RValue<SByte8> SByte8::operator=(const Reference<SByte8> &rhs)
        {
                Value *value = rhs.loadValue();
                storeValue(value);
@@ -2380,52 +2321,52 @@ namespace sw
 //             return RValue<SByte8>(Nucleus::createAShr(lhs.value, rhs.value));
 //     }
 
-       RValue<SByte8> operator+=(const SByte8 &lhs, RValue<SByte8> rhs)
+       RValue<SByte8> operator+=(SByte8 &lhs, RValue<SByte8> rhs)
        {
                return lhs = lhs + rhs;
        }
 
-       RValue<SByte8> operator-=(const SByte8 &lhs, RValue<SByte8> rhs)
+       RValue<SByte8> operator-=(SByte8 &lhs, RValue<SByte8> rhs)
        {
                return lhs = lhs - rhs;
        }
 
-//     RValue<SByte8> operator*=(const SByte8 &lhs, RValue<SByte8> rhs)
+//     RValue<SByte8> operator*=(SByte8 &lhs, RValue<SByte8> rhs)
 //     {
 //             return lhs = lhs * rhs;
 //     }
 
-//     RValue<SByte8> operator/=(const SByte8 &lhs, RValue<SByte8> rhs)
+//     RValue<SByte8> operator/=(SByte8 &lhs, RValue<SByte8> rhs)
 //     {
 //             return lhs = lhs / rhs;
 //     }
 
-//     RValue<SByte8> operator%=(const SByte8 &lhs, RValue<SByte8> rhs)
+//     RValue<SByte8> operator%=(SByte8 &lhs, RValue<SByte8> rhs)
 //     {
 //             return lhs = lhs % rhs;
 //     }
 
-       RValue<SByte8> operator&=(const SByte8 &lhs, RValue<SByte8> rhs)
+       RValue<SByte8> operator&=(SByte8 &lhs, RValue<SByte8> rhs)
        {
                return lhs = lhs & rhs;
        }
 
-       RValue<SByte8> operator|=(const SByte8 &lhs, RValue<SByte8> rhs)
+       RValue<SByte8> operator|=(SByte8 &lhs, RValue<SByte8> rhs)
        {
                return lhs = lhs | rhs;
        }
 
-       RValue<SByte8> operator^=(const SByte8 &lhs, RValue<SByte8> rhs)
+       RValue<SByte8> operator^=(SByte8 &lhs, RValue<SByte8> rhs)
        {
                return lhs = lhs ^ rhs;
        }
 
-//     RValue<SByte8> operator<<=(const SByte8 &lhs, RValue<SByte8> rhs)
+//     RValue<SByte8> operator<<=(SByte8 &lhs, RValue<SByte8> rhs)
 //     {
 //             return lhs = lhs << rhs;
 //     }
 
-//     RValue<SByte8> operator>>=(const SByte8 &lhs, RValue<SByte8> rhs)
+//     RValue<SByte8> operator>>=(SByte8 &lhs, RValue<SByte8> rhs)
 //     {
 //             return lhs = lhs >> rhs;
 //     }
@@ -2521,35 +2462,29 @@ namespace sw
 
        Byte16::Byte16(RValue<Byte16> rhs)
        {
-       //      xyzw.parent = this;
-
                storeValue(rhs.value);
        }
 
        Byte16::Byte16(const Byte16 &rhs)
        {
-       //      xyzw.parent = this;
-
                Value *value = rhs.loadValue();
                storeValue(value);
        }
 
        Byte16::Byte16(const Reference<Byte16> &rhs)
        {
-       //      xyzw.parent = this;
-
                Value *value = rhs.loadValue();
                storeValue(value);
        }
 
-       RValue<Byte16> Byte16::operator=(RValue<Byte16> rhs) const
+       RValue<Byte16> Byte16::operator=(RValue<Byte16> rhs)
        {
                storeValue(rhs.value);
 
                return rhs;
        }
 
-       RValue<Byte16> Byte16::operator=(const Byte16 &rhs) const
+       RValue<Byte16> Byte16::operator=(const Byte16 &rhs)
        {
                Value *value = rhs.loadValue();
                storeValue(value);
@@ -2557,7 +2492,7 @@ namespace sw
                return RValue<Byte16>(value);
        }
 
-       RValue<Byte16> Byte16::operator=(const Reference<Byte16> &rhs) const
+       RValue<Byte16> Byte16::operator=(const Reference<Byte16> &rhs)
        {
                Value *value = rhs.loadValue();
                storeValue(value);
@@ -2669,15 +2604,8 @@ namespace sw
                storeValue(As<Short4>(Int2(v4i32)).value);
        }
 
-       Short4::Short4()
-       {
-       //      xyzw.parent = this;
-       }
-
        Short4::Short4(short xyzw)
        {
-               //      xyzw.parent = this;
-
                int64_t constantVector[4] = {xyzw, xyzw, xyzw, xyzw};
                Value *vector = V(Nucleus::createConstantVector(constantVector, T(VectorType::get(Short::getType(), 4))));
 
@@ -2686,8 +2614,6 @@ namespace sw
 
        Short4::Short4(short x, short y, short z, short w)
        {
-       //      xyzw.parent = this;
-
                int64_t constantVector[4] = {x, y, z, w};
                Value *vector = V(Nucleus::createConstantVector(constantVector, T(VectorType::get(Short::getType(), 4))));
 
@@ -2696,56 +2622,44 @@ namespace sw
 
        Short4::Short4(RValue<Short4> rhs)
        {
-       //      xyzw.parent = this;
-
                storeValue(rhs.value);
        }
 
        Short4::Short4(const Short4 &rhs)
        {
-       //      xyzw.parent = this;
-
                Value *value = rhs.loadValue();
                storeValue(value);
        }
 
        Short4::Short4(const Reference<Short4> &rhs)
        {
-       //      xyzw.parent = this;
-
                Value *value = rhs.loadValue();
                storeValue(value);
        }
 
        Short4::Short4(RValue<UShort4> rhs)
        {
-       //      xyzw.parent = this;
-
                storeValue(rhs.value);
        }
 
        Short4::Short4(const UShort4 &rhs)
        {
-       //      xyzw.parent = this;
-
                storeValue(rhs.loadValue());
        }
 
        Short4::Short4(const Reference<UShort4> &rhs)
        {
-       //      xyzw.parent = this;
-
                storeValue(rhs.loadValue());
        }
 
-       RValue<Short4> Short4::operator=(RValue<Short4> rhs) const
+       RValue<Short4> Short4::operator=(RValue<Short4> rhs)
        {
                storeValue(rhs.value);
 
                return rhs;
        }
 
-       RValue<Short4> Short4::operator=(const Short4 &rhs) const
+       RValue<Short4> Short4::operator=(const Short4 &rhs)
        {
                Value *value = rhs.loadValue();
                storeValue(value);
@@ -2753,7 +2667,7 @@ namespace sw
                return RValue<Short4>(value);
        }
 
-       RValue<Short4> Short4::operator=(const Reference<Short4> &rhs) const
+       RValue<Short4> Short4::operator=(const Reference<Short4> &rhs)
        {
                Value *value = rhs.loadValue();
                storeValue(value);
@@ -2761,14 +2675,14 @@ namespace sw
                return RValue<Short4>(value);
        }
 
-       RValue<Short4> Short4::operator=(RValue<UShort4> rhs) const
+       RValue<Short4> Short4::operator=(RValue<UShort4> rhs)
        {
                storeValue(rhs.value);
 
                return RValue<Short4>(rhs);
        }
 
-       RValue<Short4> Short4::operator=(const UShort4 &rhs) const
+       RValue<Short4> Short4::operator=(const UShort4 &rhs)
        {
                Value *value = rhs.loadValue();
                storeValue(value);
@@ -2776,7 +2690,7 @@ namespace sw
                return RValue<Short4>(value);
        }
 
-       RValue<Short4> Short4::operator=(const Reference<UShort4> &rhs) const
+       RValue<Short4> Short4::operator=(const Reference<UShort4> &rhs)
        {
                Value *value = rhs.loadValue();
                storeValue(value);
@@ -2880,76 +2794,52 @@ namespace sw
                return x86::psraw(lhs, rhs);
        }
 
-       RValue<Short4> operator<<(RValue<Short4> lhs, RValue<Long1> rhs)
-       {
-       //      return RValue<Short4>(Nucleus::createShl(lhs.value, rhs.value));
-
-               return x86::psllw(lhs, rhs);
-       }
-
-       RValue<Short4> operator>>(RValue<Short4> lhs, RValue<Long1> rhs)
-       {
-       //      return RValue<Short4>(Nucleus::createAShr(lhs.value, rhs.value));
-
-               return x86::psraw(lhs, rhs);
-       }
-
-       RValue<Short4> operator+=(const Short4 &lhs, RValue<Short4> rhs)
+       RValue<Short4> operator+=(Short4 &lhs, RValue<Short4> rhs)
        {
                return lhs = lhs + rhs;
        }
 
-       RValue<Short4> operator-=(const Short4 &lhs, RValue<Short4> rhs)
+       RValue<Short4> operator-=(Short4 &lhs, RValue<Short4> rhs)
        {
                return lhs = lhs - rhs;
        }
 
-       RValue<Short4> operator*=(const Short4 &lhs, RValue<Short4> rhs)
+       RValue<Short4> operator*=(Short4 &lhs, RValue<Short4> rhs)
        {
                return lhs = lhs * rhs;
        }
 
-//     RValue<Short4> operator/=(const Short4 &lhs, RValue<Short4> rhs)
+//     RValue<Short4> operator/=(Short4 &lhs, RValue<Short4> rhs)
 //     {
 //             return lhs = lhs / rhs;
 //     }
 
-//     RValue<Short4> operator%=(const Short4 &lhs, RValue<Short4> rhs)
+//     RValue<Short4> operator%=(Short4 &lhs, RValue<Short4> rhs)
 //     {
 //             return lhs = lhs % rhs;
 //     }
 
-       RValue<Short4> operator&=(const Short4 &lhs, RValue<Short4> rhs)
+       RValue<Short4> operator&=(Short4 &lhs, RValue<Short4> rhs)
        {
                return lhs = lhs & rhs;
        }
 
-       RValue<Short4> operator|=(const Short4 &lhs, RValue<Short4> rhs)
+       RValue<Short4> operator|=(Short4 &lhs, RValue<Short4> rhs)
        {
                return lhs = lhs | rhs;
        }
 
-       RValue<Short4> operator^=(const Short4 &lhs, RValue<Short4> rhs)
+       RValue<Short4> operator^=(Short4 &lhs, RValue<Short4> rhs)
        {
                return lhs = lhs ^ rhs;
        }
 
-       RValue<Short4> operator<<=(const Short4 &lhs, unsigned char rhs)
-       {
-               return lhs = lhs << rhs;
-       }
-
-       RValue<Short4> operator>>=(const Short4 &lhs, unsigned char rhs)
-       {
-               return lhs = lhs >> rhs;
-       }
-
-       RValue<Short4> operator<<=(const Short4 &lhs, RValue<Long1> rhs)
+       RValue<Short4> operator<<=(Short4 &lhs, unsigned char rhs)
        {
                return lhs = lhs << rhs;
        }
 
-       RValue<Short4> operator>>=(const Short4 &lhs, RValue<Long1> rhs)
+       RValue<Short4> operator>>=(Short4 &lhs, unsigned char rhs)
        {
                return lhs = lhs >> rhs;
        }
@@ -3143,23 +3033,16 @@ namespace sw
 
                if(!saturate || !CPUID::supportsSSE4_1())
                {
-                       *this = Short4(Int4(int4));
+                       *this = Short4(int4);
                }
                else
                {
-                       *this = As<Short4>(Int2(As<Int4>(x86::packusdw(As<UInt4>(int4), As<UInt4>(int4)))));
+                       *this = As<Short4>(Int2(As<Int4>(x86::packusdw(int4, int4))));
                }
        }
 
-       UShort4::UShort4()
-       {
-       //      xyzw.parent = this;
-       }
-
        UShort4::UShort4(unsigned short xyzw)
        {
-               //      xyzw.parent = this;
-
                int64_t constantVector[4] = {xyzw, xyzw, xyzw, xyzw};
                Value *vector = V(Nucleus::createConstantVector(constantVector, T(VectorType::get(UShort::getType(), 4))));
 
@@ -3168,8 +3051,6 @@ namespace sw
 
        UShort4::UShort4(unsigned short x, unsigned short y, unsigned short z, unsigned short w)
        {
-       //      xyzw.parent = this;
-
                int64_t constantVector[4] = {x, y, z, w};
                Value *vector = V(Nucleus::createConstantVector(constantVector, T(VectorType::get(UShort::getType(), 4))));
 
@@ -3178,58 +3059,46 @@ namespace sw
 
        UShort4::UShort4(RValue<UShort4> rhs)
        {
-       //      xyzw.parent = this;
-
                storeValue(rhs.value);
        }
 
        UShort4::UShort4(const UShort4 &rhs)
        {
-       //      xyzw.parent = this;
-
                Value *value = rhs.loadValue();
                storeValue(value);
        }
 
        UShort4::UShort4(const Reference<UShort4> &rhs)
        {
-       //      xyzw.parent = this;
-
                Value *value = rhs.loadValue();
                storeValue(value);
        }
 
        UShort4::UShort4(RValue<Short4> rhs)
        {
-       //      xyzw.parent = this;
-
                storeValue(rhs.value);
        }
 
        UShort4::UShort4(const Short4 &rhs)
        {
-       //      xyzw.parent = this;
-
                Value *value = rhs.loadValue();
                storeValue(value);
        }
 
        UShort4::UShort4(const Reference<Short4> &rhs)
        {
-       //      xyzw.parent = this;
-
                Value *value = rhs.loadValue();
                storeValue(value);
        }
 
-       RValue<UShort4> UShort4::operator=(RValue<UShort4> rhs) const
+       RValue<UShort4> UShort4::operator=(RValue<UShort4> rhs)
        {
                storeValue(rhs.value);
 
                return rhs;
        }
 
-       RValue<UShort4> UShort4::operator=(const UShort4 &rhs) const
+       RValue<UShort4> UShort4::operator=(const UShort4 &rhs)
        {
                Value *value = rhs.loadValue();
                storeValue(value);
@@ -3237,7 +3106,7 @@ namespace sw
                return RValue<UShort4>(value);
        }
 
-       RValue<UShort4> UShort4::operator=(const Reference<UShort4> &rhs) const
+       RValue<UShort4> UShort4::operator=(const Reference<UShort4> &rhs)
        {
                Value *value = rhs.loadValue();
                storeValue(value);
@@ -3245,14 +3114,14 @@ namespace sw
                return RValue<UShort4>(value);
        }
 
-       RValue<UShort4> UShort4::operator=(RValue<Short4> rhs) const
+       RValue<UShort4> UShort4::operator=(RValue<Short4> rhs)
        {
                storeValue(rhs.value);
 
                return RValue<UShort4>(rhs);
        }
 
-       RValue<UShort4> UShort4::operator=(const Short4 &rhs) const
+       RValue<UShort4> UShort4::operator=(const Short4 &rhs)
        {
                Value *value = rhs.loadValue();
                storeValue(value);
@@ -3260,7 +3129,7 @@ namespace sw
                return RValue<UShort4>(value);
        }
 
-       RValue<UShort4> UShort4::operator=(const Reference<Short4> &rhs) const
+       RValue<UShort4> UShort4::operator=(const Reference<Short4> &rhs)
        {
                Value *value = rhs.loadValue();
                storeValue(value);
@@ -3354,36 +3223,12 @@ namespace sw
                return x86::psrlw(lhs, rhs);
        }
 
-       RValue<UShort4> operator<<(RValue<UShort4> lhs, RValue<Long1> rhs)
-       {
-       //      return RValue<Short4>(Nucleus::createShl(lhs.value, rhs.value));
-
-               return As<UShort4>(x86::psllw(As<Short4>(lhs), rhs));
-       }
-
-       RValue<UShort4> operator>>(RValue<UShort4> lhs, RValue<Long1> rhs)
-       {
-       //      return RValue<Short4>(Nucleus::createLShr(lhs.value, rhs.value));
-
-               return x86::psrlw(lhs, rhs);
-       }
-
-       RValue<UShort4> operator<<=(const UShort4 &lhs, unsigned char rhs)
-       {
-               return lhs = lhs << rhs;
-       }
-
-       RValue<UShort4> operator>>=(const UShort4 &lhs, unsigned char rhs)
-       {
-               return lhs = lhs >> rhs;
-       }
-
-       RValue<UShort4> operator<<=(const UShort4 &lhs, RValue<Long1> rhs)
+       RValue<UShort4> operator<<=(UShort4 &lhs, unsigned char rhs)
        {
                return lhs = lhs << rhs;
        }
 
-       RValue<UShort4> operator>>=(const UShort4 &lhs, RValue<Long1> rhs)
+       RValue<UShort4> operator>>=(UShort4 &lhs, unsigned char rhs)
        {
                return lhs = lhs >> rhs;
        }
@@ -3447,6 +3292,12 @@ namespace sw
                }
        }
 
+       Short8::Short8(short c)
+       {
+               int64_t constantVector[8] = {c, c, c, c, c, c, c, c};
+               storeValue(Nucleus::createConstantVector(constantVector, getType()));
+       }
+
        Short8::Short8(short c0, short c1, short c2, short c3, short c4, short c5, short c6, short c7)
        {
                int64_t constantVector[8] = {c0, c1, c2, c3, c4, c5, c6, c7};
@@ -3525,6 +3376,12 @@ namespace sw
                return T(VectorType::get(Short::getType(), 8));
        }
 
+       UShort8::UShort8(unsigned short c)
+       {
+               int64_t constantVector[8] = {c, c, c, c, c, c, c, c};
+               storeValue(Nucleus::createConstantVector(constantVector, getType()));
+       }
+
        UShort8::UShort8(unsigned short c0, unsigned short c1, unsigned short c2, unsigned short c3, unsigned short c4, unsigned short c5, unsigned short c6, unsigned short c7)
        {
                int64_t constantVector[8] = {c0, c1, c2, c3, c4, c5, c6, c7};
@@ -3555,14 +3412,14 @@ namespace sw
                storeValue(short8);
        }
 
-       RValue<UShort8> UShort8::operator=(RValue<UShort8> rhs) const
+       RValue<UShort8> UShort8::operator=(RValue<UShort8> rhs)
        {
                storeValue(rhs.value);
 
                return rhs;
        }
 
-       RValue<UShort8> UShort8::operator=(const UShort8 &rhs) const
+       RValue<UShort8> UShort8::operator=(const UShort8 &rhs)
        {
                Value *value = rhs.loadValue();
                storeValue(value);
@@ -3570,7 +3427,7 @@ namespace sw
                return RValue<UShort8>(value);
        }
 
-       RValue<UShort8> UShort8::operator=(const Reference<UShort8> &rhs) const
+       RValue<UShort8> UShort8::operator=(const Reference<UShort8> &rhs)
        {
                Value *value = rhs.loadValue();
                storeValue(value);
@@ -3603,7 +3460,7 @@ namespace sw
                return RValue<UShort8>(Nucleus::createMul(lhs.value, rhs.value));
        }
 
-       RValue<UShort8> operator+=(const UShort8 &lhs, RValue<UShort8> rhs)
+       RValue<UShort8> operator+=(UShort8 &lhs, RValue<UShort8> rhs)
        {
                return lhs = lhs + rhs;
        }
@@ -3704,10 +3561,6 @@ namespace sw
                storeValue(integer);
        }
 
-       Int::Int()
-       {
-       }
-
        Int::Int(int x)
        {
                storeValue(Nucleus::createConstantInt(x));
@@ -3747,26 +3600,26 @@ namespace sw
                storeValue(value);
        }
 
-       RValue<Int> Int::operator=(int rhs) const
+       RValue<Int> Int::operator=(int rhs)
        {
                return RValue<Int>(storeValue(Nucleus::createConstantInt(rhs)));
        }
 
-       RValue<Int> Int::operator=(RValue<Int> rhs) const
+       RValue<Int> Int::operator=(RValue<Int> rhs)
        {
                storeValue(rhs.value);
 
                return rhs;
        }
 
-       RValue<Int> Int::operator=(RValue<UInt> rhs) const
+       RValue<Int> Int::operator=(RValue<UInt> rhs)
        {
                storeValue(rhs.value);
 
                return RValue<Int>(rhs);
        }
 
-       RValue<Int> Int::operator=(const Int &rhs) const
+       RValue<Int> Int::operator=(const Int &rhs)
        {
                Value *value = rhs.loadValue();
                storeValue(value);
@@ -3774,7 +3627,7 @@ namespace sw
                return RValue<Int>(value);
        }
 
-       RValue<Int> Int::operator=(const Reference<Int> &rhs) const
+       RValue<Int> Int::operator=(const Reference<Int> &rhs)
        {
                Value *value = rhs.loadValue();
                storeValue(value);
@@ -3782,7 +3635,7 @@ namespace sw
                return RValue<Int>(value);
        }
 
-       RValue<Int> Int::operator=(const UInt &rhs) const
+       RValue<Int> Int::operator=(const UInt &rhs)
        {
                Value *value = rhs.loadValue();
                storeValue(value);
@@ -3790,7 +3643,7 @@ namespace sw
                return RValue<Int>(value);
        }
 
-       RValue<Int> Int::operator=(const Reference<UInt> &rhs) const
+       RValue<Int> Int::operator=(const Reference<UInt> &rhs)
        {
                Value *value = rhs.loadValue();
                storeValue(value);
@@ -3848,52 +3701,52 @@ namespace sw
                return RValue<Int>(Nucleus::createAShr(lhs.value, rhs.value));
        }
 
-       RValue<Int> operator+=(const Int &lhs, RValue<Int> rhs)
+       RValue<Int> operator+=(Int &lhs, RValue<Int> rhs)
        {
                return lhs = lhs + rhs;
        }
 
-       RValue<Int> operator-=(const Int &lhs, RValue<Int> rhs)
+       RValue<Int> operator-=(Int &lhs, RValue<Int> rhs)
        {
                return lhs = lhs - rhs;
        }
 
-       RValue<Int> operator*=(const Int &lhs, RValue<Int> rhs)
+       RValue<Int> operator*=(Int &lhs, RValue<Int> rhs)
        {
                return lhs = lhs * rhs;
        }
 
-       RValue<Int> operator/=(const Int &lhs, RValue<Int> rhs)
+       RValue<Int> operator/=(Int &lhs, RValue<Int> rhs)
        {
                return lhs = lhs / rhs;
        }
 
-       RValue<Int> operator%=(const Int &lhs, RValue<Int> rhs)
+       RValue<Int> operator%=(Int &lhs, RValue<Int> rhs)
        {
                return lhs = lhs % rhs;
        }
 
-       RValue<Int> operator&=(const Int &lhs, RValue<Int> rhs)
+       RValue<Int> operator&=(Int &lhs, RValue<Int> rhs)
        {
                return lhs = lhs & rhs;
        }
 
-       RValue<Int> operator|=(const Int &lhs, RValue<Int> rhs)
+       RValue<Int> operator|=(Int &lhs, RValue<Int> rhs)
        {
                return lhs = lhs | rhs;
        }
 
-       RValue<Int> operator^=(const Int &lhs, RValue<Int> rhs)
+       RValue<Int> operator^=(Int &lhs, RValue<Int> rhs)
        {
                return lhs = lhs ^ rhs;
        }
 
-       RValue<Int> operator<<=(const Int &lhs, RValue<Int> rhs)
+       RValue<Int> operator<<=(Int &lhs, RValue<Int> rhs)
        {
                return lhs = lhs << rhs;
        }
 
-       RValue<Int> operator>>=(const Int &lhs, RValue<Int> rhs)
+       RValue<Int> operator>>=(Int &lhs, RValue<Int> rhs)
        {
                return lhs = lhs >> rhs;
        }
@@ -3913,7 +3766,7 @@ namespace sw
                return RValue<Int>(Nucleus::createNot(val.value));
        }
 
-       RValue<Int> operator++(const Int &val, int)   // Post-increment
+       RValue<Int> operator++(Int &val, int)   // Post-increment
        {
                RValue<Int> res = val;
 
@@ -3923,7 +3776,7 @@ namespace sw
                return res;
        }
 
-       const Int &operator++(const Int &val)   // Pre-increment
+       const Int &operator++(Int &val)   // Pre-increment
        {
                Value *inc = Nucleus::createAdd(val.loadValue(), V(Nucleus::createConstantInt(1)));
                val.storeValue(inc);
@@ -3931,7 +3784,7 @@ namespace sw
                return val;
        }
 
-       RValue<Int> operator--(const Int &val, int)   // Post-decrement
+       RValue<Int> operator--(Int &val, int)   // Post-decrement
        {
                RValue<Int> res = val;
 
@@ -3941,7 +3794,7 @@ namespace sw
                return res;
        }
 
-       const Int &operator--(const Int &val)   // Pre-decrement
+       const Int &operator--(Int &val)   // Pre-decrement
        {
                Value *inc = Nucleus::createSub(val.loadValue(), V(Nucleus::createConstantInt(1)));
                val.storeValue(inc);
@@ -4020,28 +3873,24 @@ namespace sw
                storeValue(integer);
        }
 
-       Long::Long()
-       {
-       }
-
        Long::Long(RValue<Long> rhs)
        {
                storeValue(rhs.value);
        }
 
-       RValue<Long> Long::operator=(int64_t rhs) const
+       RValue<Long> Long::operator=(int64_t rhs)
        {
                return RValue<Long>(storeValue(Nucleus::createConstantLong(rhs)));
        }
 
-       RValue<Long> Long::operator=(RValue<Long> rhs) const
+       RValue<Long> Long::operator=(RValue<Long> rhs)
        {
                storeValue(rhs.value);
 
                return rhs;
        }
 
-       RValue<Long> Long::operator=(const Long &rhs) const
+       RValue<Long> Long::operator=(const Long &rhs)
        {
                Value *value = rhs.loadValue();
                storeValue(value);
@@ -4049,7 +3898,7 @@ namespace sw
                return RValue<Long>(value);
        }
 
-       RValue<Long> Long::operator=(const Reference<Long> &rhs) const
+       RValue<Long> Long::operator=(const Reference<Long> &rhs)
        {
                Value *value = rhs.loadValue();
                storeValue(value);
@@ -4067,12 +3916,12 @@ namespace sw
                return RValue<Long>(Nucleus::createSub(lhs.value, rhs.value));
        }
 
-       RValue<Long> operator+=(const Long &lhs, RValue<Long> rhs)
+       RValue<Long> operator+=(Long &lhs, RValue<Long> rhs)
        {
                return lhs = lhs + rhs;
        }
 
-       RValue<Long> operator-=(const Long &lhs, RValue<Long> rhs)
+       RValue<Long> operator-=(Long &lhs, RValue<Long> rhs)
        {
                return lhs = lhs - rhs;
        }
@@ -4087,31 +3936,6 @@ namespace sw
                return T(llvm::Type::getInt64Ty(*::context));
        }
 
-       Long1::Long1(const RValue<UInt> cast)
-       {
-               Value *undefCast = Nucleus::createInsertElement(V(UndefValue::get(VectorType::get(Int::getType(), 2))), cast.value, 0);
-               Value *zeroCast = Nucleus::createInsertElement(undefCast, V(Nucleus::createConstantInt(0)), 1);
-
-               storeValue(Nucleus::createBitCast(zeroCast, Long1::getType()));
-       }
-
-       Long1::Long1(RValue<Long1> rhs)
-       {
-               storeValue(rhs.value);
-       }
-
-       Type *Long1::getType()
-       {
-               if(CPUID::supportsMMX2())
-               {
-                       return MMX::getType();
-               }
-               else
-               {
-                       return T(VectorType::get(Long::getType(), 1));
-               }
-       }
-
        UInt::UInt(Argument<UInt> argument)
        {
                storeValue(argument.value);
@@ -4150,10 +3974,6 @@ namespace sw
                                Int(cast))).value);
        }
 
-       UInt::UInt()
-       {
-       }
-
        UInt::UInt(int x)
        {
                storeValue(Nucleus::createConstantInt(x));
@@ -4198,26 +4018,26 @@ namespace sw
                storeValue(value);
        }
 
-       RValue<UInt> UInt::operator=(unsigned int rhs) const
+       RValue<UInt> UInt::operator=(unsigned int rhs)
        {
                return RValue<UInt>(storeValue(Nucleus::createConstantInt(rhs)));
        }
 
-       RValue<UInt> UInt::operator=(RValue<UInt> rhs) const
+       RValue<UInt> UInt::operator=(RValue<UInt> rhs)
        {
                storeValue(rhs.value);
 
                return rhs;
        }
 
-       RValue<UInt> UInt::operator=(RValue<Int> rhs) const
+       RValue<UInt> UInt::operator=(RValue<Int> rhs)
        {
                storeValue(rhs.value);
 
                return RValue<UInt>(rhs);
        }
 
-       RValue<UInt> UInt::operator=(const UInt &rhs) const
+       RValue<UInt> UInt::operator=(const UInt &rhs)
        {
                Value *value = rhs.loadValue();
                storeValue(value);
@@ -4225,7 +4045,7 @@ namespace sw
                return RValue<UInt>(value);
        }
 
-       RValue<UInt> UInt::operator=(const Reference<UInt> &rhs) const
+       RValue<UInt> UInt::operator=(const Reference<UInt> &rhs)
        {
                Value *value = rhs.loadValue();
                storeValue(value);
@@ -4233,7 +4053,7 @@ namespace sw
                return RValue<UInt>(value);
        }
 
-       RValue<UInt> UInt::operator=(const Int &rhs) const
+       RValue<UInt> UInt::operator=(const Int &rhs)
        {
                Value *value = rhs.loadValue();
                storeValue(value);
@@ -4241,7 +4061,7 @@ namespace sw
                return RValue<UInt>(value);
        }
 
-       RValue<UInt> UInt::operator=(const Reference<Int> &rhs) const
+       RValue<UInt> UInt::operator=(const Reference<Int> &rhs)
        {
                Value *value = rhs.loadValue();
                storeValue(value);
@@ -4299,52 +4119,52 @@ namespace sw
                return RValue<UInt>(Nucleus::createLShr(lhs.value, rhs.value));
        }
 
-       RValue<UInt> operator+=(const UInt &lhs, RValue<UInt> rhs)
+       RValue<UInt> operator+=(UInt &lhs, RValue<UInt> rhs)
        {
                return lhs = lhs + rhs;
        }
 
-       RValue<UInt> operator-=(const UInt &lhs, RValue<UInt> rhs)
+       RValue<UInt> operator-=(UInt &lhs, RValue<UInt> rhs)
        {
                return lhs = lhs - rhs;
        }
 
-       RValue<UInt> operator*=(const UInt &lhs, RValue<UInt> rhs)
+       RValue<UInt> operator*=(UInt &lhs, RValue<UInt> rhs)
        {
                return lhs = lhs * rhs;
        }
 
-       RValue<UInt> operator/=(const UInt &lhs, RValue<UInt> rhs)
+       RValue<UInt> operator/=(UInt &lhs, RValue<UInt> rhs)
        {
                return lhs = lhs / rhs;
        }
 
-       RValue<UInt> operator%=(const UInt &lhs, RValue<UInt> rhs)
+       RValue<UInt> operator%=(UInt &lhs, RValue<UInt> rhs)
        {
                return lhs = lhs % rhs;
        }
 
-       RValue<UInt> operator&=(const UInt &lhs, RValue<UInt> rhs)
+       RValue<UInt> operator&=(UInt &lhs, RValue<UInt> rhs)
        {
                return lhs = lhs & rhs;
        }
 
-       RValue<UInt> operator|=(const UInt &lhs, RValue<UInt> rhs)
+       RValue<UInt> operator|=(UInt &lhs, RValue<UInt> rhs)
        {
                return lhs = lhs | rhs;
        }
 
-       RValue<UInt> operator^=(const UInt &lhs, RValue<UInt> rhs)
+       RValue<UInt> operator^=(UInt &lhs, RValue<UInt> rhs)
        {
                return lhs = lhs ^ rhs;
        }
 
-       RValue<UInt> operator<<=(const UInt &lhs, RValue<UInt> rhs)
+       RValue<UInt> operator<<=(UInt &lhs, RValue<UInt> rhs)
        {
                return lhs = lhs << rhs;
        }
 
-       RValue<UInt> operator>>=(const UInt &lhs, RValue<UInt> rhs)
+       RValue<UInt> operator>>=(UInt &lhs, RValue<UInt> rhs)
        {
                return lhs = lhs >> rhs;
        }
@@ -4364,7 +4184,7 @@ namespace sw
                return RValue<UInt>(Nucleus::createNot(val.value));
        }
 
-       RValue<UInt> operator++(const UInt &val, int)   // Post-increment
+       RValue<UInt> operator++(UInt &val, int)   // Post-increment
        {
                RValue<UInt> res = val;
 
@@ -4374,7 +4194,7 @@ namespace sw
                return res;
        }
 
-       const UInt &operator++(const UInt &val)   // Pre-increment
+       const UInt &operator++(UInt &val)   // Pre-increment
        {
                Value *inc = Nucleus::createAdd(val.loadValue(), V(Nucleus::createConstantInt(1)));
                val.storeValue(inc);
@@ -4382,7 +4202,7 @@ namespace sw
                return val;
        }
 
-       RValue<UInt> operator--(const UInt &val, int)   // Post-decrement
+       RValue<UInt> operator--(UInt &val, int)   // Post-decrement
        {
                RValue<UInt> res = val;
 
@@ -4392,7 +4212,7 @@ namespace sw
                return res;
        }
 
-       const UInt &operator--(const UInt &val)   // Pre-decrement
+       const UInt &operator--(UInt &val)   // Pre-decrement
        {
                Value *inc = Nucleus::createSub(val.loadValue(), V(Nucleus::createConstantInt(1)));
                val.storeValue(inc);
@@ -4477,15 +4297,8 @@ namespace sw
                storeValue(int2);
        }
 
-       Int2::Int2()
-       {
-       //      xy.parent = this;
-       }
-
        Int2::Int2(int x, int y)
        {
-       //      xy.parent = this;
-
                int64_t constantVector[2] = {x, y};
                Value *vector = V(Nucleus::createConstantVector(constantVector, T(VectorType::get(Int::getType(), 2))));
 
@@ -4494,23 +4307,17 @@ namespace sw
 
        Int2::Int2(RValue<Int2> rhs)
        {
-       //      xy.parent = this;
-
                storeValue(rhs.value);
        }
 
        Int2::Int2(const Int2 &rhs)
        {
-       //      xy.parent = this;
-
                Value *value = rhs.loadValue();
                storeValue(value);
        }
 
        Int2::Int2(const Reference<Int2> &rhs)
        {
-       //      xy.parent = this;
-
                Value *value = rhs.loadValue();
                storeValue(value);
        }
@@ -4522,7 +4329,13 @@ namespace sw
                        // movd mm0, lo
                        // movd mm1, hi
                        // punpckldq mm0, mm1
-                       storeValue(As<Int2>(UnpackLow(As<Int2>(Long1(RValue<UInt>(lo))), As<Int2>(Long1(RValue<UInt>(hi))))).value);
+
+                       Value *loLong = Nucleus::createInsertElement(V(UndefValue::get(VectorType::get(Int::getType(), 2))), lo.value, 0);
+                       loLong = Nucleus::createInsertElement(loLong, V(ConstantInt::get(Int::getType(), 0)), 1);
+                       Value *hiLong = Nucleus::createInsertElement(V(UndefValue::get(VectorType::get(Int::getType(), 2))), hi.value, 0);
+                       hiLong = Nucleus::createInsertElement(hiLong, V(ConstantInt::get(Int::getType(), 0)), 1);
+
+                       storeValue(As<Int2>(UnpackLow(As<Int2>(loLong), As<Int2>(hiLong))).value);
                }
                else
                {
@@ -4533,14 +4346,14 @@ namespace sw
                }
        }
 
-       RValue<Int2> Int2::operator=(RValue<Int2> rhs) const
+       RValue<Int2> Int2::operator=(RValue<Int2> rhs)
        {
                storeValue(rhs.value);
 
                return rhs;
        }
 
-       RValue<Int2> Int2::operator=(const Int2 &rhs) const
+       RValue<Int2> Int2::operator=(const Int2 &rhs)
        {
                Value *value = rhs.loadValue();
                storeValue(value);
@@ -4548,7 +4361,7 @@ namespace sw
                return RValue<Int2>(value);
        }
 
-       RValue<Int2> Int2::operator=(const Reference<Int2> &rhs) const
+       RValue<Int2> Int2::operator=(const Reference<Int2> &rhs)
        {
                Value *value = rhs.loadValue();
                storeValue(value);
@@ -4645,76 +4458,52 @@ namespace sw
                return x86::psrad(lhs, rhs);
        }
 
-       RValue<Int2> operator<<(RValue<Int2> lhs, RValue<Long1> rhs)
-       {
-       //      return RValue<Int2>(Nucleus::createShl(lhs.value, rhs.value));
-
-               return x86::pslld(lhs, rhs);
-       }
-
-       RValue<Int2> operator>>(RValue<Int2> lhs, RValue<Long1> rhs)
-       {
-       //      return RValue<Int2>(Nucleus::createAShr(lhs.value, rhs.value));
-
-               return x86::psrad(lhs, rhs);
-       }
-
-       RValue<Int2> operator+=(const Int2 &lhs, RValue<Int2> rhs)
+       RValue<Int2> operator+=(Int2 &lhs, RValue<Int2> rhs)
        {
                return lhs = lhs + rhs;
        }
 
-       RValue<Int2> operator-=(const Int2 &lhs, RValue<Int2> rhs)
+       RValue<Int2> operator-=(Int2 &lhs, RValue<Int2> rhs)
        {
                return lhs = lhs - rhs;
        }
 
-//     RValue<Int2> operator*=(const Int2 &lhs, RValue<Int2> rhs)
+//     RValue<Int2> operator*=(Int2 &lhs, RValue<Int2> rhs)
 //     {
 //             return lhs = lhs * rhs;
 //     }
 
-//     RValue<Int2> operator/=(const Int2 &lhs, RValue<Int2> rhs)
+//     RValue<Int2> operator/=(Int2 &lhs, RValue<Int2> rhs)
 //     {
 //             return lhs = lhs / rhs;
 //     }
 
-//     RValue<Int2> operator%=(const Int2 &lhs, RValue<Int2> rhs)
+//     RValue<Int2> operator%=(Int2 &lhs, RValue<Int2> rhs)
 //     {
 //             return lhs = lhs % rhs;
 //     }
 
-       RValue<Int2> operator&=(const Int2 &lhs, RValue<Int2> rhs)
+       RValue<Int2> operator&=(Int2 &lhs, RValue<Int2> rhs)
        {
                return lhs = lhs & rhs;
        }
 
-       RValue<Int2> operator|=(const Int2 &lhs, RValue<Int2> rhs)
+       RValue<Int2> operator|=(Int2 &lhs, RValue<Int2> rhs)
        {
                return lhs = lhs | rhs;
        }
 
-       RValue<Int2> operator^=(const Int2 &lhs, RValue<Int2> rhs)
+       RValue<Int2> operator^=(Int2 &lhs, RValue<Int2> rhs)
        {
                return lhs = lhs ^ rhs;
        }
 
-       RValue<Int2> operator<<=(const Int2 &lhs, unsigned char rhs)
+       RValue<Int2> operator<<=(Int2 &lhs, unsigned char rhs)
        {
                return lhs = lhs << rhs;
        }
 
-       RValue<Int2> operator>>=(const Int2 &lhs, unsigned char rhs)
-       {
-               return lhs = lhs >> rhs;
-       }
-
-       RValue<Int2> operator<<=(const Int2 &lhs, RValue<Long1> rhs)
-       {
-               return lhs = lhs << rhs;
-       }
-
-       RValue<Int2> operator>>=(const Int2 &lhs, RValue<Long1> rhs)
+       RValue<Int2> operator>>=(Int2 &lhs, unsigned char rhs)
        {
                return lhs = lhs >> rhs;
        }
@@ -4741,7 +4530,7 @@ namespace sw
                }
        }
 
-       RValue<Long1> UnpackLow(RValue<Int2> x, RValue<Int2> y)
+       RValue<Short4> UnpackLow(RValue<Int2> x, RValue<Int2> y)
        {
                if(CPUID::supportsMMX2())
                {
@@ -4752,11 +4541,11 @@ namespace sw
                        int shuffle[2] = {0, 2};
                        Value *packed = Nucleus::createShuffleVector(x.value, y.value, shuffle);
 
-                       return RValue<Long1>(Nucleus::createBitCast(packed, Long1::getType()));
+                       return As<Short4>(packed);
                }
        }
 
-       RValue<Long1> UnpackHigh(RValue<Int2> x, RValue<Int2> y)
+       RValue<Short4> UnpackHigh(RValue<Int2> x, RValue<Int2> y)
        {
                if(CPUID::supportsMMX2())
                {
@@ -4767,7 +4556,7 @@ namespace sw
                        int shuffle[2] = {1, 3};
                        Value *packed = Nucleus::createShuffleVector(x.value, y.value, shuffle);
 
-                       return RValue<Long1>(Nucleus::createBitCast(packed, Long1::getType()));
+                       return As<Short4>(packed);
                }
        }
 
@@ -4809,15 +4598,8 @@ namespace sw
                }
        }
 
-       UInt2::UInt2()
-       {
-       //      xy.parent = this;
-       }
-
        UInt2::UInt2(unsigned int x, unsigned int y)
        {
-       //      xy.parent = this;
-
                int64_t constantVector[2] = {x, y};
                Value *vector = V(Nucleus::createConstantVector(constantVector, T(VectorType::get(UInt::getType(), 2))));
 
@@ -4826,35 +4608,29 @@ namespace sw
 
        UInt2::UInt2(RValue<UInt2> rhs)
        {
-       //      xy.parent = this;
-
                storeValue(rhs.value);
        }
 
        UInt2::UInt2(const UInt2 &rhs)
        {
-       //      xy.parent = this;
-
                Value *value = rhs.loadValue();
                storeValue(value);
        }
 
        UInt2::UInt2(const Reference<UInt2> &rhs)
        {
-       //      xy.parent = this;
-
                Value *value = rhs.loadValue();
                storeValue(value);
        }
 
-       RValue<UInt2> UInt2::operator=(RValue<UInt2> rhs) const
+       RValue<UInt2> UInt2::operator=(RValue<UInt2> rhs)
        {
                storeValue(rhs.value);
 
                return rhs;
        }
 
-       RValue<UInt2> UInt2::operator=(const UInt2 &rhs) const
+       RValue<UInt2> UInt2::operator=(const UInt2 &rhs)
        {
                Value *value = rhs.loadValue();
                storeValue(value);
@@ -4862,7 +4638,7 @@ namespace sw
                return RValue<UInt2>(value);
        }
 
-       RValue<UInt2> UInt2::operator=(const Reference<UInt2> &rhs) const
+       RValue<UInt2> UInt2::operator=(const Reference<UInt2> &rhs)
        {
                Value *value = rhs.loadValue();
                storeValue(value);
@@ -4959,76 +4735,52 @@ namespace sw
                return x86::psrld(lhs, rhs);
        }
 
-       RValue<UInt2> operator<<(RValue<UInt2> lhs, RValue<Long1> rhs)
-       {
-       //      return RValue<UInt2>(Nucleus::createShl(lhs.value, rhs.value));
-
-               return As<UInt2>(x86::pslld(As<Int2>(lhs), rhs));
-       }
-
-       RValue<UInt2> operator>>(RValue<UInt2> lhs, RValue<Long1> rhs)
-       {
-       //      return RValue<UInt2>(Nucleus::createLShr(lhs.value, rhs.value));
-
-               return x86::psrld(lhs, rhs);
-       }
-
-       RValue<UInt2> operator+=(const UInt2 &lhs, RValue<UInt2> rhs)
+       RValue<UInt2> operator+=(UInt2 &lhs, RValue<UInt2> rhs)
        {
                return lhs = lhs + rhs;
        }
 
-       RValue<UInt2> operator-=(const UInt2 &lhs, RValue<UInt2> rhs)
+       RValue<UInt2> operator-=(UInt2 &lhs, RValue<UInt2> rhs)
        {
                return lhs = lhs - rhs;
        }
 
-//     RValue<UInt2> operator*=(const UInt2 &lhs, RValue<UInt2> rhs)
+//     RValue<UInt2> operator*=(UInt2 &lhs, RValue<UInt2> rhs)
 //     {
 //             return lhs = lhs * rhs;
 //     }
 
-//     RValue<UInt2> operator/=(const UInt2 &lhs, RValue<UInt2> rhs)
+//     RValue<UInt2> operator/=(UInt2 &lhs, RValue<UInt2> rhs)
 //     {
 //             return lhs = lhs / rhs;
 //     }
 
-//     RValue<UInt2> operator%=(const UInt2 &lhs, RValue<UInt2> rhs)
+//     RValue<UInt2> operator%=(UInt2 &lhs, RValue<UInt2> rhs)
 //     {
 //             return lhs = lhs % rhs;
 //     }
 
-       RValue<UInt2> operator&=(const UInt2 &lhs, RValue<UInt2> rhs)
+       RValue<UInt2> operator&=(UInt2 &lhs, RValue<UInt2> rhs)
        {
                return lhs = lhs & rhs;
        }
 
-       RValue<UInt2> operator|=(const UInt2 &lhs, RValue<UInt2> rhs)
+       RValue<UInt2> operator|=(UInt2 &lhs, RValue<UInt2> rhs)
        {
                return lhs = lhs | rhs;
        }
 
-       RValue<UInt2> operator^=(const UInt2 &lhs, RValue<UInt2> rhs)
+       RValue<UInt2> operator^=(UInt2 &lhs, RValue<UInt2> rhs)
        {
                return lhs = lhs ^ rhs;
        }
 
-       RValue<UInt2> operator<<=(const UInt2 &lhs, unsigned char rhs)
-       {
-               return lhs = lhs << rhs;
-       }
-
-       RValue<UInt2> operator>>=(const UInt2 &lhs, unsigned char rhs)
-       {
-               return lhs = lhs >> rhs;
-       }
-
-       RValue<UInt2> operator<<=(const UInt2 &lhs, RValue<Long1> rhs)
+       RValue<UInt2> operator<<=(UInt2 &lhs, unsigned char rhs)
        {
                return lhs = lhs << rhs;
        }
 
-       RValue<UInt2> operator>>=(const UInt2 &lhs, RValue<Long1> rhs)
+       RValue<UInt2> operator>>=(UInt2 &lhs, unsigned char rhs)
        {
                return lhs = lhs >> rhs;
        }
@@ -5124,8 +4876,6 @@ namespace sw
 
        Int4::Int4(RValue<Float4> cast)
        {
-       //      xyzw.parent = this;
-
                Value *xyzw = Nucleus::createFPToSI(cast.value, Int4::getType());
 
                storeValue(xyzw);
@@ -5153,7 +4903,7 @@ namespace sw
 
                        // Each Short is packed into each Int in the (Short | Short) format.
                        // Shifting by 16 will retrieve the original Short value.
-                       // Shitfing an Int will propagate the sign bit, which will work
+                       // Shifting an Int will propagate the sign bit, which will work
                        // for both positive and negative values of a Short.
                        *this >>= 16;
                }
@@ -5181,11 +4931,6 @@ namespace sw
                }
        }
 
-       Int4::Int4()
-       {
-       //      xyzw.parent = this;
-       }
-
        Int4::Int4(int xyzw)
        {
                constant(xyzw, xyzw, xyzw, xyzw);
@@ -5208,62 +4953,46 @@ namespace sw
 
        void Int4::constant(int x, int y, int z, int w)
        {
-       //      xyzw.parent = this;
-
                int64_t constantVector[4] = {x, y, z, w};
                storeValue(Nucleus::createConstantVector(constantVector, getType()));
        }
 
        Int4::Int4(RValue<Int4> rhs)
        {
-       //      xyzw.parent = this;
-
                storeValue(rhs.value);
        }
 
        Int4::Int4(const Int4 &rhs)
        {
-       //      xyzw.parent = this;
-
                Value *value = rhs.loadValue();
                storeValue(value);
        }
 
        Int4::Int4(const Reference<Int4> &rhs)
        {
-       //      xyzw.parent = this;
-
                Value *value = rhs.loadValue();
                storeValue(value);
        }
 
        Int4::Int4(RValue<UInt4> rhs)
        {
-       //      xyzw.parent = this;
-
                storeValue(rhs.value);
        }
 
        Int4::Int4(const UInt4 &rhs)
        {
-       //      xyzw.parent = this;
-
                Value *value = rhs.loadValue();
                storeValue(value);
        }
 
        Int4::Int4(const Reference<UInt4> &rhs)
        {
-       //      xyzw.parent = this;
-
                Value *value = rhs.loadValue();
                storeValue(value);
        }
 
        Int4::Int4(RValue<Int2> lo, RValue<Int2> hi)
        {
-       //      xyzw.parent = this;
-
                Value *loLong = Nucleus::createBitCast(lo.value, Long::getType());
                Value *hiLong = Nucleus::createBitCast(hi.value, Long::getType());
 
@@ -5277,8 +5006,6 @@ namespace sw
 
        Int4::Int4(RValue<Int> rhs)
        {
-       //      xyzw.parent = this;
-
                Value *vector = loadValue();
                Value *insert = Nucleus::createInsertElement(vector, rhs.value, 0);
 
@@ -5290,26 +5017,22 @@ namespace sw
 
        Int4::Int4(const Int &rhs)
        {
-       //      xyzw.parent = this;
-
                *this = RValue<Int>(rhs.loadValue());
        }
 
        Int4::Int4(const Reference<Int> &rhs)
        {
-       //      xyzw.parent = this;
-
                *this = RValue<Int>(rhs.loadValue());
        }
 
-       RValue<Int4> Int4::operator=(RValue<Int4> rhs) const
+       RValue<Int4> Int4::operator=(RValue<Int4> rhs)
        {
                storeValue(rhs.value);
 
                return rhs;
        }
 
-       RValue<Int4> Int4::operator=(const Int4 &rhs) const
+       RValue<Int4> Int4::operator=(const Int4 &rhs)
        {
                Value *value = rhs.loadValue();
                storeValue(value);
@@ -5317,7 +5040,7 @@ namespace sw
                return RValue<Int4>(value);
        }
 
-       RValue<Int4> Int4::operator=(const Reference<Int4> &rhs) const
+       RValue<Int4> Int4::operator=(const Reference<Int4> &rhs)
        {
                Value *value = rhs.loadValue();
                storeValue(value);
@@ -5385,52 +5108,52 @@ namespace sw
                return RValue<Int4>(Nucleus::createAShr(lhs.value, rhs.value));
        }
 
-       RValue<Int4> operator+=(const Int4 &lhs, RValue<Int4> rhs)
+       RValue<Int4> operator+=(Int4 &lhs, RValue<Int4> rhs)
        {
                return lhs = lhs + rhs;
        }
 
-       RValue<Int4> operator-=(const Int4 &lhs, RValue<Int4> rhs)
+       RValue<Int4> operator-=(Int4 &lhs, RValue<Int4> rhs)
        {
                return lhs = lhs - rhs;
        }
 
-       RValue<Int4> operator*=(const Int4 &lhs, RValue<Int4> rhs)
+       RValue<Int4> operator*=(Int4 &lhs, RValue<Int4> rhs)
        {
                return lhs = lhs * rhs;
        }
 
-//     RValue<Int4> operator/=(const Int4 &lhs, RValue<Int4> rhs)
+//     RValue<Int4> operator/=(Int4 &lhs, RValue<Int4> rhs)
 //     {
 //             return lhs = lhs / rhs;
 //     }
 
-//     RValue<Int4> operator%=(const Int4 &lhs, RValue<Int4> rhs)
+//     RValue<Int4> operator%=(Int4 &lhs, RValue<Int4> rhs)
 //     {
 //             return lhs = lhs % rhs;
 //     }
 
-       RValue<Int4> operator&=(const Int4 &lhs, RValue<Int4> rhs)
+       RValue<Int4> operator&=(Int4 &lhs, RValue<Int4> rhs)
        {
                return lhs = lhs & rhs;
        }
 
-       RValue<Int4> operator|=(const Int4 &lhs, RValue<Int4> rhs)
+       RValue<Int4> operator|=(Int4 &lhs, RValue<Int4> rhs)
        {
                return lhs = lhs | rhs;
        }
 
-       RValue<Int4> operator^=(const Int4 &lhs, RValue<Int4> rhs)
+       RValue<Int4> operator^=(Int4 &lhs, RValue<Int4> rhs)
        {
                return lhs = lhs ^ rhs;
        }
 
-       RValue<Int4> operator<<=(const Int4 &lhs, unsigned char rhs)
+       RValue<Int4> operator<<=(Int4 &lhs, unsigned char rhs)
        {
                return lhs = lhs << rhs;
        }
 
-       RValue<Int4> operator>>=(const Int4 &lhs, unsigned char rhs)
+       RValue<Int4> operator>>=(Int4 &lhs, unsigned char rhs)
        {
                return lhs = lhs >> rhs;
        }
@@ -5498,7 +5221,7 @@ namespace sw
                else
                {
                        RValue<Int4> greater = CmpNLE(x, y);
-                       return x & greater | y & ~greater;
+                       return (x & greater) | (y & ~greater);
                }
        }
 
@@ -5511,7 +5234,7 @@ namespace sw
                else
                {
                        RValue<Int4> less = CmpLT(x, y);
-                       return x & less | y & ~less;
+                       return (x & less) | (y & ~less);
                }
        }
 
@@ -5552,8 +5275,6 @@ namespace sw
 
        UInt4::UInt4(RValue<Float4> cast)
        {
-       //      xyzw.parent = this;
-
                // Note: createFPToUI is broken, must perform conversion using createFPtoSI
                // Value *xyzw = Nucleus::createFPToUI(cast.value, UInt4::getType());
 
@@ -5571,11 +5292,6 @@ namespace sw
                storeValue((~(As<Int4>(cast) >> 31) & uiValue).value);
        }
 
-       UInt4::UInt4()
-       {
-       //      xyzw.parent = this;
-       }
-
        UInt4::UInt4(int xyzw)
        {
                constant(xyzw, xyzw, xyzw, xyzw);
@@ -5598,54 +5314,40 @@ namespace sw
 
        void UInt4::constant(int x, int y, int z, int w)
        {
-       //      xyzw.parent = this;
-
                int64_t constantVector[4] = {x, y, z, w};
                storeValue(Nucleus::createConstantVector(constantVector, getType()));
        }
 
        UInt4::UInt4(RValue<UInt4> rhs)
        {
-       //      xyzw.parent = this;
-
                storeValue(rhs.value);
        }
 
        UInt4::UInt4(const UInt4 &rhs)
        {
-       //      xyzw.parent = this;
-
                Value *value = rhs.loadValue();
                storeValue(value);
        }
 
        UInt4::UInt4(const Reference<UInt4> &rhs)
        {
-       //      xyzw.parent = this;
-
                Value *value = rhs.loadValue();
                storeValue(value);
        }
 
        UInt4::UInt4(RValue<Int4> rhs)
        {
-       //      xyzw.parent = this;
-
                storeValue(rhs.value);
        }
 
        UInt4::UInt4(const Int4 &rhs)
        {
-       //      xyzw.parent = this;
-
                Value *value = rhs.loadValue();
                storeValue(value);
        }
 
        UInt4::UInt4(const Reference<Int4> &rhs)
        {
-       //      xyzw.parent = this;
-
                Value *value = rhs.loadValue();
                storeValue(value);
        }
@@ -5663,14 +5365,14 @@ namespace sw
                storeValue(uint4);
        }
 
-       RValue<UInt4> UInt4::operator=(RValue<UInt4> rhs) const
+       RValue<UInt4> UInt4::operator=(RValue<UInt4> rhs)
        {
                storeValue(rhs.value);
 
                return rhs;
        }
 
-       RValue<UInt4> UInt4::operator=(const UInt4 &rhs) const
+       RValue<UInt4> UInt4::operator=(const UInt4 &rhs)
        {
                Value *value = rhs.loadValue();
                storeValue(value);
@@ -5678,7 +5380,7 @@ namespace sw
                return RValue<UInt4>(value);
        }
 
-       RValue<UInt4> UInt4::operator=(const Reference<UInt4> &rhs) const
+       RValue<UInt4> UInt4::operator=(const Reference<UInt4> &rhs)
        {
                Value *value = rhs.loadValue();
                storeValue(value);
@@ -5746,52 +5448,52 @@ namespace sw
                return RValue<UInt4>(Nucleus::createLShr(lhs.value, rhs.value));
        }
 
-       RValue<UInt4> operator+=(const UInt4 &lhs, RValue<UInt4> rhs)
+       RValue<UInt4> operator+=(UInt4 &lhs, RValue<UInt4> rhs)
        {
                return lhs = lhs + rhs;
        }
 
-       RValue<UInt4> operator-=(const UInt4 &lhs, RValue<UInt4> rhs)
+       RValue<UInt4> operator-=(UInt4 &lhs, RValue<UInt4> rhs)
        {
                return lhs = lhs - rhs;
        }
 
-       RValue<UInt4> operator*=(const UInt4 &lhs, RValue<UInt4> rhs)
+       RValue<UInt4> operator*=(UInt4 &lhs, RValue<UInt4> rhs)
        {
                return lhs = lhs * rhs;
        }
 
-//     RValue<UInt4> operator/=(const UInt4 &lhs, RValue<UInt4> rhs)
+//     RValue<UInt4> operator/=(UInt4 &lhs, RValue<UInt4> rhs)
 //     {
 //             return lhs = lhs / rhs;
 //     }
 
-//     RValue<UInt4> operator%=(const UInt4 &lhs, RValue<UInt4> rhs)
+//     RValue<UInt4> operator%=(UInt4 &lhs, RValue<UInt4> rhs)
 //     {
 //             return lhs = lhs % rhs;
 //     }
 
-       RValue<UInt4> operator&=(const UInt4 &lhs, RValue<UInt4> rhs)
+       RValue<UInt4> operator&=(UInt4 &lhs, RValue<UInt4> rhs)
        {
                return lhs = lhs & rhs;
        }
 
-       RValue<UInt4> operator|=(const UInt4 &lhs, RValue<UInt4> rhs)
+       RValue<UInt4> operator|=(UInt4 &lhs, RValue<UInt4> rhs)
        {
                return lhs = lhs | rhs;
        }
 
-       RValue<UInt4> operator^=(const UInt4 &lhs, RValue<UInt4> rhs)
+       RValue<UInt4> operator^=(UInt4 &lhs, RValue<UInt4> rhs)
        {
                return lhs = lhs ^ rhs;
        }
 
-       RValue<UInt4> operator<<=(const UInt4 &lhs, unsigned char rhs)
+       RValue<UInt4> operator<<=(UInt4 &lhs, unsigned char rhs)
        {
                return lhs = lhs << rhs;
        }
 
-       RValue<UInt4> operator>>=(const UInt4 &lhs, unsigned char rhs)
+       RValue<UInt4> operator>>=(UInt4 &lhs, unsigned char rhs)
        {
                return lhs = lhs >> rhs;
        }
@@ -5859,7 +5561,7 @@ namespace sw
                else
                {
                        RValue<UInt4> greater = CmpNLE(x, y);
-                       return x & greater | y & ~greater;
+                       return (x & greater) | (y & ~greater);
                }
        }
 
@@ -5872,13 +5574,13 @@ namespace sw
                else
                {
                        RValue<UInt4> less = CmpLT(x, y);
-                       return x & less | y & ~less;
+                       return (x & less) | (y & ~less);
                }
        }
 
        RValue<UShort8> Pack(RValue<UInt4> x, RValue<UInt4> y)
        {
-               return x86::packusdw(x, y);   // FIXME: Fallback required
+               return x86::packusdw(As<Int4>(x), As<Int4>(y));
        }
 
        Type *UInt4::getType()
@@ -5893,11 +5595,6 @@ namespace sw
                storeValue(integer);
        }
 
-       Float::Float()
-       {
-
-       }
-
        Float::Float(float x)
        {
                storeValue(Nucleus::createConstantFloat(x));
@@ -5920,14 +5617,14 @@ namespace sw
                storeValue(value);
        }
 
-       RValue<Float> Float::operator=(RValue<Float> rhs) const
+       RValue<Float> Float::operator=(RValue<Float> rhs)
        {
                storeValue(rhs.value);
 
                return rhs;
        }
 
-       RValue<Float> Float::operator=(const Float &rhs) const
+       RValue<Float> Float::operator=(const Float &rhs)
        {
                Value *value = rhs.loadValue();
                storeValue(value);
@@ -5935,7 +5632,7 @@ namespace sw
                return RValue<Float>(value);
        }
 
-       RValue<Float> Float::operator=(const Reference<Float> &rhs) const
+       RValue<Float> Float::operator=(const Reference<Float> &rhs)
        {
                Value *value = rhs.loadValue();
                storeValue(value);
@@ -5963,22 +5660,22 @@ namespace sw
                return RValue<Float>(Nucleus::createFDiv(lhs.value, rhs.value));
        }
 
-       RValue<Float> operator+=(const Float &lhs, RValue<Float> rhs)
+       RValue<Float> operator+=(Float &lhs, RValue<Float> rhs)
        {
                return lhs = lhs + rhs;
        }
 
-       RValue<Float> operator-=(const Float &lhs, RValue<Float> rhs)
+       RValue<Float> operator-=(Float &lhs, RValue<Float> rhs)
        {
                return lhs = lhs - rhs;
        }
 
-       RValue<Float> operator*=(const Float &lhs, RValue<Float> rhs)
+       RValue<Float> operator*=(Float &lhs, RValue<Float> rhs)
        {
                return lhs = lhs * rhs;
        }
 
-       RValue<Float> operator/=(const Float &lhs, RValue<Float> rhs)
+       RValue<Float> operator/=(Float &lhs, RValue<Float> rhs)
        {
                return lhs = lhs / rhs;
        }
@@ -6040,16 +5737,16 @@ namespace sw
 
        RValue<Float> Rcp_pp(RValue<Float> x, bool exactAtPow2)
        {
-               if(exactAtPow2)
-               {
-                       // rcpss uses a piecewise-linear approximation which minimizes the relative error
-                       // but is not exact at power-of-two values. Rectify by multiplying by the inverse.
-                       return x86::rcpss(x) * Float(1.0f / _mm_cvtss_f32(_mm_rcp_ss(_mm_set_ps1(1.0f))));
-               }
-               else
-               {
-                       return x86::rcpss(x);
-               }
+               #if defined(__i386__) || defined(__x86_64__)
+                       if(exactAtPow2)
+                       {
+                               // rcpss uses a piecewise-linear approximation which minimizes the relative error
+                               // but is not exact at power-of-two values. Rectify by multiplying by the inverse.
+                               return x86::rcpss(x) * Float(1.0f / _mm_cvtss_f32(_mm_rcp_ss(_mm_set_ps1(1.0f))));
+                       }
+               #endif
+
+               return x86::rcpss(x);
        }
 
        RValue<Float> RcpSqrt_pp(RValue<Float> x)
@@ -6129,8 +5826,6 @@ namespace sw
 
        Float2::Float2(RValue<Float4> cast)
        {
-       //      xyzw.parent = this;
-
                Value *int64x2 = Nucleus::createBitCast(cast.value, T(VectorType::get(Long::getType(), 2)));
                Value *int64 = Nucleus::createExtractElement(int64x2, Long::getType(), 0);
                Value *float2 = Nucleus::createBitCast(int64, Float2::getType());
@@ -6143,10 +5838,8 @@ namespace sw
                return T(VectorType::get(Float::getType(), 2));
        }
 
-       Float4::Float4(RValue<Byte4> cast)
+       Float4::Float4(RValue<Byte4> cast) : FloatXYZW(this)
        {
-               xyzw.parent = this;
-
                #if 0
                        Value *xyzw = Nucleus::createUIToFP(cast.value, Float4::getType());   // FIXME: Crashes
                #elif 0
@@ -6175,10 +5868,8 @@ namespace sw
                storeValue(xyzw);
        }
 
-       Float4::Float4(RValue<SByte4> cast)
+       Float4::Float4(RValue<SByte4> cast) : FloatXYZW(this)
        {
-               xyzw.parent = this;
-
                #if 0
                        Value *xyzw = Nucleus::createSIToFP(cast.value, Float4::getType());   // FIXME: Crashes
                #elif 0
@@ -6207,100 +5898,82 @@ namespace sw
                storeValue(xyzw);
        }
 
-       Float4::Float4(RValue<Short4> cast)
+       Float4::Float4(RValue<Short4> cast) : FloatXYZW(this)
        {
-               xyzw.parent = this;
-
                Int4 c(cast);
                storeValue(Nucleus::createSIToFP(RValue<Int4>(c).value, Float4::getType()));
        }
 
-       Float4::Float4(RValue<UShort4> cast)
+       Float4::Float4(RValue<UShort4> cast) : FloatXYZW(this)
        {
-               xyzw.parent = this;
-
                Int4 c(cast);
                storeValue(Nucleus::createSIToFP(RValue<Int4>(c).value, Float4::getType()));
        }
 
-       Float4::Float4(RValue<Int4> cast)
+       Float4::Float4(RValue<Int4> cast) : FloatXYZW(this)
        {
-               xyzw.parent = this;
-
                Value *xyzw = Nucleus::createSIToFP(cast.value, Float4::getType());
 
                storeValue(xyzw);
        }
 
-       Float4::Float4(RValue<UInt4> cast)
+       Float4::Float4(RValue<UInt4> cast) : FloatXYZW(this)
        {
-               xyzw.parent = this;
+               RValue<Float4> result = Float4(Int4(cast & UInt4(0x7FFFFFFF))) +
+                                       As<Float4>((As<Int4>(cast) >> 31) & As<Int4>(Float4(0x80000000u)));
 
-               Value *xyzw = Nucleus::createUIToFP(cast.value, Float4::getType());
-
-               storeValue(xyzw);
+               storeValue(result.value);
        }
 
-       Float4::Float4()
+       Float4::Float4() : FloatXYZW(this)
        {
-               xyzw.parent = this;
        }
 
-       Float4::Float4(float xyzw)
+       Float4::Float4(float xyzw) : FloatXYZW(this)
        {
                constant(xyzw, xyzw, xyzw, xyzw);
        }
 
-       Float4::Float4(float x, float yzw)
+       Float4::Float4(float x, float yzw) : FloatXYZW(this)
        {
                constant(x, yzw, yzw, yzw);
        }
 
-       Float4::Float4(float x, float y, float zw)
+       Float4::Float4(float x, float y, float zw) : FloatXYZW(this)
        {
                constant(x, y, zw, zw);
        }
 
-       Float4::Float4(float x, float y, float z, float w)
+       Float4::Float4(float x, float y, float z, float w) : FloatXYZW(this)
        {
                constant(x, y, z, w);
        }
 
        void Float4::constant(float x, float y, float z, float w)
        {
-               xyzw.parent = this;
-
                double constantVector[4] = {x, y, z, w};
                storeValue(Nucleus::createConstantVector(constantVector, getType()));
        }
 
-       Float4::Float4(RValue<Float4> rhs)
+       Float4::Float4(RValue<Float4> rhs) : FloatXYZW(this)
        {
-               xyzw.parent = this;
-
                storeValue(rhs.value);
        }
 
-       Float4::Float4(const Float4 &rhs)
+       Float4::Float4(const Float4 &rhs) : FloatXYZW(this)
        {
-               xyzw.parent = this;
-
                Value *value = rhs.loadValue();
                storeValue(value);
        }
 
-       Float4::Float4(const Reference<Float4> &rhs)
+       Float4::Float4(const Reference<Float4> &rhs) : FloatXYZW(this)
        {
-               xyzw.parent = this;
-
                Value *value = rhs.loadValue();
                storeValue(value);
        }
 
-       Float4::Float4(RValue<Float> rhs)
+       Float4::Float4(RValue<Float> rhs) : FloatXYZW(this)
        {
-               xyzw.parent = this;
-
                Value *vector = loadValue();
                Value *insert = Nucleus::createInsertElement(vector, rhs.value, 0);
 
@@ -6310,33 +5983,29 @@ namespace sw
                storeValue(replicate);
        }
 
-       Float4::Float4(const Float &rhs)
+       Float4::Float4(const Float &rhs) : FloatXYZW(this)
        {
-               xyzw.parent = this;
-
                *this = RValue<Float>(rhs.loadValue());
        }
 
-       Float4::Float4(const Reference<Float> &rhs)
+       Float4::Float4(const Reference<Float> &rhs) : FloatXYZW(this)
        {
-               xyzw.parent = this;
-
                *this = RValue<Float>(rhs.loadValue());
        }
 
-       RValue<Float4> Float4::operator=(float x) const
+       RValue<Float4> Float4::operator=(float x)
        {
                return *this = Float4(x, x, x, x);
        }
 
-       RValue<Float4> Float4::operator=(RValue<Float4> rhs) const
+       RValue<Float4> Float4::operator=(RValue<Float4> rhs)
        {
                storeValue(rhs.value);
 
                return rhs;
        }
 
-       RValue<Float4> Float4::operator=(const Float4 &rhs) const
+       RValue<Float4> Float4::operator=(const Float4 &rhs)
        {
                Value *value = rhs.loadValue();
                storeValue(value);
@@ -6344,7 +6013,7 @@ namespace sw
                return RValue<Float4>(value);
        }
 
-       RValue<Float4> Float4::operator=(const Reference<Float4> &rhs) const
+       RValue<Float4> Float4::operator=(const Reference<Float4> &rhs)
        {
                Value *value = rhs.loadValue();
                storeValue(value);
@@ -6352,17 +6021,17 @@ namespace sw
                return RValue<Float4>(value);
        }
 
-       RValue<Float4> Float4::operator=(RValue<Float> rhs) const
+       RValue<Float4> Float4::operator=(RValue<Float> rhs)
        {
                return *this = Float4(rhs);
        }
 
-       RValue<Float4> Float4::operator=(const Float &rhs) const
+       RValue<Float4> Float4::operator=(const Float &rhs)
        {
                return *this = Float4(rhs);
        }
 
-       RValue<Float4> Float4::operator=(const Reference<Float> &rhs) const
+       RValue<Float4> Float4::operator=(const Reference<Float> &rhs)
        {
                return *this = Float4(rhs);
        }
@@ -6392,27 +6061,27 @@ namespace sw
                return RValue<Float4>(Nucleus::createFRem(lhs.value, rhs.value));
        }
 
-       RValue<Float4> operator+=(const Float4 &lhs, RValue<Float4> rhs)
+       RValue<Float4> operator+=(Float4 &lhs, RValue<Float4> rhs)
        {
                return lhs = lhs + rhs;
        }
 
-       RValue<Float4> operator-=(const Float4 &lhs, RValue<Float4> rhs)
+       RValue<Float4> operator-=(Float4 &lhs, RValue<Float4> rhs)
        {
                return lhs = lhs - rhs;
        }
 
-       RValue<Float4> operator*=(const Float4 &lhs, RValue<Float4> rhs)
+       RValue<Float4> operator*=(Float4 &lhs, RValue<Float4> rhs)
        {
                return lhs = lhs * rhs;
        }
 
-       RValue<Float4> operator/=(const Float4 &lhs, RValue<Float4> rhs)
+       RValue<Float4> operator/=(Float4 &lhs, RValue<Float4> rhs)
        {
                return lhs = lhs / rhs;
        }
 
-       RValue<Float4> operator%=(const Float4 &lhs, RValue<Float4> rhs)
+       RValue<Float4> operator%=(Float4 &lhs, RValue<Float4> rhs)
        {
                return lhs = lhs % rhs;
        }
@@ -6448,16 +6117,16 @@ namespace sw
 
        RValue<Float4> Rcp_pp(RValue<Float4> x, bool exactAtPow2)
        {
-               if(exactAtPow2)
-               {
-                       // rcpps uses a piecewise-linear approximation which minimizes the relative error
-                       // but is not exact at power-of-two values. Rectify by multiplying by the inverse.
-                       return x86::rcpps(x) * Float4(1.0f / _mm_cvtss_f32(_mm_rcp_ss(_mm_set_ps1(1.0f))));
-               }
-               else
-               {
-                       return x86::rcpps(x);
-               }
+               #if defined(__i386__) || defined(__x86_64__)
+                       if(exactAtPow2)
+                       {
+                               // rcpps uses a piecewise-linear approximation which minimizes the relative error
+                               // but is not exact at power-of-two values. Rectify by multiplying by the inverse.
+                               return x86::rcpps(x) * Float4(1.0f / _mm_cvtss_f32(_mm_rcp_ss(_mm_set_ps1(1.0f))));
+                       }
+               #endif
+
+               return x86::rcpps(x);
        }
 
        RValue<Float4> RcpSqrt_pp(RValue<Float4> x)
@@ -6470,14 +6139,9 @@ namespace sw
                return x86::sqrtps(x);
        }
 
-       RValue<Float4> Insert(const Float4 &val, RValue<Float> element, int i)
+       RValue<Float4> Insert(RValue<Float4> val, RValue<Float> element, int i)
        {
-               Value *value = val.loadValue();
-               Value *insert = Nucleus::createInsertElement(value, element.value, i);
-
-               val = RValue<Float4>(insert);
-
-               return val;
+               return RValue<Float4>(Nucleus::createInsertElement(val.value, element.value, i));
        }
 
        RValue<Float> Extract(RValue<Float4> x, int i)
@@ -6591,16 +6255,22 @@ namespace sw
 
        RValue<Float4> Frac(RValue<Float4> x)
        {
+               Float4 frc;
+
                if(CPUID::supportsSSE4_1())
                {
-                       return x - x86::floorps(x);
+                       frc = x - x86::floorps(x);
                }
                else
                {
-                       Float4 frc = x - Float4(Int4(x));   // Signed fractional part
+                       frc = x - Float4(Int4(x));   // Signed fractional part.
 
-                       return frc + As<Float4>(As<Int4>(CmpNLE(Float4(0.0f), frc)) & As<Int4>(Float4(1, 1, 1, 1)));
+                       frc += As<Float4>(As<Int4>(CmpNLE(Float4(0.0f), frc)) & As<Int4>(Float4(1.0f)));   // Add 1.0 if negative.
                }
+
+               // x - floor(x) can be 1.0 for very small negative x.
+               // Clamp against the value just below 1.0.
+               return Min(frc, As<Float4>(Int4(0x3F7FFFFF)));
        }
 
        RValue<Float4> Floor(RValue<Float4> x)
@@ -6634,30 +6304,30 @@ namespace sw
 
        RValue<Pointer<Byte>> operator+(RValue<Pointer<Byte>> lhs, int offset)
        {
-               return RValue<Pointer<Byte>>(Nucleus::createGEP(lhs.value, Byte::getType(), V(Nucleus::createConstantInt(offset))));
+               return RValue<Pointer<Byte>>(Nucleus::createGEP(lhs.value, Byte::getType(), V(Nucleus::createConstantInt(offset)), false));
        }
 
        RValue<Pointer<Byte>> operator+(RValue<Pointer<Byte>> lhs, RValue<Int> offset)
        {
-               return RValue<Pointer<Byte>>(Nucleus::createGEP(lhs.value, Byte::getType(), offset.value));
+               return RValue<Pointer<Byte>>(Nucleus::createGEP(lhs.value, Byte::getType(), offset.value, false));
        }
 
        RValue<Pointer<Byte>> operator+(RValue<Pointer<Byte>> lhs, RValue<UInt> offset)
        {
-               return RValue<Pointer<Byte>>(Nucleus::createGEP(lhs.value, Byte::getType(), offset.value));
+               return RValue<Pointer<Byte>>(Nucleus::createGEP(lhs.value, Byte::getType(), offset.value, true));
        }
 
-       RValue<Pointer<Byte>> operator+=(const Pointer<Byte> &lhs, int offset)
+       RValue<Pointer<Byte>> operator+=(Pointer<Byte> &lhs, int offset)
        {
                return lhs = lhs + offset;
        }
 
-       RValue<Pointer<Byte>> operator+=(const Pointer<Byte> &lhs, RValue<Int> offset)
+       RValue<Pointer<Byte>> operator+=(Pointer<Byte> &lhs, RValue<Int> offset)
        {
                return lhs = lhs + offset;
        }
 
-       RValue<Pointer<Byte>> operator+=(const Pointer<Byte> &lhs, RValue<UInt> offset)
+       RValue<Pointer<Byte>> operator+=(Pointer<Byte> &lhs, RValue<UInt> offset)
        {
                return lhs = lhs + offset;
        }
@@ -6677,17 +6347,17 @@ namespace sw
                return lhs + -offset;
        }
 
-       RValue<Pointer<Byte>> operator-=(const Pointer<Byte> &lhs, int offset)
+       RValue<Pointer<Byte>> operator-=(Pointer<Byte> &lhs, int offset)
        {
                return lhs = lhs - offset;
        }
 
-       RValue<Pointer<Byte>> operator-=(const Pointer<Byte> &lhs, RValue<Int> offset)
+       RValue<Pointer<Byte>> operator-=(Pointer<Byte> &lhs, RValue<Int> offset)
        {
                return lhs = lhs - offset;
        }
 
-       RValue<Pointer<Byte>> operator-=(const Pointer<Byte> &lhs, RValue<UInt> offset)
+       RValue<Pointer<Byte>> operator-=(Pointer<Byte> &lhs, RValue<UInt> offset)
        {
                return lhs = lhs - offset;
        }
@@ -6699,48 +6369,17 @@ namespace sw
                Nucleus::createUnreachable();
        }
 
-       void Return(bool ret)
-       {
-               Nucleus::createRet(V(Nucleus::createConstantBool(ret)));
-               Nucleus::setInsertBlock(Nucleus::createBasicBlock());
-               Nucleus::createUnreachable();
-       }
-
-       void Return(const Int &ret)
+       void Return(RValue<Int> ret)
        {
-               Nucleus::createRet(ret.loadValue());
+               Nucleus::createRet(ret.value);
                Nucleus::setInsertBlock(Nucleus::createBasicBlock());
                Nucleus::createUnreachable();
        }
 
-       bool branch(RValue<Bool> cmp, BasicBlock *bodyBB, BasicBlock *endBB)
+       void branch(RValue<Bool> cmp, BasicBlock *bodyBB, BasicBlock *endBB)
        {
                Nucleus::createCondBr(cmp.value, bodyBB, endBB);
                Nucleus::setInsertBlock(bodyBB);
-
-               return true;
-       }
-
-       void endIf(BasicBlock *falseBB)
-       {
-               ::falseBB = falseBB;
-       }
-
-       bool elseBlock(BasicBlock *falseBB)
-       {
-               assert(falseBB && "Else not preceded by If");
-               falseBB->back().eraseFromParent();
-               Nucleus::setInsertBlock(falseBB);
-
-               return true;
-       }
-
-       BasicBlock *beginElse()
-       {
-               BasicBlock *falseBB = ::falseBB;
-               ::falseBB = nullptr;
-
-               return falseBB;
        }
 
        RValue<Long> Ticks()
@@ -7132,18 +6771,18 @@ namespace sw
                        return RValue<Int>(V(::builder->CreateCall2(pextrw, As<MMX>(x).value, V(Nucleus::createConstantInt(i)))));
                }
 
-               RValue<Long1> punpckldq(RValue<Int2> x, RValue<Int2> y)
+               RValue<Short4> punpckldq(RValue<Int2> x, RValue<Int2> y)
                {
                        llvm::Function *punpckldq = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_punpckldq);
 
-                       return As<Long1>(V(::builder->CreateCall2(punpckldq, As<MMX>(x).value, As<MMX>(y).value)));
+                       return As<Short4>(V(::builder->CreateCall2(punpckldq, As<MMX>(x).value, As<MMX>(y).value)));
                }
 
-               RValue<Long1> punpckhdq(RValue<Int2> x, RValue<Int2> y)
+               RValue<Short4> punpckhdq(RValue<Int2> x, RValue<Int2> y)
                {
                        llvm::Function *punpckhdq = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_punpckhdq);
 
-                       return As<Long1>(V(::builder->CreateCall2(punpckhdq, As<MMX>(x).value, As<MMX>(y).value)));
+                       return As<Short4>(V(::builder->CreateCall2(punpckhdq, As<MMX>(x).value, As<MMX>(y).value)));
                }
 
                RValue<Short4> punpcklbw(RValue<Byte8> x, RValue<Byte8> y)
@@ -7281,7 +6920,7 @@ namespace sw
                        return As<Byte8>(V(::builder->CreateCall2(packuswb, As<MMX>(x).value, As<MMX>(y).value)));
                }
 
-               RValue<UShort8> packusdw(RValue<UInt4> x, RValue<UInt4> y)
+               RValue<UShort8> packusdw(RValue<Int4> x, RValue<Int4> y)
                {
                        if(CPUID::supportsSSE4_1())
                        {
@@ -7291,8 +6930,10 @@ namespace sw
                        }
                        else
                        {
-                               // FIXME: Not an exact replacement!
-                               return As<UShort8>(packssdw(As<Int4>(x - UInt4(0x00008000, 0x00008000, 0x00008000, 0x00008000)), As<Int4>(y - UInt4(0x00008000, 0x00008000, 0x00008000, 0x00008000))) + Short8(0x8000u, 0x8000u, 0x8000u, 0x8000u, 0x8000u, 0x8000u, 0x8000u, 0x8000u));
+                               RValue<Int4> bx = (x & ~(x >> 31)) - Int4(0x8000);
+                               RValue<Int4> by = (y & ~(y >> 31)) - Int4(0x8000);
+
+                               return As<UShort8>(packssdw(bx, by) + Short8(0x8000u));
                        }
                }
 
@@ -7419,48 +7060,6 @@ namespace sw
                        }
                }
 
-               RValue<UShort4> psrlw(RValue<UShort4> x, RValue<Long1> y)
-               {
-                       llvm::Function *psrlw = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_psrl_w);
-
-                       return As<UShort4>(V(::builder->CreateCall2(psrlw, As<MMX>(x).value, As<MMX>(y).value)));
-               }
-
-               RValue<Short4> psraw(RValue<Short4> x, RValue<Long1> y)
-               {
-                       llvm::Function *psraw = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_psra_w);
-
-                       return As<Short4>(V(::builder->CreateCall2(psraw, As<MMX>(x).value, As<MMX>(y).value)));
-               }
-
-               RValue<Short4> psllw(RValue<Short4> x, RValue<Long1> y)
-               {
-                       llvm::Function *psllw = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_psll_w);
-
-                       return As<Short4>(V(::builder->CreateCall2(psllw, As<MMX>(x).value, As<MMX>(y).value)));
-               }
-
-               RValue<Int2> pslld(RValue<Int2> x, RValue<Long1> y)
-               {
-                       llvm::Function *pslld = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_psll_d);
-
-                       return As<Int2>(V(::builder->CreateCall2(pslld, As<MMX>(x).value, As<MMX>(y).value)));
-               }
-
-               RValue<UInt2> psrld(RValue<UInt2> x, RValue<Long1> y)
-               {
-                       llvm::Function *psrld = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_psrl_d);
-
-                       return As<UInt2>(V(::builder->CreateCall2(psrld, As<MMX>(x).value, As<MMX>(y).value)));
-               }
-
-               RValue<Int2> psrad(RValue<Int2> x, RValue<Long1> y)
-               {
-                       llvm::Function *psrld = Intrinsic::getDeclaration(::module, Intrinsic::x86_mmx_psra_d);
-
-                       return As<Int2>(V(::builder->CreateCall2(psrld, As<MMX>(x).value, As<MMX>(y).value)));
-               }
-
                RValue<Int4> pmaxsd(RValue<Int4> x, RValue<Int4> y)
                {
                        llvm::Function *pmaxsd = Intrinsic::getDeclaration(::module, Intrinsic::x86_sse41_pmaxsd);