brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.2 KiB · b8a45e8 Raw
36 lines · plain
1; RUN: opt -S -passes='require<profile-summary>,function(codegenprepare)' < %s | FileCheck %s2 3target datalayout = "e-i64:64-v16:16-v32:32-n16:32:64"4target triple = "nvptx64-nvidia-cuda"5 6; When we bypass slow div with a constant numerator which fits into the bypass7; width, we still emit the bypass code, but we don't 'or' the numerator with8; the denominator.9; CHECK-LABEL: @small_constant_numer10define i64 @small_constant_numer(i64 %a) {11  ; CHECK: [[AND:%[0-9]+]] = and i64 %a, -429496729612  ; CHECK: icmp eq i64 [[AND]], 013 14  ; CHECK: [[TRUNC:%[0-9]+]] = trunc i64 %a to i3215  ; CHECK: udiv i32 -1, [[TRUNC]]16  %d = sdiv i64 4294967295, %a  ; 0xffff'ffff17  ret i64 %d18}19 20; When we try to bypass slow div with a constant numerator which *doesn't* fit21; into the bypass width, leave it as a plain 64-bit div with no bypass.22; CHECK-LABEL: @large_constant_numer23define i64 @large_constant_numer(i64 %a) {24  ; CHECK-NOT: udiv i3225  %d = sdiv i64 4294967296, %a  ; 0x1'0000'000026  ret i64 %d27}28 29; For good measure, try a value larger than 2^32.30; CHECK-LABEL: @larger_constant_numer31define i64 @larger_constant_numer(i64 %a) {32  ; CHECK-NOT: udiv i3233  %d = sdiv i64 5000000000, %a34  ret i64 %d35}36