1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown | FileCheck %s
4 ; LSR's OptimizeMax function shouldn't try to eliminate this max, because
5 ; it has three operands.
7 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128"
9 define void @foo(ptr nocapture %p, i64 %x, i64 %y) nounwind {
11 ; CHECK: # %bb.0: # %entry
12 ; CHECK-NEXT: testq %rdx, %rdx
13 ; CHECK-NEXT: movl $1, %eax
14 ; CHECK-NEXT: cmovneq %rdx, %rax
15 ; CHECK-NEXT: cmpq %rsi, %rax
16 ; CHECK-NEXT: cmovbeq %rsi, %rax
17 ; CHECK-NEXT: .p2align 4, 0x90
18 ; CHECK-NEXT: .LBB0_1: # %bb4
19 ; CHECK-NEXT: # =>This Inner Loop Header: Depth=1
20 ; CHECK-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero
21 ; CHECK-NEXT: addsd %xmm0, %xmm0
22 ; CHECK-NEXT: movsd %xmm0, (%rdi)
23 ; CHECK-NEXT: addq $8, %rdi
24 ; CHECK-NEXT: decq %rax
25 ; CHECK-NEXT: jne .LBB0_1
26 ; CHECK-NEXT: # %bb.2: # %return
29 %tmp = icmp eq i64 %y, 0 ; <i1> [#uses=1]
30 %umax = select i1 %tmp, i64 1, i64 %y ; <i64> [#uses=2]
31 %tmp8 = icmp ugt i64 %umax, %x ; <i1> [#uses=1]
32 %umax9 = select i1 %tmp8, i64 %umax, i64 %x ; <i64> [#uses=1]
35 bb4: ; preds = %bb4, %entry
36 %i.07 = phi i64 [ 0, %entry ], [ %2, %bb4 ] ; <i64> [#uses=2]
37 %scevgep = getelementptr double, ptr %p, i64 %i.07 ; <ptr> [#uses=2]
38 %0 = load double, ptr %scevgep, align 8 ; <double> [#uses=1]
39 %1 = fmul double %0, 2.000000e+00 ; <double> [#uses=1]
40 store double %1, ptr %scevgep, align 8
41 %2 = add i64 %i.07, 1 ; <i64> [#uses=2]
42 %exitcond = icmp eq i64 %2, %umax9 ; <i1> [#uses=1]
43 br i1 %exitcond, label %return, label %bb4
45 return: ; preds = %bb4