Jacques Pienaar | 0dbcc34 | 2017-05-09 18:35:26 +0000 | [diff] [blame] | 1 | ; RUN: llc < %s | FileCheck %s |
| 2 | |
| 3 | ; Test that unnecessary masking with 0x1 is not inserted. |
| 4 | |
| 5 | target datalayout = "E-m:e-p:32:32-i64:64-a:0:32-n32-S64" |
| 6 | target triple = "lanai" |
| 7 | |
| 8 | ; CHECK-LABEL: masking: |
| 9 | ; CHECK-NOT: mov 1 |
| 10 | define i32 @masking(i32 inreg %a, i32 inreg %b, i32 inreg %c, i32 inreg %d) { |
| 11 | entry: |
| 12 | %cmp = icmp ne i32 %a, 0 |
| 13 | %cmp1 = icmp ult i32 %a, %b |
| 14 | %or.cond = and i1 %cmp, %cmp1 |
| 15 | br i1 %or.cond, label %return, label %if.end |
| 16 | |
| 17 | if.end: ; preds = %entry |
| 18 | %cmp2 = icmp ne i32 %b, 0 |
| 19 | %cmp4 = icmp ult i32 %b, %c |
| 20 | %or.cond29 = and i1 %cmp2, %cmp4 |
| 21 | br i1 %or.cond29, label %return, label %if.end6 |
| 22 | |
| 23 | if.end6: ; preds = %if.end |
| 24 | %cmp7 = icmp ne i32 %c, 0 |
| 25 | %cmp9 = icmp ult i32 %c, %d |
| 26 | %or.cond30 = and i1 %cmp7, %cmp9 |
| 27 | br i1 %or.cond30, label %return, label %if.end11 |
| 28 | |
| 29 | if.end11: ; preds = %if.end6 |
| 30 | %cmp12 = icmp ne i32 %d, 0 |
| 31 | %cmp14 = icmp ult i32 %d, %a |
| 32 | %or.cond31 = and i1 %cmp12, %cmp14 |
| 33 | %b. = select i1 %or.cond31, i32 %b, i32 21 |
| 34 | ret i32 %b. |
| 35 | |
| 36 | return: ; preds = %if.end6, %if.end, %entry |
| 37 | %retval.0 = phi i32 [ %c, %entry ], [ %d, %if.end ], [ %a, %if.end6 ] |
| 38 | ret i32 %retval.0 |
| 39 | } |
| 40 | |
| 41 | ; CHECK-LABEL: notnot: |
| 42 | ; CHECK-NOT: mov 1 |
| 43 | define i32 @notnot(i32 %x) { |
| 44 | entry: |
| 45 | %tobool = icmp ne i32 %x, 0 |
| 46 | %lnot.ext = zext i1 %tobool to i32 |
| 47 | ret i32 %lnot.ext |
| 48 | } |