cranelift: Remove iconst.i128 (#5075)

* cranelift: Remove iconst.i128

* bugpoint: Report Changed when only one instruction is mutated

* cranelift: Fix egraph bxor rule

* cranelift: Remove some simple_preopt opts for i128
This commit is contained in:
Afonso Bordado
2022-10-24 20:43:28 +01:00
committed by GitHub
parent bfcf6616fe
commit c8791073d6
13 changed files with 246 additions and 184 deletions

View File

@@ -694,6 +694,16 @@ pub(crate) fn define(
.build(),
);
let NarrowInt = &TypeVar::new(
"NarrowInt",
"An integer type with lanes type to `i64`",
TypeSetBuilder::new()
.ints(8..64)
.simd_lanes(Interval::All)
.dynamic_simd_lanes(Interval::All)
.build(),
);
let ScalarTruthy = &TypeVar::new(
"ScalarTruthy",
"A scalar truthy type",
@@ -1342,7 +1352,7 @@ pub(crate) fn define(
);
let N = &Operand::new("N", &imm.imm64);
let a = &Operand::new("a", Int).with_doc("A constant integer scalar or vector value");
let a = &Operand::new("a", NarrowInt).with_doc("A constant integer scalar or vector value");
ig.push(
Inst::new(
@@ -3880,15 +3890,6 @@ pub(crate) fn define(
.operands_out(vec![lo, hi]),
);
let NarrowInt = &TypeVar::new(
"NarrowInt",
"An integer type with lanes type to `i64`",
TypeSetBuilder::new()
.ints(8..64)
.simd_lanes(Interval::All)
.build(),
);
let lo = &Operand::new("lo", NarrowInt);
let hi = &Operand::new("hi", NarrowInt);
let a = &Operand::new("a", &NarrowInt.double_width())

View File

@@ -107,7 +107,7 @@
(subsume x))
;; x ^ x == 0.
(rule (simplify (bxor ty x x))
(rule (simplify (bxor (fits_in_64 ty) x x))
(subsume (iconst ty (imm64 0))))
;; x ^ not(x) == not(x) ^ x == -1.

View File

@@ -11,7 +11,7 @@ use crate::flowgraph::ControlFlowGraph;
use crate::ir::{
condcodes::{CondCode, IntCC},
instructions::Opcode,
types::{I32, I64},
types::{I128, I32, I64},
Block, DataFlowGraph, Function, Inst, InstBuilder, InstructionData, Type, Value,
};
use crate::isa::TargetIsa;
@@ -824,27 +824,27 @@ mod simplify {
};
// Replace operations that are no-ops.
match (opcode, imm.into()) {
(Opcode::IaddImm, 0)
| (Opcode::ImulImm, 1)
| (Opcode::SdivImm, 1)
| (Opcode::UdivImm, 1)
| (Opcode::BorImm, 0)
| (Opcode::BandImm, -1)
| (Opcode::BxorImm, 0)
| (Opcode::RotlImm, 0)
| (Opcode::RotrImm, 0)
| (Opcode::IshlImm, 0)
| (Opcode::UshrImm, 0)
| (Opcode::SshrImm, 0) => {
match (opcode, imm.into(), ty) {
(Opcode::IaddImm, 0, _)
| (Opcode::ImulImm, 1, _)
| (Opcode::SdivImm, 1, _)
| (Opcode::UdivImm, 1, _)
| (Opcode::BorImm, 0, _)
| (Opcode::BandImm, -1, _)
| (Opcode::BxorImm, 0, _)
| (Opcode::RotlImm, 0, _)
| (Opcode::RotrImm, 0, _)
| (Opcode::IshlImm, 0, _)
| (Opcode::UshrImm, 0, _)
| (Opcode::SshrImm, 0, _) => {
// Alias the result value with the original argument.
replace_single_result_with_alias(&mut pos.func.dfg, inst, arg);
}
(Opcode::ImulImm, 0) | (Opcode::BandImm, 0) => {
(Opcode::ImulImm, 0, ty) | (Opcode::BandImm, 0, ty) if ty != I128 => {
// Replace by zero.
pos.func.dfg.replace(inst).iconst(ty, 0);
}
(Opcode::BorImm, -1) => {
(Opcode::BorImm, -1, ty) if ty != I128 => {
// Replace by minus one.
pos.func.dfg.replace(inst).iconst(ty, -1);
}