mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 20:32:21 +00:00
a0a0b40aa3
(The change was landed in r230280 and caused the regression PR22674. This version contains a fix and a test-case for PR22674). When emitting the increment operation, SCEVExpander marks the operation as nuw or nsw based on the flags on the preincrement SCEV. This is incorrect because, for instance, it is possible that {-6,+,1} is <nuw> while {-6,+,1}+1 = {-5,+,1} is not. This change teaches SCEV to mark the increment as nuw/nsw only if it can explicitly prove that the increment operation won't overflow. Apart from the attached test case, another (more realistic) manifestation of the bug can be seen in Transforms/IndVarSimplify/pr20680.ll. Differential Revision: http://reviews.llvm.org/D7778 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230533 91177308-0d34-0410-b5e6-96231b3b80d8
31 lines
722 B
LLVM
31 lines
722 B
LLVM
; RUN: opt -indvars -S < %s | FileCheck %s
|
|
|
|
declare void @use(i32)
|
|
declare void @use.i8(i8)
|
|
|
|
define void @f() {
|
|
; CHECK-LABEL: @f
|
|
entry:
|
|
br label %loop
|
|
|
|
loop:
|
|
; The only use for idx.mirror is to induce an nuw for %idx. It does
|
|
; not induce an nuw for %idx.inc
|
|
%idx.mirror = phi i8 [ -6, %entry ], [ %idx.mirror.inc, %loop ]
|
|
%idx = phi i8 [ -5, %entry ], [ %idx.inc, %loop ]
|
|
|
|
%idx.sext = sext i8 %idx to i32
|
|
call void @use(i32 %idx.sext)
|
|
|
|
%idx.mirror.inc = add nuw i8 %idx.mirror, 1
|
|
call void @use.i8(i8 %idx.mirror.inc)
|
|
|
|
%idx.inc = add i8 %idx, 1
|
|
; CHECK-NOT: %indvars.iv.next = add nuw nsw i32 %indvars.iv, 1
|
|
%cmp = icmp ugt i8 %idx.inc, 0
|
|
br i1 %cmp, label %loop, label %exit
|
|
|
|
exit:
|
|
ret void
|
|
}
|