mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-24 09:29:42 +00:00
There are places where the inductive range check elimination pass depends on two llvm::Values or llvm::SCEVs to be of the same llvm::Type when they do not need to be. This patch relaxes those restrictions (by bailing out of the optimization if the types mismatch), and adds test cases to trigger those paths. These issues were found by bootstrapping clang with IRCE running in the -O3 pass ordering. Differential Revision: http://reviews.llvm.org/D7082 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226793 91177308-0d34-0410-b5e6-96231b3b80d8
67 lines
1.6 KiB
LLVM
67 lines
1.6 KiB
LLVM
; RUN: opt -irce -S < %s
|
|
|
|
; These test cases don't check the correctness of the transform, but
|
|
; that the -irce does not crash in the presence of certain things in
|
|
; the IR:
|
|
|
|
define void @mismatched_types_1() {
|
|
; In this test case, the safe range for the only range check in the
|
|
; loop is of type [i32, i32) while the backedge taken count is of type
|
|
; i64.
|
|
|
|
; CHECK-LABEL: mismatched_types_1
|
|
entry:
|
|
br label %for.body
|
|
|
|
for.body:
|
|
%indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.inc ]
|
|
%0 = trunc i64 %indvars.iv to i32
|
|
%1 = icmp ult i32 %0, 7
|
|
br i1 %1, label %switch.lookup, label %for.inc
|
|
|
|
switch.lookup:
|
|
br label %for.inc
|
|
|
|
for.inc:
|
|
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
|
|
%cmp55 = icmp slt i64 %indvars.iv.next, 11
|
|
br i1 %cmp55, label %for.body, label %for.end
|
|
|
|
for.end:
|
|
unreachable
|
|
}
|
|
|
|
define void @mismatched_types_2() {
|
|
; In this test case, there are two range check in the loop, one with a
|
|
; safe range of type [i32, i32) and one with a safe range of type
|
|
; [i64, i64).
|
|
|
|
; CHECK-LABEL: mismatched_types_2
|
|
entry:
|
|
br label %for.body.a
|
|
|
|
for.body.a:
|
|
%indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.inc ]
|
|
%cond.a = icmp ult i64 %indvars.iv, 7
|
|
br i1 %cond.a, label %switch.lookup.a, label %for.body.b
|
|
|
|
switch.lookup.a:
|
|
br label %for.body.b
|
|
|
|
for.body.b:
|
|
%truncated = trunc i64 %indvars.iv to i32
|
|
%cond.b = icmp ult i32 %truncated, 7
|
|
br i1 %cond.b, label %switch.lookup.b, label %for.inc
|
|
|
|
switch.lookup.b:
|
|
br label %for.inc
|
|
|
|
for.inc:
|
|
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
|
|
%cmp55 = icmp slt i64 %indvars.iv.next, 11
|
|
br i1 %cmp55, label %for.body.a, label %for.end
|
|
|
|
for.end:
|
|
unreachable
|
|
}
|