Skip to content

Commit cb499a2

Browse files
authored
remove some intrinsics (#625)
1 parent f5597ff commit cb499a2

File tree

2 files changed

+2
-50
lines changed

2 files changed

+2
-50
lines changed

src/builder.rs

+1-9
Original file line numberDiff line numberDiff line change
@@ -371,16 +371,8 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
371371
let previous_arg_count = args.len();
372372
let orig_args = args;
373373
let args = {
374-
let function_address_names = self.function_address_names.borrow();
375-
let original_function_name = function_address_names.get(&func_ptr);
376374
func_ptr = llvm::adjust_function(self.context, &func_name, func_ptr, args);
377-
llvm::adjust_intrinsic_arguments(
378-
self,
379-
gcc_func,
380-
args.into(),
381-
&func_name,
382-
original_function_name,
383-
)
375+
llvm::adjust_intrinsic_arguments(self, gcc_func, args.into(), &func_name)
384376
};
385377
let args_adjusted = args.len() != previous_arg_count;
386378
let args = self.check_ptr_call("call", func_ptr, &args);

src/intrinsic/llvm.rs

+1-41
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::borrow::Cow;
22

3-
use gccjit::{CType, Context, Function, FunctionPtrType, RValue, ToRValue, UnaryOp};
3+
use gccjit::{CType, Context, Function, FunctionPtrType, RValue, ToRValue};
44
use rustc_codegen_ssa::traits::BuilderMethods;
55

66
use crate::builder::Builder;
@@ -43,7 +43,6 @@ pub fn adjust_intrinsic_arguments<'a, 'b, 'gcc, 'tcx>(
4343
gcc_func: FunctionPtrType<'gcc>,
4444
mut args: Cow<'b, [RValue<'gcc>]>,
4545
func_name: &str,
46-
original_function_name: Option<&String>,
4746
) -> Cow<'b, [RValue<'gcc>]> {
4847
// TODO: this might not be a good way to workaround the missing tile builtins.
4948
if func_name == "__builtin_trap" {
@@ -541,33 +540,6 @@ pub fn adjust_intrinsic_arguments<'a, 'b, 'gcc, 'tcx>(
541540
let c = builder.context.new_rvalue_from_vector(None, arg3_type, &[new_args[2]; 2]);
542541
args = vec![a, b, c, new_args[3]].into();
543542
}
544-
"__builtin_ia32_vfmaddsubpd256"
545-
| "__builtin_ia32_vfmaddsubps"
546-
| "__builtin_ia32_vfmaddsubps256"
547-
| "__builtin_ia32_vfmaddsubpd" => {
548-
if let Some(original_function_name) = original_function_name {
549-
match &**original_function_name {
550-
"llvm.x86.fma.vfmsubadd.pd.256"
551-
| "llvm.x86.fma.vfmsubadd.ps"
552-
| "llvm.x86.fma.vfmsubadd.ps.256"
553-
| "llvm.x86.fma.vfmsubadd.pd" => {
554-
// NOTE: since both llvm.x86.fma.vfmsubadd.ps and llvm.x86.fma.vfmaddsub.ps maps to
555-
// __builtin_ia32_vfmaddsubps, only add minus if this comes from a
556-
// subadd LLVM intrinsic, e.g. _mm256_fmsubadd_pd.
557-
let mut new_args = args.to_vec();
558-
let arg3 = &mut new_args[2];
559-
*arg3 = builder.context.new_unary_op(
560-
None,
561-
UnaryOp::Minus,
562-
arg3.get_type(),
563-
*arg3,
564-
);
565-
args = new_args.into();
566-
}
567-
_ => (),
568-
}
569-
}
570-
}
571543
"__builtin_ia32_ldmxcsr" => {
572544
// The builtin __builtin_ia32_ldmxcsr takes an integer value while llvm.x86.sse.ldmxcsr takes a pointer,
573545
// so dereference the pointer.
@@ -913,16 +885,6 @@ pub fn intrinsic<'gcc, 'tcx>(name: &str, cx: &CodegenCx<'gcc, 'tcx>) -> Function
913885
"llvm.ctlz.v4i64" => "__builtin_ia32_vplzcntq_256_mask",
914886
"llvm.ctlz.v2i64" => "__builtin_ia32_vplzcntq_128_mask",
915887
"llvm.ctpop.v32i16" => "__builtin_ia32_vpopcountw_v32hi",
916-
"llvm.x86.fma.vfmsub.sd" => "__builtin_ia32_vfmsubsd3",
917-
"llvm.x86.fma.vfmsub.ss" => "__builtin_ia32_vfmsubss3",
918-
"llvm.x86.fma.vfmsubadd.pd" => "__builtin_ia32_vfmaddsubpd",
919-
"llvm.x86.fma.vfmsubadd.pd.256" => "__builtin_ia32_vfmaddsubpd256",
920-
"llvm.x86.fma.vfmsubadd.ps" => "__builtin_ia32_vfmaddsubps",
921-
"llvm.x86.fma.vfmsubadd.ps.256" => "__builtin_ia32_vfmaddsubps256",
922-
"llvm.x86.fma.vfnmadd.sd" => "__builtin_ia32_vfnmaddsd3",
923-
"llvm.x86.fma.vfnmadd.ss" => "__builtin_ia32_vfnmaddss3",
924-
"llvm.x86.fma.vfnmsub.sd" => "__builtin_ia32_vfnmsubsd3",
925-
"llvm.x86.fma.vfnmsub.ss" => "__builtin_ia32_vfnmsubss3",
926888
"llvm.x86.avx512.conflict.d.512" => "__builtin_ia32_vpconflictsi_512_mask",
927889
"llvm.x86.avx512.conflict.d.256" => "__builtin_ia32_vpconflictsi_256_mask",
928890
"llvm.x86.avx512.conflict.d.128" => "__builtin_ia32_vpconflictsi_128_mask",
@@ -1000,8 +962,6 @@ pub fn intrinsic<'gcc, 'tcx>(name: &str, cx: &CodegenCx<'gcc, 'tcx>) -> Function
1000962
"llvm.fshr.v32i16" => "__builtin_ia32_vpshrdv_v32hi",
1001963
"llvm.fshr.v16i16" => "__builtin_ia32_vpshrdv_v16hi",
1002964
"llvm.fshr.v8i16" => "__builtin_ia32_vpshrdv_v8hi",
1003-
"llvm.x86.fma.vfmadd.sd" => "__builtin_ia32_vfmaddsd3",
1004-
"llvm.x86.fma.vfmadd.ss" => "__builtin_ia32_vfmaddss3",
1005965
"llvm.x86.rdrand.64" => "__builtin_ia32_rdrand64_step",
1006966

1007967
// The above doc points to unknown builtins for the following, so override them:

0 commit comments

Comments
 (0)