1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -mtriple=x86_64-linux -codegenprepare -S < %s | FileCheck %s
4 declare { i64, i1 } @llvm.uadd.with.overflow.i64(i64, i64)
6 define i32 @test_01(ptr %p, i64 %len, i32 %x) {
7 ; CHECK-LABEL: @test_01(
9 ; CHECK-NEXT: br label [[LOOP:%.*]]
11 ; CHECK-NEXT: [[IV:%.*]] = phi i64 [ [[MATH:%.*]], [[BACKEDGE:%.*]] ], [ [[LEN:%.*]], [[ENTRY:%.*]] ]
12 ; CHECK-NEXT: [[TMP0:%.*]] = call { i64, i1 } @llvm.uadd.with.overflow.i64(i64 [[IV]], i64 1)
13 ; CHECK-NEXT: [[MATH]] = extractvalue { i64, i1 } [[TMP0]], 0
14 ; CHECK-NEXT: [[OV:%.*]] = extractvalue { i64, i1 } [[TMP0]], 1
15 ; CHECK-NEXT: br i1 [[OV]], label [[EXIT:%.*]], label [[BACKEDGE]]
17 ; CHECK-NEXT: [[SUNKADDR3:%.*]] = mul i64 [[MATH]], 4
18 ; CHECK-NEXT: [[SUNKADDR4:%.*]] = getelementptr i8, ptr [[P:%.*]], i64 [[SUNKADDR3]]
19 ; CHECK-NEXT: [[LOADED:%.*]] = load atomic i32, ptr [[SUNKADDR4]] unordered, align 4
20 ; CHECK-NEXT: [[COND_2:%.*]] = icmp eq i32 [[LOADED]], [[X:%.*]]
21 ; CHECK-NEXT: br i1 [[COND_2]], label [[FAILURE:%.*]], label [[LOOP]]
23 ; CHECK-NEXT: ret i32 -1
25 ; CHECK-NEXT: unreachable
30 loop: ; preds = %backedge, %entry
31 %iv = phi i64 [ %math, %backedge ], [ %len, %entry ]
32 %0 = call { i64, i1 } @llvm.uadd.with.overflow.i64(i64 %iv, i64 1)
33 %math = extractvalue { i64, i1 } %0, 0
34 %ov = extractvalue { i64, i1 } %0, 1
35 br i1 %ov, label %exit, label %backedge
37 backedge: ; preds = %loop
38 %sunkaddr = mul i64 %iv, 4
39 %sunkaddr1 = getelementptr i8, ptr %p, i64 %sunkaddr
40 %sunkaddr2 = getelementptr i8, ptr %sunkaddr1, i64 4
41 %loaded = load atomic i32, ptr %sunkaddr2 unordered, align 4
42 %cond_2 = icmp eq i32 %loaded, %x
43 br i1 %cond_2, label %failure, label %loop
48 failure: ; preds = %backedge