[llvm-bugs] [Bug 24738] New: Loop vectorizer introduces bad "undef"
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Sep 7 06:25:47 PDT 2015
https://llvm.org/bugs/show_bug.cgi?id=24738
Bug ID: 24738
Summary: Loop vectorizer introduces bad "undef"
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: Loop Optimizer
Assignee: unassignedbugs at nondot.org
Reporter: mattias.v.eriksson at ericsson.com
CC: llvm-bugs at lists.llvm.org, nrotem at apple.com
Classification: Unclassified
Created attachment 14851
--> https://llvm.org/bugs/attachment.cgi?id=14851&action=edit
Reduced reproducer
I think this is a bug in the fix to Bug 14725.
With the attached file if we run:
opt -S -licm -loop-vectorize -O1 -o /dev/null bugpoint-reduced-simplified.ll
-print-after-all -print-before-all
The loop vectorizer does this transformation:
*** IR Dump Before Loop Vectorization ***
define void @TEST__MAIN() {
%_tmp52 = call i16 @foo(i16 0)
%_tmp53 = load i16*, i16** undef
br label %bb1
bb1: ; preds = %bb1, %0
%i.22.0 = phi i16 [ undef, %0 ], [ %_tmp55, %bb1 ]
%_tmp55 = add i16 %i.22.0, 1
%_tmp59 = icmp slt i16 %_tmp55, 40
br i1 %_tmp59, label %bb1, label %bb4.preheader
bb4.preheader: ; preds = %bb1
%_tmp52.lcssa = phi i16 [ %_tmp52, %bb1 ]
store i16 %_tmp52, i16* %_tmp53
%_tmp67 = load i16*, i16** undef
br label %bb4
bb4: ; preds = %bb4.preheader,
%bb4
br i1 false, label %bb4, label %bb6
bb6: ; preds = %bb4
store i16 %_tmp52.lcssa, i16* %_tmp67
ret void
}
*** IR Dump After Loop Vectorization ***
define void @TEST__MAIN() {
%_tmp52 = call i16 @foo(i16 0)
%_tmp53 = load i16*, i16** undef
%min.iters.check = icmp ult i32 1, 4
br i1 %min.iters.check, label %scalar.ph, label %min.iters.checked
min.iters.checked: ; preds = %0
br i1 true, label %middle.block, label %vector.ph
vector.ph: ; preds = %min.iters.checked
br label %vector.body
vector.body: ; preds = %vector.body,
%vector.ph
%index = phi i32 [ 0, %vector.ph ], [ %index.next, %vector.body ]
%1 = trunc i32 %index to i16
%broadcast.splatinsert = insertelement <4 x i16> undef, i16 %1, i32 0
%broadcast.splat = shufflevector <4 x i16> %broadcast.splatinsert, <4 x i16>
undef, <4 x i32> zeroinitializer
%induction = add <4 x i16> %broadcast.splat, <i16 0, i16 1, i16 2, i16 3>
%2 = add <4 x i16> %induction, <i16 1, i16 1, i16 1, i16 1>
%3 = icmp slt <4 x i16> %2, <i16 40, i16 40, i16 40, i16 40>
%index.next = add i32 %index, 4
%4 = icmp eq i32 %index.next, 0
br i1 %4, label %middle.block, label %vector.body, !llvm.loop !0
middle.block: ; preds = %vector.body,
%min.iters.checked
%resume.val = phi i32 [ 0, %min.iters.checked ], [ 0, %vector.body ]
%trunc.resume.val = phi i16 [ undef, %min.iters.checked ], [ 0, %vector.body
]
%cmp.n = icmp eq i32 1, %resume.val
br i1 %cmp.n, label %bb4.preheader, label %scalar.ph
scalar.ph: ; preds = %middle.block, %0
%bc.resume.val = phi i32 [ %resume.val, %middle.block ], [ 0, %0 ]
%bc.trunc.resume.val = phi i16 [ %trunc.resume.val, %middle.block ], [ undef,
%0 ]
br label %bb1
bb1: ; preds = %bb1, %scalar.ph
%i.22.0 = phi i16 [ %bc.trunc.resume.val, %scalar.ph ], [ %_tmp55, %bb1 ]
%_tmp55 = add i16 %i.22.0, 1
%_tmp59 = icmp slt i16 %_tmp55, 40
br i1 %_tmp59, label %bb1, label %bb4.preheader, !llvm.loop !3
bb4.preheader: ; preds = %middle.block, %bb1
%_tmp52.lcssa = phi i16 [ %_tmp52, %bb1 ], [ undef, %middle.block ]
The problem is at the last line. The phi-node has a new incoming value that is
undef, but in this case it should be the same as the first incoming value.
The new "undef" is added in fixLCSSAPHIs() in LoopVectorize.cpp.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150907/ac5226c7/attachment.html>
More information about the llvm-bugs
mailing list