[llvm] [SLP] Normalize debug messages for newTreeEntry. (PR #119514)
Alexander Kornienko via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 14 08:50:27 PST 2025
================
@@ -8417,13 +8418,14 @@ void BoUpSLP::buildTree_rec(ArrayRef<Value *> VL, unsigned Depth,
}
// Insert new order with initial value 0, if it does not exist,
// otherwise return the iterator to the existing one.
- newTreeEntry(VL, Bundle /*vectorized*/, S, UserTreeIdx,
- ReuseShuffleIndices, CurrentOrder);
+ TreeEntry *TE = newTreeEntry(VL, Bundle /*vectorized*/, S, UserTreeIdx,
+ ReuseShuffleIndices, CurrentOrder);
+ LLVM_DEBUG(dbgs() << "SLP: added a new TreeEntry "
+ "(ExtractValueInst/ExtractElementInst).\n";
+ TE->dump());
// This is a special case, as it does not gather, but at the same time
// we are not extending buildTree_rec() towards the operands.
- ValueList Op0;
- Op0.assign(VL.size(), VL0->getOperand(0));
- VectorizableTree.back()->setOperand(0, Op0);
+ TE->setOperand(*this);
----------------
alexfh wrote:
Here a reduced test that shows the difference in produced IR after this commit. I'm not sure if it's correct or not, but I believe this was not intended. The patch might have been over-reduced (since I used the presence of any diff as the interestingness test), but the original code seems to be correct, but after this commit it starts producing a segfault.
```
$ cat reduced.ll
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
define void @_f() #0 {
%1 = extractelement <8 x float> zeroinitializer, i64 1
%2 = fcmp uno float %1, 0.000000e+00
%3 = select i1 %2, i64 0, i64 0
%4 = extractelement <8 x float> zeroinitializer, i64 2
%5 = fcmp uno float %4, 0.000000e+00
%6 = select i1 %5, i64 0, i64 0
%7 = extractelement <8 x float> zeroinitializer, i64 3
%8 = fcmp uno float %7, 0.000000e+00
%9 = extractelement <8 x float> zeroinitializer, i64 4
%10 = fcmp uno float %9, 0.000000e+00
%11 = select i1 %10, i64 0, i64 0
%12 = extractelement <8 x float> zeroinitializer, i64 5
%13 = fcmp uno float %12, 0.000000e+00
%14 = extractelement <8 x float> zeroinitializer, i64 6
%15 = fcmp uno float %14, 0.000000e+00
%16 = select i1 %15, i64 0, i64 0
%17 = extractelement <8 x float> zeroinitializer, i64 7
%18 = fcmp uno float %17, 0.000000e+00
%19 = fcmp oeq float %12, 0.000000e+00
%20 = fcmp oeq float %14, 0.000000e+00
%21 = select i1 %20, i64 0, i64 0
%22 = fcmp oeq float %17, 0.000000e+00
%23 = select i1 %22, i64 0, i64 0
%24 = fcmp oeq float %4, 0.000000e+00
%25 = select i1 %24, i64 0, i64 0
%26 = fcmp oeq float %7, 0.000000e+00
%27 = select i1 %26, i64 0, i64 0
%28 = fcmp oeq float %9, 0.000000e+00
%29 = fcmp oeq float %12, 0.000000e+00
%30 = select i1 %29, i64 0, i64 0
%31 = fcmp oeq float %14, 0.000000e+00
%32 = select i1 %31, i64 0, i64 0
%33 = fcmp oeq float %17, 0.000000e+00
ret void
}
attributes #0 = { "target-features"="+aes,+avx,+avx2,+avx512bw,+avx512dq,+avx512f,+avx512vl,+bmi2,+cmov,+crc32,+cx16,+cx8,+evex512,+f16c,+fma,+fxsr,+lzcnt,+mmx,+pclmul,+popcnt,+prfchw,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave" }
$ diff -u <(./opt-before --passes=slp-vectorizer reduced.ll -S -o -) <(./opt-after --passes=slp-vectorizer reduced.ll -S -o -)
--- /dev/fd/63 2025-01-14 17:46:34.291801310 +0100
+++ /dev/fd/62 2025-01-14 17:46:34.291801310 +0100
@@ -4,16 +4,16 @@
target triple = "x86_64-unknown-linux-gnu"
define void @_f() #0 {
- %1 = select i1 false, i64 0, i64 0
- %2 = select i1 false, i64 0, i64 0
- %3 = select i1 false, i64 0, i64 0
- %4 = select i1 false, i64 0, i64 0
- %5 = select i1 true, i64 0, i64 0
- %6 = select i1 true, i64 0, i64 0
- %7 = select i1 true, i64 0, i64 0
- %8 = select i1 true, i64 0, i64 0
- %9 = select i1 true, i64 0, i64 0
- %10 = select i1 true, i64 0, i64 0
+ %1 = select i1 poison, i64 0, i64 0
+ %2 = select i1 poison, i64 0, i64 0
+ %3 = select i1 poison, i64 0, i64 0
+ %4 = select i1 poison, i64 0, i64 0
+ %5 = select i1 poison, i64 0, i64 0
+ %6 = select i1 poison, i64 0, i64 0
+ %7 = select i1 poison, i64 0, i64 0
+ %8 = select i1 poison, i64 0, i64 0
+ %9 = select i1 poison, i64 0, i64 0
+ %10 = select i1 poison, i64 0, i64 0
ret void
}
```
https://github.com/llvm/llvm-project/pull/119514
More information about the llvm-commits
mailing list