[PowerPC] Eliminate compares - add i32 sext/zext handling for SETULT/SETUGT
[llvm-core.git] / test / Transforms / CorrelatedValuePropagation / ashr.ll
blob5e6bd1102b76976722a6879bd3932552b25ec748
1 ; RUN: opt < %s -correlated-propagation -S | FileCheck %s
3 ; CHECK-LABEL: @test1
4 define void @test1(i32 %n) {
5 entry:
6   br label %for.cond
8 for.cond:                                         ; preds = %for.body, %entry
9   %a = phi i32 [ %n, %entry ], [ %shr, %for.body ]
10   %cmp = icmp sgt i32 %a, 1
11   br i1 %cmp, label %for.body, label %for.end
13 for.body:                                         ; preds = %for.cond
14 ; CHECK: lshr i32 %a, 5
15   %shr = ashr i32 %a, 5
16   br label %for.cond
18 for.end:                                          ; preds = %for.cond
19   ret void
22 ;; Negative test to show transform doesn't happen unless n > 0.
23 ; CHECK-LABEL: @test2
24 define void @test2(i32 %n) {
25 entry:
26   br label %for.cond
28 for.cond:                                         ; preds = %for.body, %entry
29   %a = phi i32 [ %n, %entry ], [ %shr, %for.body ]
30   %cmp = icmp sgt i32 %a, -2
31   br i1 %cmp, label %for.body, label %for.end
33 for.body:                                         ; preds = %for.cond
34 ; CHECK: ashr i32 %a, 2
35   %shr = ashr i32 %a, 2
36   br label %for.cond
38 for.end:                                          ; preds = %for.cond
39   ret void
42 ;; Non looping test case.
43 ; CHECK-LABEL: @test3
44 define void @test3(i32 %n) {
45 entry:
46   %cmp = icmp sgt i32 %n, 0
47   br i1 %cmp, label %bb, label %exit
49 bb:
50 ; CHECK: lshr exact i32 %n, 4
51   %shr = ashr exact i32 %n, 4
52   br label %exit
54 exit:
55   ret void