[llvm] r296770 - The patch turns on epilogue unroll for loops with constant recurency start.

Davide Italiano via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 21 18:00:49 PDT 2017


On Thu, Mar 2, 2017 at 9:38 AM, Evgeny Stupachenko via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
> Author: evstupac
> Date: Thu Mar  2 11:38:46 2017
> New Revision: 296770
>

Hi Evgeny,
sorry for being late, but this patch triggers a misoptimization at LTO
time in some of our internal code.

The optimized bitcode reverting the change is:

define i32 @main() local_unnamed_addr #0 {
fib.exit17:
  %0 = tail call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5
x i8], [5 x i8]* @.str, i64
0, i64 0), double 0x3FF9E4129E4129E4)
  ret i32 0
}


while ToT looks like:

define i32 @main() local_unnamed_addr #0 {
  br label %1

; <label>:1:                                      ; preds = %1, %0
  %2 = phi i32 [ %5, %1 ], [ 34, %0 ]
  %3 = phi i32 [ %2, %1 ], [ 21, %0 ]
  %4 = phi i32 [ %6, %1 ], [ 2, %0 ]
  %5 = add nsw i32 %2, %3
  %6 = add nsw i32 %4, -1
  %7 = icmp eq i32 %6, 0
  br i1 %7, label %fib.exit, label %1, !llvm.loop !2

fib.exit:                                         ; preds = %1
  %8 = sitofp i32 %5 to double
  %9 = fdiv double %8, 5.500000e+01
  %10 = tail call i32 (i8*, ...) @printf(i8* getelementptr inbounds
([5 x i8], [5 x i8]* @.str, i64
0, i64 0), double %9)
  ret i32 0
}

I'll open a PR with the details on how to reproduce.

Thanks,

--
Davide


More information about the llvm-commits mailing list