1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=aarch64-linux-gnu %s -o - | FileCheck %s
4 ; The test cases in this file check following transformation if the right form
6 ; A - (B + C) ==> (A - B) - C
9 define i32 @test1(i32 %a, i32 %b, i32 %c) {
11 ; CHECK: // %bb.0: // %entry
12 ; CHECK-NEXT: add w8, w0, #100
13 ; CHECK-NEXT: orr w9, w2, #0x80
14 ; CHECK-NEXT: eor w10, w1, w8, lsl #8
15 ; CHECK-NEXT: sub w8, w9, w8
16 ; CHECK-NEXT: sub w8, w8, w10
17 ; CHECK-NEXT: eor w0, w8, w10, asr #13
23 %xor = xor i32 %shl, %b
24 %add = add i32 %xor, %a1
25 %sub = sub i32 %c1, %add
26 %shr = ashr i32 %xor, 13
27 %xor2 = xor i32 %sub, %shr
32 define i64 @test2(i64 %a, i64 %b, i64 %c) {
34 ; CHECK: // %bb.0: // %entry
35 ; CHECK-NEXT: add x8, x0, #100
36 ; CHECK-NEXT: orr x9, x2, #0x80
37 ; CHECK-NEXT: eor x10, x1, x8, lsl #8
38 ; CHECK-NEXT: sub x8, x9, x8
39 ; CHECK-NEXT: sub x8, x8, x10
40 ; CHECK-NEXT: eor x0, x8, x10, asr #13
46 %xor = xor i64 %shl, %b
47 %add = add i64 %xor, %a1
48 %sub = sub i64 %c1, %add
49 %shr = ashr i64 %xor, 13
50 %xor2 = xor i64 %sub, %shr
54 ; Negative test. The right form can't reduce latency.
55 define i32 @test3(i32 %a, i32 %b, i32 %c) {
57 ; CHECK: // %bb.0: // %entry
58 ; CHECK-NEXT: add w8, w0, #100
59 ; CHECK-NEXT: orr w9, w2, #0x80
60 ; CHECK-NEXT: eor w10, w1, w8, lsl #8
61 ; CHECK-NEXT: add w8, w9, w8
62 ; CHECK-NEXT: sub w8, w10, w8
63 ; CHECK-NEXT: eor w0, w8, w10, asr #13
69 %xor = xor i32 %shl, %b
70 %add = add i32 %c1, %a1
71 %sub = sub i32 %xor, %add
72 %shr = ashr i32 %xor, 13
73 %xor2 = xor i32 %sub, %shr