1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 2; RUN: llc < %s -mtriple=x86_64-apple-darwin | FileCheck %s 3 4define 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 19; CHECK-NEXT: ud2 20; CHECK-NEXT: LBB0_4: ## %exit 21; CHECK-NEXT: retq 22entry: 23 br label %exit_check 24 25exit_check: 26 %i = phi i64 [ 0, %entry ], [ %i.next, %loop ] 27 %c = icmp slt i64 %i, %n 28 br i1 %c, label %loop, label %exit 29 30loop: 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 35 36exit: 37 ret void 38 39overflow: 40 tail call void @llvm.trap() 41 unreachable 42} 43 44declare { i64, i1 } @llvm.sadd.with.overflow.i64(i64, i64) 45declare void @llvm.trap() 46 47