ac/nir: handle negate modifier
authorMarek Olšák <marek.olsak@amd.com>
Wed, 24 Jul 2019 03:11:40 +0000 (23:11 -0400)
committerMarek Olšák <marek.olsak@amd.com>
Wed, 31 Jul 2019 02:06:23 +0000 (22:06 -0400)
src/amd/common/ac_nir_to_llvm.c

index 826a63773238097027f8c7edd1ba058e812a7f21..f3cb9e879ed8074efbe5bc46147f5040bb735b47 100644 (file)
@@ -187,7 +187,18 @@ static LLVMValueRef get_alu_src(struct ac_nir_context *ctx,
                                                       swizzle, "");
                }
        }
-       assert(!src.negate);
+
+       if (src.negate) {
+               LLVMTypeRef type = LLVMTypeOf(value);
+               if (LLVMGetTypeKind(type) == LLVMVectorTypeKind)
+                       type = LLVMGetElementType(type);
+
+               if (LLVMGetTypeKind(type) == LLVMIntegerTypeKind)
+                       value = LLVMBuildNeg(ctx->ac.builder, value, "");
+               else
+                       value = LLVMBuildFNeg(ctx->ac.builder, value, "");
+       }
+
        assert(!src.abs);
        return value;
 }