1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 2; RUN: llc < %s -mtriple=x86_64-linux-gnu -o - | FileCheck %s 3 4; This test checks that only a single jae gets generated in the final code 5; for lowering the CMOV pseudos that get created for this IR. The tricky part 6; of this test is that it tests the special PHI operand rewriting code in 7; X86TargetLowering::EmitLoweredSelect. 8; 9define double @foo1(float %p1, double %p2, double %p3) nounwind { 10entry: 11 %c1 = fcmp oge float %p1, 0.000000e+00 12 %d0 = fadd double %p2, 1.25e0 13 %d1 = fadd double %p3, 1.25e0 14 %d2 = select i1 %c1, double %d0, double %d1 15 %d3 = select i1 %c1, double %d2, double %p2 16 %d4 = select i1 %c1, double %d3, double %p3 17 %d5 = fsub double %d2, %d3 18 %d6 = fadd double %d5, %d4 19 ret double %d6 20} 21 22; This test checks that only a single jae gets generated in the final code 23; for lowering the CMOV pseudos that get created for this IR. The tricky part 24; of this test is that it tests the special PHI operand rewriting code in 25; X86TargetLowering::EmitLoweredSelect. 26; 27define double @foo2(float %p1, double %p2, double %p3) nounwind { 28; CHECK-LABEL: foo2: 29; CHECK: # %bb.0: # %entry 30; CHECK-NEXT: xorps %xmm3, %xmm3 31; CHECK-NEXT: ucomiss %xmm3, %xmm0 32; CHECK-NEXT: movsd {{.*#+}} xmm0 = [1.25E+0,0.0E+0] 33; CHECK-NEXT: jae .LBB1_1 34; CHECK-NEXT: # %bb.2: # %entry 35; CHECK-NEXT: addsd %xmm0, %xmm2 36; CHECK-NEXT: movapd %xmm2, %xmm0 37; CHECK-NEXT: movapd %xmm2, %xmm1 38; CHECK-NEXT: jmp .LBB1_3 39; CHECK-NEXT: .LBB1_1: 40; CHECK-NEXT: addsd %xmm1, %xmm0 41; CHECK-NEXT: .LBB1_3: # %entry 42; CHECK-NEXT: subsd %xmm1, %xmm0 43; CHECK-NEXT: addsd %xmm2, %xmm0 44; CHECK-NEXT: retq 45entry: 46 %c1 = fcmp oge float %p1, 0.000000e+00 47 %d0 = fadd double %p2, 1.25e0 48 %d1 = fadd double %p3, 1.25e0 49 %d2 = select i1 %c1, double %d0, double %d1 50 %d3 = select i1 %c1, double %p2, double %d2 51 %d4 = select i1 %c1, double %p3, double %d3 52 %d5 = fsub double %d2, %d3 53 %d6 = fadd double %d5, %d4 54 ret double %d6 55} 56 57; This test checks that only a single js gets generated in the final code 58; for lowering the CMOV pseudos that get created for this IR. The tricky part 59; of this test is that it tests the special PHI operand rewriting code in 60; X86TargetLowering::EmitLoweredSelect. It also tests to make sure all 61; the operands of the resulting instructions are from the proper places. 62; 63define double @foo3(i32 %p1, double %p2, double %p3, 64; CHECK-LABEL: foo3: 65; CHECK: # %bb.0: # %entry 66; CHECK-NEXT: testl %edi, %edi 67; CHECK-NEXT: js .LBB2_2 68; CHECK-NEXT: # %bb.1: # %entry 69; CHECK-NEXT: movapd %xmm2, %xmm1 70; CHECK-NEXT: movapd %xmm2, %xmm0 71; CHECK-NEXT: .LBB2_2: # %entry 72; CHECK-NEXT: divsd %xmm1, %xmm0 73; CHECK-NEXT: retq 74 double %p4, double %p5) nounwind { 75entry: 76 %c1 = icmp slt i32 %p1, 0 77 %d2 = select i1 %c1, double %p2, double %p3 78 %d3 = select i1 %c1, double %p3, double %p4 79 %d4 = select i1 %c1, double %d2, double %d3 80 %d5 = fdiv double %d4, %d3 81 ret double %d5 82} 83 84; This test checks that only a single js gets generated in the final code 85; for lowering the CMOV pseudos that get created for this IR. The tricky part 86; of this test is that it tests the special PHI operand rewriting code in 87; X86TargetLowering::EmitLoweredSelect. It also tests to make sure all 88; the operands of the resulting instructions are from the proper places 89; when the "opposite condition" handling code in the compiler is used. 90; This should be the same code as foo3 above, because we use the opposite 91; condition code in the second two selects, but we also swap the operands 92; of the selects to give the same actual computation. 93; 94define double @foo4(i32 %p1, double %p2, double %p3, 95; CHECK-LABEL: foo4: 96; CHECK: # %bb.0: # %entry 97; CHECK-NEXT: testl %edi, %edi 98; CHECK-NEXT: js .LBB3_2 99; CHECK-NEXT: # %bb.1: # %entry 100; CHECK-NEXT: movapd %xmm2, %xmm1 101; CHECK-NEXT: movapd %xmm2, %xmm0 102; CHECK-NEXT: .LBB3_2: # %entry 103; CHECK-NEXT: divsd %xmm1, %xmm0 104; CHECK-NEXT: retq 105 double %p4, double %p5) nounwind { 106entry: 107 %c1 = icmp slt i32 %p1, 0 108 %d2 = select i1 %c1, double %p2, double %p3 109 %c2 = icmp sge i32 %p1, 0 110 %d3 = select i1 %c2, double %p4, double %p3 111 %d4 = select i1 %c2, double %d3, double %d2 112 %d5 = fdiv double %d4, %d3 113 ret double %d5 114} 115 116; This test checks that only a single jae gets generated in the final code 117; for lowering the CMOV pseudos that get created for this IR. The tricky part 118; of this test is that it tests the special code in CodeGenPrepare. 119; 120define double @foo5(float %p1, double %p2, double %p3) nounwind { 121; CHECK-LABEL: foo5: 122; CHECK: # %bb.0: # %entry 123; CHECK-NEXT: xorps %xmm3, %xmm3 124; CHECK-NEXT: ucomiss %xmm3, %xmm0 125; CHECK-NEXT: movsd {{.*#+}} xmm0 = [1.25E+0,0.0E+0] 126; CHECK-NEXT: jae .LBB4_1 127; CHECK-NEXT: # %bb.2: # %select.false 128; CHECK-NEXT: addsd %xmm2, %xmm0 129; CHECK-NEXT: .LBB4_3: # %select.end 130; CHECK-NEXT: subsd %xmm1, %xmm0 131; CHECK-NEXT: addsd %xmm2, %xmm0 132; CHECK-NEXT: retq 133; CHECK-NEXT: .LBB4_1: 134; CHECK-NEXT: addsd %xmm0, %xmm1 135; CHECK-NEXT: movapd %xmm1, %xmm0 136; CHECK-NEXT: movapd %xmm1, %xmm2 137; CHECK-NEXT: jmp .LBB4_3 138entry: 139 %c1 = fcmp oge float %p1, 0.000000e+00 140 %d0 = fadd double %p2, 1.25e0 141 %d1 = fadd double %p3, 1.25e0 142 %d2 = select i1 %c1, double %d0, double %d1, !prof !0 143 %d3 = select i1 %c1, double %d2, double %p2, !prof !0 144 %d4 = select i1 %c1, double %d3, double %p3, !prof !0 145 %d5 = fsub double %d2, %d3 146 %d6 = fadd double %d5, %d4 147 ret double %d6 148} 149 150; We should expand select instructions into 3 conditional branches as their 151; condtions are different. 152; 153define double @foo6(float %p1, double %p2, double %p3) nounwind { 154; CHECK-LABEL: foo6: 155; CHECK: # %bb.0: # %entry 156; CHECK-NEXT: movaps %xmm0, %xmm3 157; CHECK-NEXT: xorps %xmm0, %xmm0 158; CHECK-NEXT: ucomiss %xmm0, %xmm3 159; CHECK-NEXT: movsd {{.*#+}} xmm0 = [1.25E+0,0.0E+0] 160; CHECK-NEXT: jae .LBB5_1 161; CHECK-NEXT: # %bb.2: # %select.false 162; CHECK-NEXT: addsd %xmm2, %xmm0 163; CHECK-NEXT: .LBB5_3: # %select.end 164; CHECK-NEXT: ucomiss {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm3 165; CHECK-NEXT: movapd %xmm0, %xmm4 166; CHECK-NEXT: jae .LBB5_5 167; CHECK-NEXT: # %bb.4: # %select.false2 168; CHECK-NEXT: movapd %xmm1, %xmm4 169; CHECK-NEXT: .LBB5_5: # %select.end1 170; CHECK-NEXT: ucomiss {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm3 171; CHECK-NEXT: movapd %xmm4, %xmm1 172; CHECK-NEXT: jae .LBB5_7 173; CHECK-NEXT: # %bb.6: # %select.false4 174; CHECK-NEXT: movapd %xmm2, %xmm1 175; CHECK-NEXT: .LBB5_7: # %select.end3 176; CHECK-NEXT: subsd %xmm4, %xmm0 177; CHECK-NEXT: addsd %xmm1, %xmm0 178; CHECK-NEXT: retq 179; CHECK-NEXT: .LBB5_1: 180; CHECK-NEXT: addsd %xmm1, %xmm0 181; CHECK-NEXT: jmp .LBB5_3 182entry: 183 %c1 = fcmp oge float %p1, 0.000000e+00 184 %c2 = fcmp oge float %p1, 1.000000e+00 185 %c3 = fcmp oge float %p1, 2.000000e+00 186 %d0 = fadd double %p2, 1.25e0 187 %d1 = fadd double %p3, 1.25e0 188 %d2 = select i1 %c1, double %d0, double %d1, !prof !0 189 %d3 = select i1 %c2, double %d2, double %p2, !prof !0 190 %d4 = select i1 %c3, double %d3, double %p3, !prof !0 191 %d5 = fsub double %d2, %d3 192 %d6 = fadd double %d5, %d4 193 ret double %d6 194} 195 196declare void @llvm.dbg.value(metadata, metadata, metadata) 197 198; Like the test for @foo1, but check that the inserted dbg.value does not 199; affect codegen. The CHECK items below should always be identical to @foo1, 200; minus the DEBUG_VALUE line and changes in labels.. 201define double @foo1_g(float %p1, double %p2, double %p3) nounwind !dbg !4 { 202; CHECK-LABEL: foo1_g: 203; CHECK: # %bb.0: # %entry 204; CHECK-NEXT: .file 1 "." "test.c" 205; CHECK-NEXT: .loc 1 3 0 prologue_end 206; CHECK-NEXT: xorps %xmm3, %xmm3 207; CHECK-NEXT: ucomiss %xmm3, %xmm0 208; CHECK-NEXT: movsd {{.*#+}} xmm0 = [1.25E+0,0.0E+0] 209; CHECK-NEXT: jae .LBB6_1 210; CHECK-NEXT: # %bb.2: # %entry 211; CHECK-NEXT: addsd %xmm2, %xmm0 212; CHECK-NEXT: jmp .LBB6_3 213; CHECK-NEXT: .LBB6_1: 214; CHECK-NEXT: addsd %xmm0, %xmm1 215; CHECK-NEXT: movapd %xmm1, %xmm0 216; CHECK-NEXT: movapd %xmm1, %xmm2 217; CHECK-NEXT: .LBB6_3: # %entry 218; CHECK-NEXT: #DEBUG_VALUE: foobar:xyzzy <- undef 219; CHECK-NEXT: subsd %xmm1, %xmm0 220; CHECK-NEXT: addsd %xmm2, %xmm0 221; CHECK-NEXT: retq 222entry: 223 %c1 = fcmp oge float %p1, 0.000000e+00 224 %d0 = fadd double %p2, 1.25e0 225 %d1 = fadd double %p3, 1.25e0 226 %d2 = select i1 %c1, double %d0, double %d1 227 call void @llvm.dbg.value(metadata float undef, metadata !5, metadata !DIExpression()), !dbg !6 228 %d3 = select i1 %c1, double %d2, double %p2 229 %d4 = select i1 %c1, double %d3, double %p3 230 %d5 = fsub double %d2, %d3 231 %d6 = fadd double %d5, %d4 232 ret double %d6 233} 234 235!llvm.module.flags = !{!1} 236!llvm.dbg.cu = !{!2} 237 238!0 = !{!"branch_weights", i32 1, i32 2000} 239!1 = !{i32 2, !"Debug Info Version", i32 3} 240!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, nameTableKind: None) 241!3 = !DIFile(filename: "test.c", directory: ".") 242!4 = distinct !DISubprogram(name: "foobar", scope: !2, file: !3, line: 1, type: !9, scopeLine: 3, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !8) 243!5 = !DILocalVariable(name: "xyzzy", scope: !4, file: !3, line: 2, type: !7) 244!6 = !DILocation(line: 1, column: 1, scope: !4) 245!7 = !DIBasicType(name: "float", size: 32, encoding: DW_ATE_float) 246!8 = !{!5} 247!9 = !DISubroutineType(types: !10) 248!10 = !{!7} 249