[Bug target/44659] New: Combiner fails to match cmp patterns with upper 8bit register
hjl dot tools at gmail dot com
gcc-bugzilla@gcc.gnu.org
Thu Jun 24 17:56:00 GMT 2010
After fixing PR 44588, I got
[hjl@gnu-6 divb]$ cat umod-4.c
int
foo (unsigned char x, unsigned char y)
{
return (x % y) != 0;
}
[hjl@gnu-6 divb]$ /export/build/gnu/gcc/build-x86_64-linux/gcc/xgcc
-B/export/build/gnu/gcc/build-x86_64-linux/gcc/ -Os -c -o umod-4.o umod-4.c
[hjl@gnu-6 divb]$ cat umod-4.s
.file "umod-4.c"
.text
.globl foo
.type foo, @function
foo:
.LFB0:
.cfi_startproc
movzbl %dil, %eax
divb %sil
movzbl %ah, %eax
testb %al, %al
setne %al
movzbl %al, %eax
ret
We can generate
testb %ah, %ah
instead of
movzbl %ah, %eax
testb %al, %al
The combine pass shows
Trying 11 -> 13:
Failed to match this instruction:
(set (reg:CCZ 17 flags)
(compare:CCZ (subreg:QI (lshiftrt:SI (subreg:SI (reg:HI 69) 0)
(const_int 8 [0x8])) 0)
(const_int 0 [0])))
with
(insn 11 10 13 2 umod-4.c:4 (set (reg:QI 67)
(subreg:QI (zero_extract:SI (reg:HI 69)
(const_int 8 [0x8])
(const_int 8 [0x8])) 0)) 90 {*movqi_extzv_2_rex64}
(expr_list:REG_DEAD (reg:HI 69)
(expr_list:REG_EQUAL (umod:QI (reg/v:QI 61 [ x ])
(reg/v:QI 63 [ y ]))
(nil))))
(insn 13 11 14 2 umod-4.c:4 (set (reg:CCZ 17 flags)
(compare:CCZ (reg:QI 67)
(const_int 0 [0]))) 0 {*cmpqi_ccno_1} (expr_list:REG_DEAD (reg:QI
67)
(nil)))
i386.md has
(define_insn "*cmpqi_ext_2"
[(set (reg FLAGS_REG)
(compare
(subreg:QI
(zero_extract:SI
(match_operand 0 "ext_register_operand" "Q")
(const_int 8)
(const_int 8)) 0)
(match_operand:QI 1 "const0_operand" "")))]
"ix86_match_ccmode (insn, CCNOmode)"
"test{b}\t%h0, %h0"
[(set_attr "type" "test")
(set_attr "length_immediate" "0")
(set_attr "mode" "QI")])
According to
http://gcc.gnu.org/ml/gcc-patches/2010-06/msg02477.html
(set (reg:CCZ 17 flags)
(compare:CCZ (subreg:QI (lshiftrt:SI (subreg:SI (reg:HI 69) 0)
(const_int 8 [0x8])) 0)
(const_int 0 [0])))
is the standard form within combine.c. The questions are
1. Why doesn't combiner match QI cmp patterns with zero_extract?
2. Should i386.md provide QI cmp patterns with lshiftrt for
combiner?
3. Does i386.md need QI cmp patterns with zero_extract if they aren't
used by combiner?
--
Summary: Combiner fails to match cmp patterns with upper 8bit
register
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: hjl dot tools at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44659
More information about the Gcc-bugs
mailing list