llvm-project

Форк
0
/
tlr_is_hoistable_load.ll 
71 строка · 2.6 Кб
1
; RUN: opt %loadPolly -polly-invariant-load-hoisting -polly-detect-full-functions -polly-print-scops -disable-output < %s | FileCheck %s
2
;
3
; This testcase checks for compatibility of the -detect-full-functions
4
; flag in combination with the -invariant-load-hoisting option. More
5
; specifically, ScopHelper.cpp::isHoistableLoad only gets called if
6
; -invariant-load-hoisting is enabled. This function, however, had a bug
7
; which caused a crash if the region argument was top-level. This test
8
; is a minimal example that hits this specific code path.
9
;
10
; Also note that this file's IR is in no way optimized, i.e. it was
11
; generated with clang -O0 from the following C-code:
12
;
13
;    void test() {
14
;      int A[] = {1, 2, 3, 4, 5};
15
;      int len = (sizeof A) / sizeof(int);
16
;      for (int i = 0; i < len; ++i) {
17
;        A[i] = A[i] * 2;
18
;      }
19
;    }
20
;
21
; This is also the reason why polly does not detect any scops (the loop
22
; variable i is loaded from and stored to memory in each iteration):
23
;
24
; CHECK:      region: 'for.cond => for.end' in function 'test':
25
; CHECK-NEXT: Invalid Scop!
26
; CHECK-NEXT: region: 'entry => <Function Return>' in function 'test':
27
; CHECK-NEXT: Invalid Scop!
28
;
29
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
30

31
@test.A = private unnamed_addr constant [5 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5], align 16
32

33
define void @test() {
34
entry:
35
  %A = alloca [5 x i32], align 16
36
  %len = alloca i32, align 4
37
  %i = alloca i32, align 4
38
  call void @llvm.memcpy.p0.p0.i64(ptr %A, ptr @test.A, i64 20, i32 16, i1 false)
39
  store i32 5, ptr %len, align 4
40
  store i32 0, ptr %i, align 4
41
  br label %for.cond
42

43
for.cond:                                         ; preds = %for.inc, %entry
44
  %0 = load i32, ptr %i, align 4
45
  %1 = load i32, ptr %len, align 4
46
  %cmp = icmp slt i32 %0, %1
47
  br i1 %cmp, label %for.body, label %for.end
48

49
for.body:                                         ; preds = %for.cond
50
  %2 = load i32, ptr %i, align 4
51
  %idxprom = sext i32 %2 to i64
52
  %arrayidx = getelementptr inbounds [5 x i32], ptr %A, i64 0, i64 %idxprom
53
  %3 = load i32, ptr %arrayidx, align 4
54
  %mul = mul nsw i32 %3, 2
55
  %4 = load i32, ptr %i, align 4
56
  %idxprom1 = sext i32 %4 to i64
57
  %arrayidx2 = getelementptr inbounds [5 x i32], ptr %A, i64 0, i64 %idxprom1
58
  store i32 %mul, ptr %arrayidx2, align 4
59
  br label %for.inc
60

61
for.inc:                                          ; preds = %for.body
62
  %5 = load i32, ptr %i, align 4
63
  %inc = add nsw i32 %5, 1
64
  store i32 %inc, ptr %i, align 4
65
  br label %for.cond
66

67
for.end:                                          ; preds = %for.cond
68
  ret void
69
}
70

71
declare void @llvm.memcpy.p0.p0.i64(ptr nocapture writeonly, ptr nocapture readonly, i64, i32, i1)
72

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.