ac: rework ac_llvm_extract_elem()
authorTimothy Arceri <tarceri@itsqueeze.com>
Wed, 13 Dec 2017 07:46:56 +0000 (18:46 +1100)
committerTimothy Arceri <tarceri@itsqueeze.com>
Fri, 5 Jan 2018 01:20:38 +0000 (12:20 +1100)
Simplifies the logic a little and asserts index is 0.

Suggested-by: Nicolai Hähnle <nhaehnle@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/amd/common/ac_llvm_build.c

index 0ea5e7f4caacf90d98b7518b25b93aaa822c316b..8a3a2abf17b525dc5cd8efda2006f2f424963d2d 100644 (file)
@@ -114,10 +114,10 @@ ac_llvm_extract_elem(struct ac_llvm_context *ac,
                     LLVMValueRef value,
                     int index)
 {
-       int count = ac_get_llvm_num_components(value);
-
-       if (count == 1)
+       if (LLVMGetTypeKind(LLVMTypeOf(value)) != LLVMVectorTypeKind) {
+               assert(index == 0);
                return value;
+       }
 
        return LLVMBuildExtractElement(ac->builder, value,
                                       LLVMConstInt(ac->i32, index, false), "");