Skip to content

rotate intrinsic 128bit integers on 32 bit mode fail #4003

@philberty

Description

@philberty
#![feature(intrinsics)]

mod intrinsics {
    extern "rust-intrinsic" {
        pub fn rotate_left<T>(a: T, b: T) -> T;
    }
}

#[lang = "sized"]
trait Sized {}

#[lang = "u128"]
impl u128 {
    #[inline]
    pub fn rotate_left(self, n: u32) -> Self {
        unsafe { intrinsics::rotate_left(self, n as Self) }
    }
}

pub fn test() -> u128 {
    let x: u128 = 42;
    x.rotate_left(35)
}

This crashes in:

Analyzing compilation unit
Performing interprocedural optimizations
 <*free_lang_data> {heap 1552k} <visibility> {heap 1552k} <build_ssa_passes> {heap 1552k} <opt_local_passes> {heap 2008k} <remove_symbols> {heap 2008k} <targetclone> {heap 2008k} <free-fnsummary>
 {heap 2008k}Streaming LTO
 <whole-program> {heap 2008k} <fnsummary> {heap 2008k} <inline> {heap 2008k} <modref> {heap 2008k} <free-fnsummary> {heap 2008k} <single-use> {heap 2008k} <comdats> {heap 2008k}Assembling functions:
 <simdclone> {heap 2008k} test::<impl XXX>::rotate_lefttest.rs: In function ‘test::<impl XXX>::rotate_left’:
test.rs:15:9: note: the ABI for passing parameters with 16-byte alignment has changed in GCC 4.6
   15 |     pub fn rotate_left(self, n: u32) -> Self {
      |         ^~
during RTL pass: expand
In function ‘rotate_left<u128>’,
    inlined from ‘test::<impl XXX>::rotate_left’ at test.rs:16:18:
<built-in>: internal compiler error: in expand_shift_1, at expmed.cc:2713
0x5586b0b internal_error(char const*, ...)
        ../../gccrs/gcc/diagnostic-global-context.cc:517
0x553ee94 fancy_abort(char const*, int, char const*)
        ../../gccrs/gcc/diagnostic.cc:1803
0x43a06fe expand_shift_1
        ../../gccrs/gcc/expmed.cc:2713
0x43a04c0 expand_shift_1
        ../../gccrs/gcc/expmed.cc:2668
0x43a0837 expand_variable_shift(tree_code, machine_mode, rtx_def*, tree_node*, rtx_def*, int)
        ../../gccrs/gcc/expmed.cc:2754
0x43db767 expand_expr_real_2(separate_ops const*, rtx_def*, machine_mode, expand_modifier)
        ../../gccrs/gcc/expr.cc:10750
0x43dd759 expand_expr_real_gassign(gassign*, rtx_def*, machine_mode, expand_modifier, rtx_def**, bool)
        ../../gccrs/gcc/expr.cc:11186
0x4191a19 expand_gimple_stmt_1
        ../../gccrs/gcc/cfgexpand.cc:4306
0x4191cd4 expand_gimple_stmt
        ../../gccrs/gcc/cfgexpand.cc:4370
0x419a7f7 expand_gimple_basic_block
        ../../gccrs/gcc/cfgexpand.cc:6433
0x419d034 execute
        ../../gccrs/gcc/cfgexpand.cc:7181
Please submit a full bug report, with preprocessed source (by using -freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

Seems in expand_binop 32 bit mode doesnt not have this expansion enabled:

raw_optab_handler (scode=93323283) at insn-opinit.cc:5892                                        
5892      int i = lookup_handler (scode);                                                        
(gdb) n                                                                                          
5894              ? pats[i].icode : CODE_FOR_nothing);                                           
(gdb) p pats[i]                                                                                                                                                                                    
$49 = {scode = 93323283, icode = CODE_FOR_rotlti3}                                               
(gdb) frame                                                                                                                                                                                        
#0  raw_optab_handler (scode=93323283) at insn-opinit.cc:5894
5894              ? pats[i].icode : CODE_FOR_nothing); 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions