[PATCH] D103458: [SLP]Improve gathering of scalar elements.

Alexey Bataev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 30 05:06:10 PDT 2021


ABataev added a comment.

In D103458#2849176 <https://reviews.llvm.org/D103458#2849176>, @Carrot wrote:

> Compile the following test case with
>
> opt -slp-vectorizer -S test3.ll
>
> Then I can get a poison value in the phi instruction.
>
>   target triple = "x86_64-grtev4-linux-gnu"
>   
>   %S = type { i64, i40 }
>   
>   define void @foo(i1 %cond) {
>   entry:
>     %nb = alloca %S, align 8
>     br i1 %cond, label %then, label %bug
>   
>   then:
>     call void @baz()
>     %ptr_2 = getelementptr inbounds %S, %S* %nb, i64 0, i32 0
>     %load2 = load i64, i64* %ptr_2, align 8
>     %bf_1 = getelementptr inbounds %S, %S* %nb, i64 0, i32 1
>     %ptr_1 = bitcast i40* %bf_1 to i64*
>     %load1 = load i64, i64* %ptr_1, align 8
>     br label %bug
>   
>   bug:
>     %word1 = phi i64 [ %load1, %then ], [ undef, %entry ]
>     %word2 = phi i64 [ %load2, %then ], [ undef, %entry ]
>     %ptr2 = getelementptr inbounds %S, %S* %nb, i64 0, i32 0
>     %word2.clear = and i64 %word2, -1152921504606846976
>     %word2.set = or i64 %word2.clear, 1
>     store i64 %word2.set, i64* %ptr2, align 8
>     %bf1 = getelementptr inbounds %S, %S* %nb, i64 0, i32 1
>     %ptr1 = bitcast i40* %bf1 to i64*
>     %word1.clear = and i64 %word1, -68719476736
>     %word1.set = or i64 %word1.clear, 21
>     store i64 %word1.set, i64* %ptr1, align 8
>     call void @bar()
>     br label %exit
>   
>   exit:
>     ret void
>   }
>   
>   declare void @bar()
>   declare void @baz()



In D103458#2849176 <https://reviews.llvm.org/D103458#2849176>, @Carrot wrote:

> Compile the following test case with
>
> opt -slp-vectorizer -S test3.ll
>
> Then I can get a poison value in the phi instruction.
>
>   target triple = "x86_64-grtev4-linux-gnu"
>   
>   %S = type { i64, i40 }
>   
>   define void @foo(i1 %cond) {
>   entry:
>     %nb = alloca %S, align 8
>     br i1 %cond, label %then, label %bug
>   
>   then:
>     call void @baz()
>     %ptr_2 = getelementptr inbounds %S, %S* %nb, i64 0, i32 0
>     %load2 = load i64, i64* %ptr_2, align 8
>     %bf_1 = getelementptr inbounds %S, %S* %nb, i64 0, i32 1
>     %ptr_1 = bitcast i40* %bf_1 to i64*
>     %load1 = load i64, i64* %ptr_1, align 8
>     br label %bug
>   
>   bug:
>     %word1 = phi i64 [ %load1, %then ], [ undef, %entry ]
>     %word2 = phi i64 [ %load2, %then ], [ undef, %entry ]
>     %ptr2 = getelementptr inbounds %S, %S* %nb, i64 0, i32 0
>     %word2.clear = and i64 %word2, -1152921504606846976
>     %word2.set = or i64 %word2.clear, 1
>     store i64 %word2.set, i64* %ptr2, align 8
>     %bf1 = getelementptr inbounds %S, %S* %nb, i64 0, i32 1
>     %ptr1 = bitcast i40* %bf1 to i64*
>     %word1.clear = and i64 %word1, -68719476736
>     %word1.set = or i64 %word1.clear, 21
>     store i64 %word1.set, i64* %ptr1, align 8
>     call void @bar()
>     br label %exit
>   
>   exit:
>     ret void
>   }
>   
>   declare void @bar()
>   declare void @baz()

Checked it, looks like everything is correct. You have 2 undefs in phi, they are correctly merged into a vector `poison`. Also, checked the transformation via alive (https://alive2.llvm.org/ce/z/q6G8TK), it is correct


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103458/new/

https://reviews.llvm.org/D103458



More information about the llvm-commits mailing list