@@ -819,19 +819,6 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
819
819
value
820
820
} ;
821
821
822
- // only break apart 128-bit ints if they're not natively supported
823
- // TODO(antoyo): remove this if/when native 128-bit integers land in libgccjit
824
- if value_type. is_u128 ( & self . cx ) && !self . cx . supports_128bit_integers {
825
- let sixty_four = self . gcc_int ( value_type, 64 ) ;
826
- let right_shift = self . gcc_lshr ( value, sixty_four) ;
827
- let high = self . gcc_int_cast ( right_shift, self . cx . ulonglong_type ) ;
828
- let high = self . pop_count ( high) ;
829
- let low = self . gcc_int_cast ( value, self . cx . ulonglong_type ) ;
830
- let low = self . pop_count ( low) ;
831
- let res = high + low;
832
- return self . gcc_int_cast ( res, result_type) ;
833
- }
834
-
835
822
// Use Wenger's algorithm for population count, gcc's seems to play better with it
836
823
// for (int counter = 0; value != 0; counter++) {
837
824
// value &= value - 1;
@@ -844,30 +831,31 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
844
831
let counter_type = self . int_type ;
845
832
let counter = self . current_func ( ) . new_local ( None , counter_type, "popcount_counter" ) ;
846
833
let val = self . current_func ( ) . new_local ( None , value_type, "popcount_value" ) ;
847
- let zero = self . context . new_rvalue_zero ( counter_type) ;
834
+ let zero = self . gcc_zero ( counter_type) ;
848
835
self . llbb ( ) . add_assignment ( None , counter, zero) ;
849
836
self . llbb ( ) . add_assignment ( None , val, value) ;
850
837
self . br ( loop_head) ;
851
838
852
839
// check if value isn't zero
853
840
self . switch_to_block ( loop_head) ;
854
- let zero = self . context . new_rvalue_zero ( value_type) ;
855
- let cond = self . context . new_comparison ( None , ComparisonOp :: NotEquals , val. to_rvalue ( ) , zero) ;
841
+ let zero = self . gcc_zero ( value_type) ;
842
+ let cond = self . gcc_icmp ( IntPredicate :: IntNE , val. to_rvalue ( ) , zero) ;
856
843
self . cond_br ( cond, loop_body, loop_tail) ;
857
844
858
845
// val &= val - 1;
859
846
self . switch_to_block ( loop_body) ;
860
- let sub = val. to_rvalue ( ) - self . context . new_rvalue_one ( value_type) ;
847
+ let one = self . gcc_int ( value_type, 1 ) ;
848
+ let sub = self . gcc_sub ( val. to_rvalue ( ) , one) ;
861
849
loop_body. add_assignment_op ( None , val, BinaryOp :: BitwiseAnd , sub) ;
862
850
863
851
// counter += 1
864
- let one = self . context . new_rvalue_one ( counter_type) ;
852
+ let one = self . gcc_int ( counter_type, 1 ) ;
865
853
loop_body. add_assignment_op ( None , counter, BinaryOp :: Plus , one) ;
866
854
self . br ( loop_head) ;
867
855
868
856
// end of loop
869
857
self . switch_to_block ( loop_tail) ;
870
- self . context . new_cast ( None , counter. to_rvalue ( ) , result_type)
858
+ self . gcc_int_cast ( counter. to_rvalue ( ) , result_type)
871
859
}
872
860
873
861
// Algorithm from: https://blog.regehr.org/archives/1063
0 commit comments