diff options
| author | Sanjay Patel <spatel@rotateright.com> | 2019-02-20 15:40:58 +0000 | 
|---|---|---|
| committer | Sanjay Patel <spatel@rotateright.com> | 2019-02-20 15:40:58 +0000 | 
| commit | 8d91faa48138e04910fc7ad0b4e139e3f82d4fd1 (patch) | |
| tree | 84eb82ef1ceb33564249e4ff63a75216740ddbc4 /llvm/test | |
| parent | 1498a59d9b283ef54e403e13da369f669530cb88 (diff) | |
| download | bcm5719-llvm-8d91faa48138e04910fc7ad0b4e139e3f82d4fd1.tar.gz bcm5719-llvm-8d91faa48138e04910fc7ad0b4e139e3f82d4fd1.zip | |
[CGP][x86] add tests for usubo special-case; NFC
This is another example from PR31754:
https://bugs.llvm.org/show_bug.cgi?id=31754
llvm-svn: 354475
Diffstat (limited to 'llvm/test')
| -rw-r--r-- | llvm/test/CodeGen/X86/cgp-usubo.ll | 35 | ||||
| -rw-r--r-- | llvm/test/Transforms/CodeGenPrepare/X86/overflow-intrinsics.ll | 15 | 
2 files changed, 41 insertions, 9 deletions
| diff --git a/llvm/test/CodeGen/X86/cgp-usubo.ll b/llvm/test/CodeGen/X86/cgp-usubo.ll index 3554f19fcfe..ba804282364 100644 --- a/llvm/test/CodeGen/X86/cgp-usubo.ll +++ b/llvm/test/CodeGen/X86/cgp-usubo.ll @@ -106,6 +106,23 @@ define i1 @usubo_eq_constant1_op1_i32(i32 %x, i32* %p) nounwind {    ret i1 %ov  } +; Special-case: subtract from 0 (negate) changes the compare predicate. + +define i1 @usubo_ne_constant0_op1_i32(i32 %x, i32* %p) { +; CHECK-LABEL: usubo_ne_constant0_op1_i32: +; CHECK:       # %bb.0: +; CHECK-NEXT:    movl %edi, %ecx +; CHECK-NEXT:    negl %ecx +; CHECK-NEXT:    testl %edi, %edi +; CHECK-NEXT:    setne %al +; CHECK-NEXT:    movl %ecx, (%rsi) +; CHECK-NEXT:    retq +  %s = sub i32 0, %x +  %ov = icmp ne i32 %x, 0 +  store i32 %s, i32* %p +  ret i1 %ov +} +  ; Verify insertion point for multi-BB.  declare void @call(i1) @@ -114,16 +131,16 @@ define i1 @usubo_ult_sub_dominates_i64(i64 %x, i64 %y, i64* %p, i1 %cond) nounwi  ; CHECK-LABEL: usubo_ult_sub_dominates_i64:  ; CHECK:       # %bb.0: # %entry  ; CHECK-NEXT:    testb $1, %cl -; CHECK-NEXT:    je .LBB7_2 +; CHECK-NEXT:    je .LBB8_2  ; CHECK-NEXT:  # %bb.1: # %t  ; CHECK-NEXT:    subq %rsi, %rdi  ; CHECK-NEXT:    setb %al  ; CHECK-NEXT:    movq %rdi, (%rdx)  ; CHECK-NEXT:    testb $1, %cl -; CHECK-NEXT:    jne .LBB7_3 -; CHECK-NEXT:  .LBB7_2: # %f +; CHECK-NEXT:    jne .LBB8_3 +; CHECK-NEXT:  .LBB8_2: # %f  ; CHECK-NEXT:    movl %ecx, %eax -; CHECK-NEXT:  .LBB7_3: # %end +; CHECK-NEXT:  .LBB8_3: # %end  ; CHECK-NEXT:    retq  entry:    br i1 %cond, label %t, label %f @@ -151,7 +168,7 @@ define i1 @usubo_ult_cmp_dominates_i64(i64 %x, i64 %y, i64* %p, i1 %cond) nounwi  ; CHECK-NEXT:    pushq %rax  ; CHECK-NEXT:    movl %ecx, %ebp  ; CHECK-NEXT:    testb $1, %bpl -; CHECK-NEXT:    je .LBB8_2 +; CHECK-NEXT:    je .LBB9_2  ; CHECK-NEXT:  # %bb.1: # %t  ; CHECK-NEXT:    movq %rdx, %r14  ; CHECK-NEXT:    movq %rsi, %r15 @@ -161,14 +178,14 @@ define i1 @usubo_ult_cmp_dominates_i64(i64 %x, i64 %y, i64* %p, i1 %cond) nounwi  ; CHECK-NEXT:    setb %dil  ; CHECK-NEXT:    callq call  ; CHECK-NEXT:    subq %r15, %rbx -; CHECK-NEXT:    jae .LBB8_2 +; CHECK-NEXT:    jae .LBB9_2  ; CHECK-NEXT:  # %bb.4: # %end  ; CHECK-NEXT:    setb %al  ; CHECK-NEXT:    movq %rbx, (%r14) -; CHECK-NEXT:    jmp .LBB8_3 -; CHECK-NEXT:  .LBB8_2: # %f +; CHECK-NEXT:    jmp .LBB9_3 +; CHECK-NEXT:  .LBB9_2: # %f  ; CHECK-NEXT:    movl %ebp, %eax -; CHECK-NEXT:  .LBB8_3: # %f +; CHECK-NEXT:  .LBB9_3: # %f  ; CHECK-NEXT:    addq $8, %rsp  ; CHECK-NEXT:    popq %rbx  ; CHECK-NEXT:    popq %r14 diff --git a/llvm/test/Transforms/CodeGenPrepare/X86/overflow-intrinsics.ll b/llvm/test/Transforms/CodeGenPrepare/X86/overflow-intrinsics.ll index 4661106a89e..5107e833ecf 100644 --- a/llvm/test/Transforms/CodeGenPrepare/X86/overflow-intrinsics.ll +++ b/llvm/test/Transforms/CodeGenPrepare/X86/overflow-intrinsics.ll @@ -281,6 +281,21 @@ define i1 @usubo_eq_constant1_op1_i32(i32 %x, i32* %p) {    ret i1 %ov  } +; Special-case: subtract from 0 (negate) changes the compare predicate. + +define i1 @usubo_ne_constant0_op1_i32(i32 %x, i32* %p) { +; CHECK-LABEL: @usubo_ne_constant0_op1_i32( +; CHECK-NEXT:    [[S:%.*]] = sub i32 0, [[X:%.*]] +; CHECK-NEXT:    [[OV:%.*]] = icmp ne i32 [[X]], 0 +; CHECK-NEXT:    store i32 [[S]], i32* [[P:%.*]] +; CHECK-NEXT:    ret i1 [[OV]] +; +  %s = sub i32 0, %x +  %ov = icmp ne i32 %x, 0 +  store i32 %s, i32* %p +  ret i1 %ov +} +  ; Verify insertion point for multi-BB.  declare void @call(i1) | 

