104 changes: 71 additions & 33 deletions llvm/test/Transforms/InstCombine/fmul.ll
Original file line number Diff line number Diff line change
Expand Up @@ -633,15 +633,15 @@ define float @log2half(float %x, float %y) {

define float @log2half_commute(float %x1, float %y) {
; CHECK-LABEL: @log2half_commute(
; CHECK-NEXT: [[X1:%.*]] = fmul fast float [[X2:%.*]], 0x3FC24924A0000000
; CHECK-NEXT: [[TMP1:%.*]] = call fast float @llvm.log2.f32(float [[Y:%.*]])
; CHECK-NEXT: [[TMP2:%.*]] = fmul fast float [[TMP1]], [[X1:%.*]]
; CHECK-NEXT: [[TMP2:%.*]] = fmul fast float [[TMP1]], [[X1]]
; CHECK-NEXT: [[TMP3:%.*]] = fsub fast float [[TMP2]], [[X1]]
; CHECK-NEXT: [[MUL:%.*]] = fmul fast float [[TMP3]], 0x3FC24924A0000000
; CHECK-NEXT: ret float [[MUL]]
; CHECK-NEXT: ret float [[TMP3]]
;
%x = fdiv float %x1, 7.0 ; thwart complexity-based canonicalization
%halfy = fmul float %y, 0.5
%log2 = call float @llvm.log2.f32(float %halfy)
%x = fdiv fast float %x1, 7.0 ; thwart complexity-based canonicalization
%halfy = fmul fast float %y, 0.5
%log2 = call fast float @llvm.log2.f32(float %halfy)
%mul = fmul fast float %x, %log2
ret float %mul
}
Expand All @@ -652,12 +652,50 @@ define float @fdiv_constant_numerator_fmul(float %x) {
; CHECK-LABEL: @fdiv_constant_numerator_fmul(
; CHECK-NEXT: [[T3:%.*]] = fdiv reassoc float 1.200000e+07, [[X:%.*]]
; CHECK-NEXT: ret float [[T3]]
;
%t1 = fdiv reassoc float 2.0e+3, %x
%t3 = fmul reassoc float %t1, 6.0e+3
ret float %t3
}

; C1/X * C2 => (C1*C2) / X with mixed fast-math flags

define float @fdiv_constant_numerator_fmul_mixed(float %x) {
; CHECK-LABEL: @fdiv_constant_numerator_fmul_mixed(
; CHECK-NEXT: [[T3:%.*]] = fdiv reassoc float 1.200000e+07, [[X:%.*]]
; CHECK-NEXT: ret float [[T3]]
;
%t1 = fdiv reassoc float 2.0e+3, %x
%t3 = fmul fast float %t1, 6.0e+3
ret float %t3
}

; C1/X * C2 => (C1*C2) / X with full fast-math flags

define float @fdiv_constant_numerator_fmul_fast(float %x) {
; CHECK-LABEL: @fdiv_constant_numerator_fmul_fast(
; CHECK-NEXT: [[T3:%.*]] = fdiv fast float 1.200000e+07, [[X:%.*]]
; CHECK-NEXT: ret float [[T3]]
;
%t1 = fdiv fast float 2.0e+3, %x
%t3 = fmul fast float %t1, 6.0e+3
ret float %t3
}

; C1/X * C2 => (C1*C2) / X with no fast-math flags on the fdiv

define float @fdiv_constant_numerator_fmul_precdiv(float %x) {
; CHECK-LABEL: @fdiv_constant_numerator_fmul_precdiv(
; CHECK-NEXT: [[T1:%.*]] = fdiv float 2.000000e+03, [[X:%.*]]
; CHECK-NEXT: [[T4:%.*]] = fmul reassoc float [[T1]], 6.000000e+03
; CHECK-NEXT: ret float [[T4]]
;
%t1 = fdiv float 2.0e+3, %x
%t3 = fmul reassoc float %t1, 6.0e+3
ret float %t3
}


; C1/X * C2 => (C1*C2) / X is disabled if C1/X has multiple uses

@fmul2_external = external global float
Expand All @@ -682,7 +720,7 @@ define float @fdiv_constant_denominator_fmul(float %x) {
; CHECK-NEXT: [[T3:%.*]] = fmul reassoc float [[X:%.*]], 3.000000e+00
; CHECK-NEXT: ret float [[T3]]
;
%t1 = fdiv float %x, 2.0e+3
%t1 = fdiv reassoc float %x, 2.0e+3
%t3 = fmul reassoc float %t1, 6.0e+3
ret float %t3
}
Expand All @@ -692,7 +730,7 @@ define <4 x float> @fdiv_constant_denominator_fmul_vec(<4 x float> %x) {
; CHECK-NEXT: [[T3:%.*]] = fmul reassoc <4 x float> [[X:%.*]], <float 3.000000e+00, float 2.000000e+00, float 1.000000e+00, float 1.000000e+00>
; CHECK-NEXT: ret <4 x float> [[T3]]
;
%t1 = fdiv <4 x float> %x, <float 2.0e+3, float 3.0e+3, float 2.0e+3, float 1.0e+3>
%t1 = fdiv reassoc <4 x float> %x, <float 2.0e+3, float 3.0e+3, float 2.0e+3, float 1.0e+3>
%t3 = fmul reassoc <4 x float> %t1, <float 6.0e+3, float 6.0e+3, float 2.0e+3, float 1.0e+3>
ret <4 x float> %t3
}
Expand All @@ -705,7 +743,7 @@ define <4 x float> @fdiv_constant_denominator_fmul_vec_constexpr(<4 x float> %x)
; CHECK-NEXT: ret <4 x float> [[T3]]
;
%constExprMul = bitcast i128 trunc (i160 bitcast (<5 x float> <float 6.0e+3, float 6.0e+3, float 2.0e+3, float 1.0e+3, float undef> to i160) to i128) to <4 x float>
%t1 = fdiv <4 x float> %x, <float 2.0e+3, float 3.0e+3, float 2.0e+3, float 1.0e+3>
%t1 = fdiv reassoc <4 x float> %x, <float 2.0e+3, float 3.0e+3, float 2.0e+3, float 1.0e+3>
%t3 = fmul reassoc <4 x float> %t1, %constExprMul
ret <4 x float> %t3
}
Expand Down Expand Up @@ -734,7 +772,7 @@ define float @fdiv_constant_denominator_fmul_denorm(float %x) {
; CHECK-NEXT: [[T3:%.*]] = fmul fast float [[X:%.*]], 0x3760620000000000
; CHECK-NEXT: ret float [[T3]]
;
%t1 = fdiv float %x, 2.0e+3
%t1 = fdiv fast float %x, 2.0e+3
%t3 = fmul fast float %t1, 0x3810000000000000
ret float %t3
}
Expand All @@ -748,7 +786,7 @@ define float @fdiv_constant_denominator_fmul_denorm_try_harder(float %x) {
; CHECK-NEXT: [[T3:%.*]] = fdiv reassoc float [[X:%.*]], 0x47E8000000000000
; CHECK-NEXT: ret float [[T3]]
;
%t1 = fdiv float %x, 3.0
%t1 = fdiv reassoc float %x, 3.0
%t3 = fmul reassoc float %t1, 0x3810000000000000
ret float %t3
}
Expand Down Expand Up @@ -776,7 +814,7 @@ define float @fmul_fadd_distribute(float %x) {
; CHECK-NEXT: [[T3:%.*]] = fadd reassoc float [[TMP1]], 6.000000e+00
; CHECK-NEXT: ret float [[T3]]
;
%t2 = fadd float %x, 2.0
%t2 = fadd reassoc float %x, 2.0
%t3 = fmul reassoc float %t2, 3.0
ret float %t3
}
Expand All @@ -787,7 +825,7 @@ define <2 x float> @fmul_fadd_distribute_vec(<2 x float> %x) {
; CHECK-NEXT: [[T3:%.*]] = fadd reassoc <2 x float> [[TMP1]], <float 1.200000e+07, float 1.200000e+07>
; CHECK-NEXT: ret <2 x float> [[T3]]
;
%t1 = fadd <2 x float> <float 2.0e+3, float 2.0e+3>, %x
%t1 = fadd reassoc <2 x float> <float 2.0e+3, float 2.0e+3>, %x
%t3 = fmul reassoc <2 x float> %t1, <float 6.0e+3, float 6.0e+3>
ret <2 x float> %t3
}
Expand All @@ -798,7 +836,7 @@ define <vscale x 2 x float> @fmul_fadd_distribute_scalablevec(<vscale x 2 x floa
; CHECK-NEXT: [[T3:%.*]] = fadd reassoc <vscale x 2 x float> [[TMP1]], shufflevector (<vscale x 2 x float> insertelement (<vscale x 2 x float> poison, float 1.200000e+07, i64 0), <vscale x 2 x float> poison, <vscale x 2 x i32> zeroinitializer)
; CHECK-NEXT: ret <vscale x 2 x float> [[T3]]
;
%t1 = fadd <vscale x 2 x float> splat (float 2.0e+3), %x
%t1 = fadd reassoc <vscale x 2 x float> splat (float 2.0e+3), %x
%t3 = fmul reassoc <vscale x 2 x float> %t1, splat (float 6.0e+3)


Expand All @@ -813,7 +851,7 @@ define float @fmul_fsub_distribute1(float %x) {
; CHECK-NEXT: [[T3:%.*]] = fadd reassoc float [[TMP1]], -6.000000e+00
; CHECK-NEXT: ret float [[T3]]
;
%t2 = fsub float %x, 2.0
%t2 = fsub reassoc float %x, 2.0
%t3 = fmul reassoc float %t2, 3.0
ret float %t3
}
Expand All @@ -826,7 +864,7 @@ define float @fmul_fsub_distribute2(float %x) {
; CHECK-NEXT: [[T3:%.*]] = fsub reassoc float 6.000000e+00, [[TMP1]]
; CHECK-NEXT: ret float [[T3]]
;
%t2 = fsub float 2.0, %x
%t2 = fsub reassoc float 2.0, %x
%t3 = fmul reassoc float %t2, 3.0
ret float %t3
}
Expand All @@ -840,8 +878,8 @@ define float @fmul_fadd_fmul_distribute(float %x) {
; CHECK-NEXT: [[T3:%.*]] = fadd fast float [[TMP1]], 1.000000e+01
; CHECK-NEXT: ret float [[T3]]
;
%t1 = fmul float %x, 6.0
%t2 = fadd float %t1, 2.0
%t1 = fmul fast float %x, 6.0
%t2 = fadd fast float %t1, 2.0
%t3 = fmul fast float %t2, 5.0
ret float %t3
}
Expand Down Expand Up @@ -872,8 +910,8 @@ define double @fmul_fadd_fdiv_distribute2(double %x) {
; CHECK-NEXT: [[T3:%.*]] = fadd reassoc double [[TMP1]], 0x34000000000000
; CHECK-NEXT: ret double [[T3]]
;
%t1 = fdiv double %x, 3.0
%t2 = fadd double %t1, 5.0
%t1 = fdiv reassoc double %x, 3.0
%t2 = fadd reassoc double %t1, 5.0
%t3 = fmul reassoc double %t2, 0x10000000000000
ret double %t3
}
Expand All @@ -887,8 +925,8 @@ define double @fmul_fadd_fdiv_distribute3(double %x) {
; CHECK-NEXT: [[T3:%.*]] = fadd reassoc double [[TMP1]], 0x34000000000000
; CHECK-NEXT: ret double [[T3]]
;
%t1 = fdiv double %x, 3.0
%t2 = fadd double %t1, 5.0
%t1 = fdiv reassoc double %x, 3.0
%t2 = fadd reassoc double %t1, 5.0
%t3 = fmul reassoc double %t2, 0x10000000000000
ret double %t3
}
Expand All @@ -902,8 +940,8 @@ define float @fmul_fsub_fmul_distribute(float %x) {
; CHECK-NEXT: [[T3:%.*]] = fsub fast float 1.000000e+01, [[TMP1]]
; CHECK-NEXT: ret float [[T3]]
;
%t1 = fmul float %x, 6.0
%t2 = fsub float 2.0, %t1
%t1 = fmul fast float %x, 6.0
%t2 = fsub fast float 2.0, %t1
%t3 = fmul fast float %t2, 5.0
ret float %t3
}
Expand Down Expand Up @@ -932,8 +970,8 @@ define float @fmul_fsub_fmul_distribute2(float %x) {
; CHECK-NEXT: [[T3:%.*]] = fadd fast float [[TMP1]], -1.000000e+01
; CHECK-NEXT: ret float [[T3]]
;
%t1 = fmul float %x, 6.0
%t2 = fsub float %t1, 2.0
%t1 = fmul fast float %x, 6.0
%t2 = fsub fast float %t1, 2.0
%t3 = fmul fast float %t2, 5.0
ret float %t3
}
Expand Down Expand Up @@ -986,8 +1024,8 @@ define double @fmul_fdivs_factor_common_denominator(double %x, double %y, double
; CHECK-NEXT: [[MUL:%.*]] = fdiv fast double [[TMP1]], [[TMP2]]
; CHECK-NEXT: ret double [[MUL]]
;
%div1 = fdiv double %x, %z
%div2 = fdiv double %y, %z
%div1 = fdiv fast double %x, %z
%div2 = fdiv fast double %y, %z
%mul = fmul fast double %div1, %div2
ret double %mul
}
Expand All @@ -999,8 +1037,8 @@ define double @fmul_fdivs_factor(double %x, double %y, double %z, double %w) {
; CHECK-NEXT: [[MUL:%.*]] = fdiv reassoc double [[TMP2]], [[Y:%.*]]
; CHECK-NEXT: ret double [[MUL]]
;
%div1 = fdiv double %x, %y
%div2 = fdiv double %z, %w
%div1 = fdiv reassoc double %x, %y
%div2 = fdiv reassoc double %z, %w
%mul = fmul reassoc double %div1, %div2
ret double %mul
}
Expand All @@ -1011,7 +1049,7 @@ define double @fmul_fdiv_factor(double %x, double %y, double %z) {
; CHECK-NEXT: [[MUL:%.*]] = fdiv reassoc double [[TMP1]], [[Y:%.*]]
; CHECK-NEXT: ret double [[MUL]]
;
%div = fdiv double %x, %y
%div = fdiv reassoc double %x, %y
%mul = fmul reassoc double %div, %z
ret double %mul
}
Expand All @@ -1022,7 +1060,7 @@ define double @fmul_fdiv_factor_constant1(double %x, double %y) {
; CHECK-NEXT: [[MUL:%.*]] = fdiv reassoc double [[TMP1]], [[Y:%.*]]
; CHECK-NEXT: ret double [[MUL]]
;
%div = fdiv double %x, %y
%div = fdiv reassoc double %x, %y
%mul = fmul reassoc double %div, 42.0
ret double %mul
}
Expand All @@ -1033,7 +1071,7 @@ define <2 x float> @fmul_fdiv_factor_constant2(<2 x float> %x, <2 x float> %y) {
; CHECK-NEXT: [[MUL:%.*]] = fdiv reassoc <2 x float> [[TMP1]], <float 4.200000e+01, float 1.200000e+01>
; CHECK-NEXT: ret <2 x float> [[MUL]]
;
%div = fdiv <2 x float> %x, <float 42.0, float 12.0>
%div = fdiv reassoc <2 x float> %x, <float 42.0, float 12.0>
%mul = fmul reassoc <2 x float> %div, %y
ret <2 x float> %mul
}
Expand Down
73 changes: 71 additions & 2 deletions utils/bazel/llvm-project-overlay/lldb/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,9 @@ cc_library(
"//lldb/source/Plugins:PluginSymbolLocatorDebugSymbols",
"//lldb/source/Plugins:PluginSymbolVendorMacOSX",
],
"@platforms//os:linux": [
"//lldb/source/Plugins:PluginProcessLinux",
],
"//conditions:default": [],
}),
)
Expand Down Expand Up @@ -752,7 +755,13 @@ cc_binary(
data = [
":lldb-argdumper",
] + select({
"@platforms//os:macos": [":debugserver"],
"@platforms//os:macos": [
":debugserver",
":lldb-server",
],
"@platforms//os:linux": [
":lldb-server",
],
"//conditions:default": [],
}),
deps = [
Expand Down Expand Up @@ -799,8 +808,8 @@ cc_library(
["tools/debugserver/source/**/*.cpp"],
exclude = ["tools/debugserver/source/debugserver.cpp"],
),
tags = ["nobuildkite"],
local_defines = ["LLDB_USE_OS_LOG"],
tags = ["nobuildkite"],
deps = [
":DebugServerCommonHeaders",
":DebugServerCommonMacOSXHeaders",
Expand Down Expand Up @@ -852,3 +861,63 @@ cc_binary(
srcs = glob(["tools/argdumper/*.cpp"]),
deps = ["//llvm:Support"],
)

gentbl_cc_library(
name = "lldb_server_opts_gen",
strip_include_prefix = ".",
tbl_outs = [(
["-gen-opt-parser-defs"],
"LLGSOptions.inc",
)],
tblgen = "//llvm:llvm-tblgen",
td_file = "tools/lldb-server/LLGSOptions.td",
deps = ["//llvm:OptParserTdFiles"],
)

cc_binary(
name = "lldb-server",
srcs = glob([
"tools/lldb-server/*.cpp",
"tools/lldb-server/*.h",
]),
target_compatible_with = select({
"@platforms//os:linux": [],
"@platforms//os:macos": [],
# TODO: This can theoretically support more platforms, but it hasn't been tested yet
"//conditions:default": ["@platforms//:incompatible"],
}),
deps = [
":Host",
":Initialization",
":Utility",
":Version",
":lldb_server_opts_gen",
"//lldb:Target",
"//lldb:TargetHeaders",
"//lldb/source/Plugins:PluginCPlusPlusLanguage",
"//lldb/source/Plugins:PluginExpressionParserClang",
"//lldb/source/Plugins:PluginInstructionARM",
"//lldb/source/Plugins:PluginInstructionARM64",
"//lldb/source/Plugins:PluginInstructionLoongArch",
"//lldb/source/Plugins:PluginInstructionMIPS",
"//lldb/source/Plugins:PluginInstructionMIPS64",
"//lldb/source/Plugins:PluginInstructionRISCV",
"//lldb/source/Plugins:PluginObjCLanguage",
"//lldb/source/Plugins:PluginProcessGDBRemote",
"//lldb/source/Plugins:PluginSymbolFileDWARF",
"//lldb/source/Plugins:PluginSymbolFileNativePDB",
"//lldb/source/Plugins:PluginSymbolFilePDB",
"//lldb/source/Plugins:PluginTypeSystemClang",
"//llvm:Option",
"//llvm:Support",
] + select({
"@platforms//os:linux": [
"//lldb/source/Plugins:PluginObjectFileELF",
"//lldb/source/Plugins:PluginProcessLinux",
],
"@platforms//os:macos": [
"//lldb/source/Plugins:PluginObjectFileMachO",
],
"//conditions:default": [],
}),
)
19 changes: 19 additions & 0 deletions utils/bazel/llvm-project-overlay/lldb/source/Plugins/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2100,6 +2100,25 @@ cc_library(
],
)

cc_library(
name = "PluginProcessLinux",
srcs = glob(["Process/Linux/*.cpp"]),
hdrs = glob(["Process/Linux/*.h"]),
include_prefix = "Plugins",
deps = [
":PluginProcessPOSIX",
":PluginProcessUtility",
"//lldb:Core",
"//lldb:Headers",
"//lldb:Host",
"//lldb:SymbolHeaders",
"//lldb:TargetHeaders",
"//lldb:Utility",
"//llvm:Support",
"//llvm:TargetParser",
],
)

cc_library(
name = "PluginScriptedProcess",
srcs = glob(["Process/scripted/*.cpp"]),
Expand Down