Dan Gohman | 6665b0e | 2009-10-26 21:55:43 +0000 | [diff] [blame] | 1 | ; RUN: opt < %s -aa-eval -print-all-alias-modref-info -disable-output \ |
| 2 | ; RUN: |& grep {NoAlias: double\\* \[%\]a, double\\* \[%\]b\$} | count 4 |
| 3 | |
| 4 | ; BasicAA should detect NoAliases in PHIs and Selects. |
| 5 | |
| 6 | ; Two PHIs in the same block. |
| 7 | define void @foo(i1 %m, double* noalias %x, double* noalias %y) { |
| 8 | entry: |
| 9 | br i1 %m, label %true, label %false |
| 10 | |
| 11 | true: |
| 12 | br label %exit |
| 13 | |
| 14 | false: |
| 15 | br label %exit |
| 16 | |
| 17 | exit: |
| 18 | %a = phi double* [ %x, %true ], [ %y, %false ] |
| 19 | %b = phi double* [ %x, %false ], [ %y, %true ] |
| 20 | volatile store double 0.0, double* %a |
| 21 | volatile store double 1.0, double* %b |
| 22 | ret void |
| 23 | } |
| 24 | |
| 25 | ; Two selects with the same condition. |
| 26 | define void @bar(i1 %m, double* noalias %x, double* noalias %y) { |
| 27 | entry: |
| 28 | %a = select i1 %m, double* %x, double* %y |
| 29 | %b = select i1 %m, double* %y, double* %x |
| 30 | volatile store double 0.000000e+00, double* %a |
| 31 | volatile store double 1.000000e+00, double* %b |
| 32 | ret void |
| 33 | } |
| 34 | |
| 35 | ; Two PHIs with disjoint sets of inputs. |
| 36 | define void @qux(i1 %m, double* noalias %x, double* noalias %y, |
| 37 | i1 %n, double* noalias %v, double* noalias %w) { |
| 38 | entry: |
| 39 | br i1 %m, label %true, label %false |
| 40 | |
| 41 | true: |
| 42 | br label %exit |
| 43 | |
| 44 | false: |
| 45 | br label %exit |
| 46 | |
| 47 | exit: |
| 48 | %a = phi double* [ %x, %true ], [ %y, %false ] |
| 49 | br i1 %n, label %ntrue, label %nfalse |
| 50 | |
| 51 | ntrue: |
| 52 | br label %nexit |
| 53 | |
| 54 | nfalse: |
| 55 | br label %nexit |
| 56 | |
| 57 | nexit: |
| 58 | %b = phi double* [ %v, %ntrue ], [ %w, %nfalse ] |
| 59 | volatile store double 0.0, double* %a |
| 60 | volatile store double 1.0, double* %b |
| 61 | ret void |
| 62 | } |
| 63 | |
| 64 | ; Two selects with disjoint sets of arms. |
| 65 | define void @fin(i1 %m, double* noalias %x, double* noalias %y, |
| 66 | i1 %n, double* noalias %v, double* noalias %w) { |
| 67 | entry: |
| 68 | %a = select i1 %m, double* %x, double* %y |
| 69 | %b = select i1 %n, double* %v, double* %w |
| 70 | volatile store double 0.000000e+00, double* %a |
| 71 | volatile store double 1.000000e+00, double* %b |
| 72 | ret void |
| 73 | } |