Skip to content

Cranelift: ISLE compiler should reject negative constant literals for u64 #12757

@bongjunj

Description

@bongjunj

ISLE test case

(rule (simplify (bor ty (bxor ty (bxor ty (iconst_u ty -1) y) x) y)) (bor ty y (bxor ty x (iconst_u ty -1))))

Steps to Reproduce

  • Add the file in any mid-end opt file. For example, cranelift/codegen/src/opts/arithmetic.isle
  • Build the code generator with cargo build -p cranelift-codegen

Expected Results

  1. The ISLE compiler MUST NOT produce invalid Rust code.
  2. As -1 is in place of u64 (iconst_u <Type> <u64>), islec must either
  • Reject the rule and raise ISLE compilation error, or
  • Translate -1 as a u64 constant (e.g., 0xffffffffffffffff_u64)

Actual Results

islec produces 0xffffffffffffffffffffffffffffffff_u64, and this is an invalid Rust constant literal. As the literal requires 128-bit, and thus it cannot fit into 64-bit datatype.

Versions and Environment

Cranelift version or commit: 0.131.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIncorrect behavior in the current implementation that needs fixingcraneliftIssues related to the Cranelift code generator

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions