xref: /aosp_15_r20/external/llvm/test/CodeGen/X86/lsr-nonaffine.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc -asm-verbose=false -march=x86-64 -mtriple=x86_64-apple-darwin -o - < %s | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Worker; LSR should leave non-affine expressions alone because it currently
4*9880d681SAndroid Build Coastguard Worker; doesn't know how to do anything with them, and when it tries, it
5*9880d681SAndroid Build Coastguard Worker; gets SCEVExpander's current expansion for them, which is suboptimal.
6*9880d681SAndroid Build Coastguard Worker
7*9880d681SAndroid Build Coastguard Worker; CHECK:        xorl %eax, %eax
8*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:   align
9*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: BB0_1:
10*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:   movq  %rax, (%rdx)
11*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:   addq  %rsi, %rax
12*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:   cmpq  %rdi, %rax
13*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:   jl
14*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:   imulq %rax, %rax
15*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:   ret
16*9880d681SAndroid Build Coastguard Workerdefine i64 @foo(i64 %n, i64 %s, i64* %p) nounwind {
17*9880d681SAndroid Build Coastguard Workerentry:
18*9880d681SAndroid Build Coastguard Worker  br label %loop
19*9880d681SAndroid Build Coastguard Worker
20*9880d681SAndroid Build Coastguard Workerloop:
21*9880d681SAndroid Build Coastguard Worker  %i = phi i64 [ 0, %entry ], [ %i.next, %loop ]
22*9880d681SAndroid Build Coastguard Worker  store volatile i64 %i, i64* %p
23*9880d681SAndroid Build Coastguard Worker  %i.next = add i64 %i, %s
24*9880d681SAndroid Build Coastguard Worker  %c = icmp slt i64 %i.next, %n
25*9880d681SAndroid Build Coastguard Worker  br i1 %c, label %loop, label %exit
26*9880d681SAndroid Build Coastguard Worker
27*9880d681SAndroid Build Coastguard Workerexit:
28*9880d681SAndroid Build Coastguard Worker  %mul = mul i64 %i.next, %i.next
29*9880d681SAndroid Build Coastguard Worker  ret i64 %mul
30*9880d681SAndroid Build Coastguard Worker}
31