Eric Christopher | cee313d | 2019-04-17 04:52:47 +0000 | [diff] [blame] | 1 | ; RUN: opt -codegenprepare -S < %s | FileCheck %s |
| 2 | |
| 3 | target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64" |
| 4 | target triple = "thumbv8m.main-arm-none-eabi" |
| 5 | |
| 6 | ; CHECK-LABEL: uadd_overflow_too_far_cmp_dom |
| 7 | ; CHECK-NOT: with.overflow.i32 |
| 8 | define i32 @uadd_overflow_too_far_cmp_dom(i32 %arg0) { |
| 9 | entry: |
| 10 | %cmp = icmp ne i32 %arg0, 0 |
| 11 | br i1 %cmp, label %if.else, label %if.then |
| 12 | |
| 13 | if.then: |
| 14 | call void @foo() |
| 15 | br label %exit |
| 16 | |
| 17 | if.else: |
| 18 | call void @bar() |
| 19 | br label %if.end |
| 20 | |
| 21 | if.end: |
| 22 | %dec = add nsw i32 %arg0, -1 |
| 23 | br label %exit |
| 24 | |
| 25 | exit: |
| 26 | %res = phi i32 [ %arg0, %if.then ], [ %dec, %if.end ] |
| 27 | ret i32 %res |
| 28 | } |
| 29 | |
| 30 | ; CHECK-LABEL: uadd_overflow_too_far_math_dom |
| 31 | ; CHECK-NOT: with.overflow.i32 |
| 32 | define i32 @uadd_overflow_too_far_math_dom(i32 %arg0, i32 %arg1) { |
| 33 | entry: |
| 34 | %dec = add nsw i32 %arg0, -1 |
| 35 | %cmp = icmp ugt i32 %arg0, 1 |
| 36 | br i1 %cmp, label %if.else, label %if.then |
| 37 | |
| 38 | if.then: |
| 39 | call void @foo() |
| 40 | br label %if.end |
| 41 | |
| 42 | if.else: |
| 43 | call void @bar() |
| 44 | br label %if.end |
| 45 | |
| 46 | if.end: |
| 47 | %cmp.i.i = icmp ne i32 %arg0, 0 |
| 48 | %tobool = zext i1 %cmp.i.i to i32 |
| 49 | br label %exit |
| 50 | |
| 51 | exit: |
| 52 | ret i32 %tobool |
| 53 | } |
| 54 | |
| 55 | declare void @foo() |
| 56 | declare void @bar() |