1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=x86_64-apple-darwin | FileCheck %s
4 define void @redundant_add(i64 %n) {
5 ; Check that we don't create two additions for the sadd.with.overflow.
6 ; CHECK-LABEL: redundant_add:
7 ; CHECK: ## %bb.0: ## %entry
8 ; CHECK-NEXT: xorl %eax, %eax
9 ; CHECK-NEXT: .p2align 4, 0x90
10 ; CHECK-NEXT: LBB0_1: ## %exit_check
11 ; CHECK-NEXT: ## =>This Inner Loop Header: Depth=1
12 ; CHECK-NEXT: cmpq %rdi, %rax
13 ; CHECK-NEXT: jge LBB0_4
14 ; CHECK-NEXT: ## %bb.2: ## %loop
15 ; CHECK-NEXT: ## in Loop: Header=BB0_1 Depth=1
16 ; CHECK-NEXT: incq %rax
17 ; CHECK-NEXT: jno LBB0_1
18 ; CHECK-NEXT: ## %bb.3: ## %overflow
20 ; CHECK-NEXT: LBB0_4: ## %exit
26 %i = phi i64 [ 0, %entry ], [ %i.next, %loop ]
27 %c = icmp slt i64 %i, %n
28 br i1 %c, label %loop, label %exit
31 %i.o = tail call { i64, i1 } @llvm.sadd.with.overflow.i64(i64 %i, i64 1)
32 %i.next = extractvalue { i64, i1 } %i.o, 0
33 %o = extractvalue { i64, i1 } %i.o, 1
34 br i1 %o, label %overflow, label %exit_check
40 tail call void @llvm.trap()
44 declare { i64, i1 } @llvm.sadd.with.overflow.i64(i64, i64)
45 declare void @llvm.trap()