@@ -415,6 +415,7 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
415
415
IntPredicate :: IntNE => {
416
416
return self . context . new_comparison ( None , ComparisonOp :: NotEquals , cmp, self . context . new_rvalue_one ( self . int_type ) ) ;
417
417
} ,
418
+ // TODO(antoyo): cast to u128 for unsigned comparison. See below.
418
419
IntPredicate :: IntUGT => ( ComparisonOp :: Equals , 2 ) ,
419
420
IntPredicate :: IntUGE => ( ComparisonOp :: GreaterThanEquals , 1 ) ,
420
421
IntPredicate :: IntULT => ( ComparisonOp :: Equals , 0 ) ,
@@ -444,6 +445,18 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
444
445
rhs = self . context . new_cast ( None , rhs, a_type) ;
445
446
}
446
447
}
448
+ match op {
449
+ IntPredicate :: IntUGT | IntPredicate :: IntUGE | IntPredicate :: IntULT | IntPredicate :: IntULE => {
450
+ if !a_type. is_vector ( ) {
451
+ let unsigned_type = a_type. to_unsigned ( & self . cx ) ;
452
+ lhs = self . context . new_cast ( None , lhs, unsigned_type) ;
453
+ rhs = self . context . new_cast ( None , rhs, unsigned_type) ;
454
+ }
455
+ } ,
456
+ // TODO(antoyo): we probably need to handle signed comparison for unsigned
457
+ // integers.
458
+ _ => ( ) ,
459
+ }
447
460
self . context . new_comparison ( None , op. to_gcc_comparison ( ) , lhs, rhs)
448
461
}
449
462
}
0 commit comments