1 ; RUN: llc < %s -mtriple=x86_64-apple-darwin | FileCheck %s 2 3 define void @redundant_add(i64 %n) { 4 ; Check that we don't create two additions for the sadd.with.overflow. 5 ; CHECK-LABEL: redundant_add 6 ; CHECK-NOT: leaq 7 ; CHECK-NOT: addq 8 ; CHECK: incq 9 ; CHECK-NEXT: jno 10 entry: 11 br label %exit_check 12 13 exit_check: 14 %i = phi i64 [ 0, %entry ], [ %i.next, %loop ] 15 %c = icmp slt i64 %i, %n 16 br i1 %c, label %loop, label %exit 17 18 loop: 19 %i.o = tail call { i64, i1 } @llvm.sadd.with.overflow.i64(i64 %i, i64 1) 20 %i.next = extractvalue { i64, i1 } %i.o, 0 21 %o = extractvalue { i64, i1 } %i.o, 1 22 br i1 %o, label %overflow, label %exit_check 23 24 exit: 25 ret void 26 27 overflow: 28 tail call void @llvm.trap() 29 unreachable 30 } 31 32 declare { i64, i1 } @llvm.sadd.with.overflow.i64(i64, i64) 33 declare void @llvm.trap() 34 35