compiler.cfg.value-numbering.comparisons: ##test-imm rewrite rule must check that the immediate fits

db4
Slava Pestov 2010-05-15 03:19:24 -04:00
parent 20305432a9
commit 5c0c87fcaa
2 changed files with 63 additions and 10 deletions

View File

@ -280,21 +280,29 @@ M: ##compare-integer-imm rewrite
M: ##test rewrite
{
{ [ dup src1>> vreg>insn ##load-integer? ] [ t >test-imm ] }
{ [ dup src2>> vreg>insn ##load-integer? ] [ f >test-imm ] }
{ [ dup diagonal? not ] [ drop f ] }
{ [ dup src1>> vreg>insn ##and? ] [ simplify-test ] }
{ [ dup src1>> vreg>insn ##and-imm? ] [ simplify-test-imm ] }
{ [ dup src1>> vreg-immediate-comparand? ] [ t >test-imm ] }
{ [ dup src2>> vreg-immediate-comparand? ] [ f >test-imm ] }
{ [ dup diagonal? ] [
{
{ [ dup src1>> vreg>insn ##and? ] [ simplify-test ] }
{ [ dup src1>> vreg>insn ##and-imm? ] [ simplify-test-imm ] }
[ drop f ]
} cond
] }
[ drop f ]
} cond ;
M: ##test-branch rewrite
{
{ [ dup src1>> vreg>insn ##load-integer? ] [ t >test-imm-branch ] }
{ [ dup src2>> vreg>insn ##load-integer? ] [ f >test-imm-branch ] }
{ [ dup diagonal? not ] [ drop f ] }
{ [ dup src1>> vreg>insn ##and? ] [ simplify-test-branch ] }
{ [ dup src1>> vreg>insn ##and-imm? ] [ simplify-test-imm-branch ] }
{ [ dup src1>> vreg-immediate-comparand? ] [ t >test-imm-branch ] }
{ [ dup src2>> vreg-immediate-comparand? ] [ f >test-imm-branch ] }
{ [ dup diagonal? ] [
{
{ [ dup src1>> vreg>insn ##and? ] [ simplify-test-branch ] }
{ [ dup src1>> vreg>insn ##and-imm? ] [ simplify-test-imm-branch ] }
[ drop f ]
} cond
] }
[ drop f ]
} cond ;

View File

@ -1163,6 +1163,51 @@ cpu x86.32? [
} value-numbering-step
] unit-test
[
{
T{ ##peek f 0 D 0 }
T{ ##load-integer f 1 10 }
T{ ##test-imm-branch f 0 10 cc= }
}
] [
{
T{ ##peek f 0 D 0 }
T{ ##load-integer f 1 10 }
T{ ##test-branch f 1 0 cc= }
} value-numbering-step
] unit-test
! Make sure the immediate fits
cpu x86.64? [
[
{
T{ ##peek f 0 D 0 }
T{ ##load-integer f 1 100000000000 }
T{ ##test f 2 1 0 cc= }
}
] [
{
T{ ##peek f 0 D 0 }
T{ ##load-integer f 1 100000000000 }
T{ ##test f 2 1 0 cc= }
} value-numbering-step
] unit-test
[
{
T{ ##peek f 0 D 0 }
T{ ##load-integer f 1 100000000000 }
T{ ##test-branch f 1 0 cc= }
}
] [
{
T{ ##peek f 0 D 0 }
T{ ##load-integer f 1 100000000000 }
T{ ##test-branch f 1 0 cc= }
} value-numbering-step
] unit-test
] when
! Rewriting ##compare into ##test
cpu x86? [
[