1# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py 2# RUN: llc -mtriple aarch64 -run-pass=aarch64-prelegalizer-combiner -verify-machineinstrs %s -o - | FileCheck %s 3 4name: or_same 5tracksRegLiveness: true 6body: | 7 bb.0: 8 liveins: $x0 9 10 ; Fold: x or x -> x 11 ; CHECK-LABEL: name: or_same 12 ; CHECK: liveins: $x0 13 ; CHECK: %copy:_(s64) = COPY $x0 14 ; CHECK: $x0 = COPY %copy(s64) 15 ; CHECK: RET_ReallyLR implicit $x0 16 %copy:_(s64) = COPY $x0 17 %or:_(s64) = G_OR %copy, %copy 18 $x0 = COPY %or(s64) 19 RET_ReallyLR implicit $x0 20 21... 22--- 23name: and_same 24tracksRegLiveness: true 25body: | 26 bb.0: 27 liveins: $x0 28 29 ; Fold: x and x -> x 30 31 ; CHECK-LABEL: name: and_same 32 ; CHECK: liveins: $x0 33 ; CHECK: %copy:_(s64) = COPY $x0 34 ; CHECK: $x0 = COPY %copy(s64) 35 ; CHECK: RET_ReallyLR implicit $x0 36 %copy:_(s64) = COPY $x0 37 %and:_(s64) = G_AND %copy, %copy 38 $x0 = COPY %and(s64) 39 RET_ReallyLR implicit $x0 40 41... 42--- 43name: and_same2 44tracksRegLiveness: true 45body: | 46 bb.0: 47 liveins: $x0, $x1 48 49 ; We can fold when the LHS and RHS are guaranteed to be identical. 50 51 ; CHECK-LABEL: name: and_same2 52 ; CHECK: liveins: $x0, $x1 53 ; CHECK: %copy1:_(s64) = COPY $x0 54 ; CHECK: %copy2:_(s64) = COPY $x1 55 ; CHECK: %or:_(s64) = G_OR %copy1, %copy2 56 ; CHECK: $x0 = COPY %or(s64) 57 ; CHECK: RET_ReallyLR implicit $x0 58 %copy1:_(s64) = COPY $x0 59 %copy2:_(s64) = COPY $x1 60 %or:_(s64) = G_OR %copy1, %copy2 61 %same_as_or:_(s64) = COPY %or(s64) 62 %and:_(s64) = G_AND %or, %same_as_or 63 $x0 = COPY %and(s64) 64 RET_ReallyLR implicit $x0 65 66... 67--- 68name: or_and_not_same 69tracksRegLiveness: true 70body: | 71 bb.0: 72 liveins: $x0, $x1, $x2 73 74 ; None of the G_ORs or G_ANDs should be eliminated here, because their LHS 75 ; and RHS values are different. 76 77 ; CHECK-LABEL: name: or_and_not_same 78 ; CHECK: liveins: $x0, $x1, $x2 79 ; CHECK: %copy1:_(s64) = COPY $x0 80 ; CHECK: %copy2:_(s64) = COPY $x1 81 ; CHECK: %copy3:_(s64) = COPY $x2 82 ; CHECK: %or1:_(s64) = G_OR %copy1, %copy2 83 ; CHECK: %or2:_(s64) = G_OR %copy1, %copy3 84 ; CHECK: %and:_(s64) = G_AND %or1, %or2 85 ; CHECK: $x0 = COPY %and(s64) 86 ; CHECK: RET_ReallyLR implicit $x0 87 %copy1:_(s64) = COPY $x0 88 %copy2:_(s64) = COPY $x1 89 %copy3:_(s64) = COPY $x2 90 %or1:_(s64) = G_OR %copy1, %copy2 91 %or2:_(s64) = G_OR %copy1, %copy3 92 %and:_(s64) = G_AND %or1, %or2 93 $x0 = COPY %and(s64) 94 RET_ReallyLR implicit $x0 95 96... 97