1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 2; RUN: llc < %s -mtriple=x86_64-unknown-unknown | FileCheck %s 3 4; LSR's OptimizeMax function shouldn't try to eliminate this max, because 5; it has three operands. 6 7target 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" 8 9define void @foo(double* nocapture %p, i64 %x, i64 %y) nounwind { 10; CHECK-LABEL: foo: 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 27; CHECK-NEXT: retq 28entry: 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] 33 br label %bb4 34 35bb4: ; preds = %bb4, %entry 36 %i.07 = phi i64 [ 0, %entry ], [ %2, %bb4 ] ; <i64> [#uses=2] 37 %scevgep = getelementptr double, double* %p, i64 %i.07 ; <double*> [#uses=2] 38 %0 = load double, double* %scevgep, align 8 ; <double> [#uses=1] 39 %1 = fmul double %0, 2.000000e+00 ; <double> [#uses=1] 40 store double %1, double* %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 44 45return: ; preds = %bb4 46 ret void 47} 48 49