[llvm-bugs] [Bug 25578] New: IndVarSimplify breaks LCSSA form, while saying it's preserved
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Nov 19 12:09:25 PST 2015
https://llvm.org/bugs/show_bug.cgi?id=25578
Bug ID: 25578
Summary: IndVarSimplify breaks LCSSA form, while saying it's
preserved
Product: libraries
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P
Component: Loop Optimizer
Assignee: unassignedbugs at nondot.org
Reporter: michael.v.zolotukhin at gmail.com
CC: llvm-bugs at lists.llvm.org
Classification: Unclassified
Applied on the following test case, IndVarSimplify introduces a definition
without corresponding LCSSA phi nodes, thus breaking LCSSA:
--------------------------------------------
; RUN: opt < %s -indvars -S | FileCheck %s
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
; CHECK-LABEL: @foo
define void @foo() {
entry:
br label %L1_header
L1_header:
br label %L2_header
; CHECK: L2_header:
; CHECK: %[[INDVAR:.*]] = phi i64
L2_header:
%i = phi i32 [ 0, %L1_header ], [ %i_next, %L2_latch ]
%i_prom = sext i32 %i to i64
br label %L3_header
; CHECK: L3_header:
; CHECK: %[[TRUNC:.*]] = trunc i64 %[[INDVAR]] to i32
L3_header:
br i1 undef, label %L3_latch, label %L2_exiting_1
L3_latch:
br i1 undef, label %L3_header, label %L2_exiting_2
; CHECK: L2_exiting_1:
; CHECK: %{{.*}} = phi i32 [ %[[TRUNC]], %L3_header ]
L2_exiting_1:
br i1 undef, label %L2_latch, label %L1_latch
; CHECK: L2_exiting_2:
; CHECK: %{{.*}} = phi i32 [ %[[TRUNC]], %L3_latch ]
L2_exiting_2:
br i1 undef, label %L2_latch, label %L1_latch
L2_latch:
%i_next = add nsw i32 %i, 1
br label %L2_header
L1_latch:
%i_lcssa = phi i32 [ %i, %L2_exiting_1 ], [ %i, %L2_exiting_2 ]
br i1 undef, label %exit, label %L1_header
exit:
ret void
}
--------------------------------------------
When it promotes an i32 induction variable to i64, it has to insert trunc
instruction before uses of the original i32 variable. In this case such use is
a phi-node(%i_lcssa in L1_latch), so it finds the nearest block that dominates
all corresponding incoming blocks (L2_exiting_1 and L2_exiting_2), and inserts
"%0 = trunc ..." there (into L3_header). However, this insertion point happens
to be in a loop (L3), so this definition is inside a loop, while its uses are
outside the loop. IndVarSimplify doesn't insert corresponding phi-nodes, and
thus breaks LCSSA.
--
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/20151119/cb18e9fc/attachment.html>
More information about the llvm-bugs
mailing list