Skip to content

Commit 52c5de0

Browse files
committed
Streamline bin_op_to_[if]cmp_predicate.
1 parent cd3da00 commit 52c5de0

File tree

1 file changed

+13
-43
lines changed
  • compiler/rustc_codegen_ssa/src

1 file changed

+13
-43
lines changed

Diff for: compiler/rustc_codegen_ssa/src/base.rs

+13-43
Original file line numberDiff line numberDiff line change
@@ -45,42 +45,18 @@ use crate::{
4545
};
4646

4747
pub(crate) fn bin_op_to_icmp_predicate(op: BinOp, signed: bool) -> IntPredicate {
48-
match op {
49-
BinOp::Eq => IntPredicate::IntEQ,
50-
BinOp::Ne => IntPredicate::IntNE,
51-
BinOp::Lt => {
52-
if signed {
53-
IntPredicate::IntSLT
54-
} else {
55-
IntPredicate::IntULT
56-
}
57-
}
58-
BinOp::Le => {
59-
if signed {
60-
IntPredicate::IntSLE
61-
} else {
62-
IntPredicate::IntULE
63-
}
64-
}
65-
BinOp::Gt => {
66-
if signed {
67-
IntPredicate::IntSGT
68-
} else {
69-
IntPredicate::IntUGT
70-
}
71-
}
72-
BinOp::Ge => {
73-
if signed {
74-
IntPredicate::IntSGE
75-
} else {
76-
IntPredicate::IntUGE
77-
}
78-
}
79-
op => bug!(
80-
"comparison_op_to_icmp_predicate: expected comparison operator, \
81-
found {:?}",
82-
op
83-
),
48+
match (op, signed) {
49+
(BinOp::Eq, _) => IntPredicate::IntEQ,
50+
(BinOp::Ne, _) => IntPredicate::IntNE,
51+
(BinOp::Lt, true) => IntPredicate::IntSLT,
52+
(BinOp::Lt, false) => IntPredicate::IntULT,
53+
(BinOp::Le, true) => IntPredicate::IntSLE,
54+
(BinOp::Le, false) => IntPredicate::IntULE,
55+
(BinOp::Gt, true) => IntPredicate::IntSGT,
56+
(BinOp::Gt, false) => IntPredicate::IntUGT,
57+
(BinOp::Ge, true) => IntPredicate::IntSGE,
58+
(BinOp::Ge, false) => IntPredicate::IntUGE,
59+
op => bug!("bin_op_to_icmp_predicate: expected comparison operator, found {:?}", op),
8460
}
8561
}
8662

@@ -92,13 +68,7 @@ pub(crate) fn bin_op_to_fcmp_predicate(op: BinOp) -> RealPredicate {
9268
BinOp::Le => RealPredicate::RealOLE,
9369
BinOp::Gt => RealPredicate::RealOGT,
9470
BinOp::Ge => RealPredicate::RealOGE,
95-
op => {
96-
bug!(
97-
"comparison_op_to_fcmp_predicate: expected comparison operator, \
98-
found {:?}",
99-
op
100-
);
101-
}
71+
op => bug!("bin_op_to_fcmp_predicate: expected comparison operator, found {:?}", op),
10272
}
10373
}
10474

0 commit comments

Comments
 (0)