Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

egraph opt rules: do (icmp cc x x) == {0,1} only for integer types. #5438

Merged
merged 1 commit into from
Dec 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions cranelift/codegen/src/opts/algebraic.isle
Original file line number Diff line number Diff line change
Expand Up @@ -211,32 +211,32 @@
;; `x == x` is always true for integers; `x != x` is false. Strict
;; inequalities are false, and loose inequalities are true.
(rule (simplify
(icmp ty (IntCC.Equal) x x))
(icmp (ty_int ty) (IntCC.Equal) x x))
(iconst ty (imm64 1)))
(rule (simplify
(icmp ty (IntCC.NotEqual) x x))
(icmp (ty_int ty) (IntCC.NotEqual) x x))
(iconst ty (imm64 0)))
(rule (simplify
(icmp ty (IntCC.UnsignedGreaterThan) x x))
(icmp (ty_int ty) (IntCC.UnsignedGreaterThan) x x))
(iconst ty (imm64 0)))
(rule (simplify
(icmp ty (IntCC.UnsignedGreaterThanOrEqual) x x))
(icmp (ty_int ty) (IntCC.UnsignedGreaterThanOrEqual) x x))
(iconst ty (imm64 1)))
(rule (simplify
(icmp ty (IntCC.SignedGreaterThan) x x))
(icmp (ty_int ty) (IntCC.SignedGreaterThan) x x))
(iconst ty (imm64 0)))
(rule (simplify
(icmp ty (IntCC.SignedGreaterThanOrEqual) x x))
(icmp (ty_int ty) (IntCC.SignedGreaterThanOrEqual) x x))
(iconst ty (imm64 1)))
(rule (simplify
(icmp ty (IntCC.UnsignedLessThan) x x))
(icmp (ty_int ty) (IntCC.UnsignedLessThan) x x))
(iconst ty (imm64 0)))
(rule (simplify
(icmp ty (IntCC.UnsignedLessThanOrEqual) x x))
(icmp (ty_int ty) (IntCC.UnsignedLessThanOrEqual) x x))
(iconst ty (imm64 1)))
(rule (simplify
(icmp ty (IntCC.SignedLessThan) x x))
(icmp (ty_int ty) (IntCC.SignedLessThan) x x))
(iconst ty (imm64 0)))
(rule (simplify
(icmp ty (IntCC.SignedLessThanOrEqual) x x))
(icmp (ty_int ty) (IntCC.SignedLessThanOrEqual) x x))
(iconst ty (imm64 1)))
41 changes: 41 additions & 0 deletions cranelift/filetests/filetests/egraph/issue-5437.clif
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
test compile
set use_egraphs=true
target x86_64
target aarch64
target s390x

function u0:0(i64 vmctx, i64) fast {
gv0 = vmctx
gv1 = load.i64 notrap aligned readonly gv0+8
gv2 = load.i64 notrap aligned gv1
sig0 = (i64 vmctx, i64) fast
fn0 = colocated u0:2 sig0
jt0 = jump_table [block1]
stack_limit = gv2

block0(v0: i64, v1: i64):
@0019 v2 = vconst.i8x16 [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]
@001b v3 = iconst.i32 0
@001d brz v3, block2 ; v3 = 0
@001d jump block3

block3:
@001f trap unreachable

block2:
@0025 v4 = bitcast.i16x8 little v2 ; v2 = const0
@0025 v5 = bitcast.i16x8 little v2 ; v2 = const0
@0025 v6 = icmp ult v4, v5
@0027 v7 = bitcast.i32x4 little v6
@0027 v8 = vhigh_bits.i32 v7
@002a v9 = iconst.i32 0
@002c brnz v9, block1 ; v9 = 0
@002c jump block4

block4:
@002e call fn0(v0, v0)
@0030 br_table v8, block1, jt0

block1:
@0036 return
}