[llvm] r340217 - [X86] Add test command line to expose PR38649.
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 20 14:51:36 PDT 2018
Author: ctopper
Date: Mon Aug 20 14:51:35 2018
New Revision: 340217
URL: http://llvm.org/viewvc/llvm-project?rev=340217&view=rev
Log:
[X86] Add test command line to expose PR38649.
Bypass slow division and constant hoisting are conspiring to break div+rem of large constants.
Modified:
llvm/trunk/test/CodeGen/X86/divide-by-constant.ll
Modified: llvm/trunk/test/CodeGen/X86/divide-by-constant.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/divide-by-constant.ll?rev=340217&r1=340216&r2=340217&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/divide-by-constant.ll (original)
+++ llvm/trunk/test/CodeGen/X86/divide-by-constant.ll Mon Aug 20 14:51:35 2018
@@ -1,6 +1,7 @@
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc < %s -mtriple=i686-pc-linux-gnu | FileCheck %s --check-prefix=X32
-; RUN: llc < %s -mtriple=x86_64-pc-linux-gnu | FileCheck %s --check-prefix=X64
+; RUN: llc < %s -mtriple=x86_64-pc-linux-gnu | FileCheck %s --check-prefix=X64 --check-prefix=X64-FAST
+; RUN: llc < %s -mtriple=x86_64-pc-linux-gnu -mattr=idivq-to-divl | FileCheck %s --check-prefix=X64 --check-prefix=X64-SLOW
define zeroext i16 @test1(i16 zeroext %x) nounwind {
; X32-LABEL: test1:
@@ -308,23 +309,41 @@ define i64 @PR23590(i64 %x) nounwind {
; X32-NEXT: addl $28, %esp
; X32-NEXT: retl
;
-; X64-LABEL: PR23590:
-; X64: # %bb.0: # %entry
-; X64-NEXT: movq %rdi, %rcx
-; X64-NEXT: movabsq $6120523590596543007, %rdx # imm = 0x54F077C718E7C21F
-; X64-NEXT: movq %rdi, %rax
-; X64-NEXT: mulq %rdx
-; X64-NEXT: shrq $12, %rdx
-; X64-NEXT: imulq $12345, %rdx, %rax # imm = 0x3039
-; X64-NEXT: subq %rax, %rcx
-; X64-NEXT: movabsq $2635249153387078803, %rdx # imm = 0x2492492492492493
-; X64-NEXT: movq %rcx, %rax
-; X64-NEXT: mulq %rdx
-; X64-NEXT: subq %rdx, %rcx
-; X64-NEXT: shrq %rcx
-; X64-NEXT: leaq (%rcx,%rdx), %rax
-; X64-NEXT: shrq $2, %rax
-; X64-NEXT: retq
+; X64-FAST-LABEL: PR23590:
+; X64-FAST: # %bb.0: # %entry
+; X64-FAST-NEXT: movq %rdi, %rcx
+; X64-FAST-NEXT: movabsq $6120523590596543007, %rdx # imm = 0x54F077C718E7C21F
+; X64-FAST-NEXT: movq %rdi, %rax
+; X64-FAST-NEXT: mulq %rdx
+; X64-FAST-NEXT: shrq $12, %rdx
+; X64-FAST-NEXT: imulq $12345, %rdx, %rax # imm = 0x3039
+; X64-FAST-NEXT: subq %rax, %rcx
+; X64-FAST-NEXT: movabsq $2635249153387078803, %rdx # imm = 0x2492492492492493
+; X64-FAST-NEXT: movq %rcx, %rax
+; X64-FAST-NEXT: mulq %rdx
+; X64-FAST-NEXT: subq %rdx, %rcx
+; X64-FAST-NEXT: shrq %rcx
+; X64-FAST-NEXT: leaq (%rcx,%rdx), %rax
+; X64-FAST-NEXT: shrq $2, %rax
+; X64-FAST-NEXT: retq
+;
+; X64-SLOW-LABEL: PR23590:
+; X64-SLOW: # %bb.0: # %entry
+; X64-SLOW-NEXT: movq %rdi, %rcx
+; X64-SLOW-NEXT: movabsq $6120523590596543007, %rdx # imm = 0x54F077C718E7C21F
+; X64-SLOW-NEXT: movq %rdi, %rax
+; X64-SLOW-NEXT: mulq %rdx
+; X64-SLOW-NEXT: shrq $12, %rdx
+; X64-SLOW-NEXT: imulq $12345, %rdx, %rax # imm = 0x3039
+; X64-SLOW-NEXT: subq %rax, %rcx
+; X64-SLOW-NEXT: imulq $613566757, %rcx, %rax # imm = 0x24924925
+; X64-SLOW-NEXT: shrq $32, %rax
+; X64-SLOW-NEXT: subl %eax, %ecx
+; X64-SLOW-NEXT: shrl %ecx
+; X64-SLOW-NEXT: addl %eax, %ecx
+; X64-SLOW-NEXT: shrl $2, %ecx
+; X64-SLOW-NEXT: movq %rcx, %rax
+; X64-SLOW-NEXT: retq
entry:
%rem = urem i64 %x, 12345
%div = udiv i64 %rem, 7
@@ -365,18 +384,39 @@ define { i64, i32 } @PR38622(i64) nounwi
; X32-NEXT: popl %ebp
; X32-NEXT: retl
;
-; X64-LABEL: PR38622:
-; X64: # %bb.0:
-; X64-NEXT: movq %rdi, %rax
-; X64-NEXT: shrq $11, %rax
-; X64-NEXT: movabsq $4835703278458517, %rcx # imm = 0x112E0BE826D695
-; X64-NEXT: mulq %rcx
-; X64-NEXT: shrq $9, %rdx
-; X64-NEXT: imull $-294967296, %edx, %eax # imm = 0xEE6B2800
-; X64-NEXT: subl %eax, %edi
-; X64-NEXT: movq %rdx, %rax
-; X64-NEXT: movl %edi, %edx
-; X64-NEXT: retq
+; X64-FAST-LABEL: PR38622:
+; X64-FAST: # %bb.0:
+; X64-FAST-NEXT: movq %rdi, %rax
+; X64-FAST-NEXT: shrq $11, %rax
+; X64-FAST-NEXT: movabsq $4835703278458517, %rcx # imm = 0x112E0BE826D695
+; X64-FAST-NEXT: mulq %rcx
+; X64-FAST-NEXT: shrq $9, %rdx
+; X64-FAST-NEXT: imull $-294967296, %edx, %eax # imm = 0xEE6B2800
+; X64-FAST-NEXT: subl %eax, %edi
+; X64-FAST-NEXT: movq %rdx, %rax
+; X64-FAST-NEXT: movl %edi, %edx
+; X64-FAST-NEXT: retq
+;
+; X64-SLOW-LABEL: PR38622:
+; X64-SLOW: # %bb.0:
+; X64-SLOW-NEXT: movl $4000000000, %ecx # imm = 0xEE6B2800
+; X64-SLOW-NEXT: movq %rdi, %rax
+; X64-SLOW-NEXT: shrq $32, %rax
+; X64-SLOW-NEXT: je .LBB14_1
+; X64-SLOW-NEXT: # %bb.2:
+; X64-SLOW-NEXT: xorl %edx, %edx
+; X64-SLOW-NEXT: movq %rdi, %rax
+; X64-SLOW-NEXT: divq %rcx
+; X64-SLOW-NEXT: # kill: def $edx killed $edx killed $rdx
+; X64-SLOW-NEXT: retq
+; X64-SLOW-NEXT: .LBB14_1:
+; X64-SLOW-NEXT: xorl %edx, %edx
+; X64-SLOW-NEXT: movl %edi, %eax
+; X64-SLOW-NEXT: divl %ecx
+; X64-SLOW-NEXT: # kill: def $edx killed $edx def $rdx
+; X64-SLOW-NEXT: # kill: def $eax killed $eax def $rax
+; X64-SLOW-NEXT: # kill: def $edx killed $edx killed $rdx
+; X64-SLOW-NEXT: retq
%2 = udiv i64 %0, 4000000000
%3 = urem i64 %0, 4000000000
%4 = trunc i64 %3 to i32
@@ -419,20 +459,41 @@ define { i64, i32 } @PR38622_signed(i64)
; X32-NEXT: popl %ebp
; X32-NEXT: retl
;
-; X64-LABEL: PR38622_signed:
-; X64: # %bb.0:
-; X64-NEXT: movabsq $1237940039285380275, %rcx # imm = 0x112E0BE826D694B3
-; X64-NEXT: movq %rdi, %rax
-; X64-NEXT: imulq %rcx
-; X64-NEXT: movq %rdx, %rcx
-; X64-NEXT: shrq $63, %rcx
-; X64-NEXT: sarq $28, %rdx
-; X64-NEXT: leaq (%rdx,%rcx), %rax
-; X64-NEXT: addl %ecx, %edx
-; X64-NEXT: imull $-294967296, %edx, %ecx # imm = 0xEE6B2800
-; X64-NEXT: subl %ecx, %edi
-; X64-NEXT: movl %edi, %edx
-; X64-NEXT: retq
+; X64-FAST-LABEL: PR38622_signed:
+; X64-FAST: # %bb.0:
+; X64-FAST-NEXT: movabsq $1237940039285380275, %rcx # imm = 0x112E0BE826D694B3
+; X64-FAST-NEXT: movq %rdi, %rax
+; X64-FAST-NEXT: imulq %rcx
+; X64-FAST-NEXT: movq %rdx, %rcx
+; X64-FAST-NEXT: shrq $63, %rcx
+; X64-FAST-NEXT: sarq $28, %rdx
+; X64-FAST-NEXT: leaq (%rdx,%rcx), %rax
+; X64-FAST-NEXT: addl %ecx, %edx
+; X64-FAST-NEXT: imull $-294967296, %edx, %ecx # imm = 0xEE6B2800
+; X64-FAST-NEXT: subl %ecx, %edi
+; X64-FAST-NEXT: movl %edi, %edx
+; X64-FAST-NEXT: retq
+;
+; X64-SLOW-LABEL: PR38622_signed:
+; X64-SLOW: # %bb.0:
+; X64-SLOW-NEXT: movl $4000000000, %ecx # imm = 0xEE6B2800
+; X64-SLOW-NEXT: movq %rdi, %rax
+; X64-SLOW-NEXT: shrq $32, %rax
+; X64-SLOW-NEXT: je .LBB15_1
+; X64-SLOW-NEXT: # %bb.2:
+; X64-SLOW-NEXT: movq %rdi, %rax
+; X64-SLOW-NEXT: cqto
+; X64-SLOW-NEXT: idivq %rcx
+; X64-SLOW-NEXT: # kill: def $edx killed $edx killed $rdx
+; X64-SLOW-NEXT: retq
+; X64-SLOW-NEXT: .LBB15_1:
+; X64-SLOW-NEXT: xorl %edx, %edx
+; X64-SLOW-NEXT: movl %edi, %eax
+; X64-SLOW-NEXT: divl %ecx
+; X64-SLOW-NEXT: # kill: def $edx killed $edx def $rdx
+; X64-SLOW-NEXT: # kill: def $eax killed $eax def $rax
+; X64-SLOW-NEXT: # kill: def $edx killed $edx killed $rdx
+; X64-SLOW-NEXT: retq
%2 = sdiv i64 %0, 4000000000
%3 = srem i64 %0, 4000000000
%4 = trunc i64 %3 to i32
More information about the llvm-commits
mailing list