Bug 53454

Summary: [RX backend]: redundant insn being expanded for long long trivial arithmetic comparison
Product: gcc Reporter: Paulo J. Matos <paulo>
Component: middle-endAssignee: Not yet assigned to anyone <unassigned>
Status: UNCONFIRMED ---    
Severity: minor Keywords: missed-optimization
Priority: P3    
Version: 4.6.3   
Target Milestone: ---   
Host: Target: rx
Build: Known to work:
Known to fail: Last reconfirmed:

Description Paulo J. Matos 2012-05-22 14:44:14 UTC
I was comparing my port double word arithmetic comparison with the one from rx and I noticed some strange code being expanded.

In GCC4.6.3 for the code compiled with -Os:
int le(long long x) { return x <= 0; }

I get after expand:
;; Generating RTL for gimple basic block 2

;; return D.1216_2;

(insn 9 8 10 (set (reg:SI 27)
        (const_int 1 [0x1])) test.c:1 -1
     (nil))

(jump_insn 10 9 11 (set (pc)
        (if_then_else (gt (subreg:SI (reg/v:DI 26 [ x ]) 4)
                (const_int 0 [0]))
            (label_ref 16)
            (pc))) test.c:1 -1
     (nil))

(jump_insn 11 10 12 (set (pc)
        (if_then_else (ne (subreg:SI (reg/v:DI 26 [ x ]) 4)
                (const_int 0 [0]))
            (label_ref 18)
            (pc))) test.c:1 -1
     (nil))

(jump_insn 12 11 13 (set (pc)
        (if_then_else (ne (subreg:SI (reg/v:DI 26 [ x ]) 0)
                (const_int 0 [0]))
            (label_ref 16)
            (pc))) test.c:1 -1
     (nil))

(jump_insn 13 12 14 (set (pc)
        (if_then_else (ne (subreg:SI (reg/v:DI 26 [ x ]) 0)
                (const_int 0 [0]))
            (label_ref 18)
            (pc))) test.c:1 -1
     (nil))

(jump_insn 14 13 15 (set (pc)
        (label_ref 18)) test.c:1 -1
     (nil))

(barrier 15 14 16)

(code_label 16 15 17 3 "" [0 uses])

(insn 17 16 18 (set (reg:SI 27)
        (const_int 0 [0])) test.c:1 -1
     (nil))

(code_label 18 17 19 2 "" [0 uses])

(insn 19 18 20 (set (reg:SI 24 [ <retval> ])
        (reg:SI 27)) test.c:1 -1
     (nil))

(jump_insn 20 19 21 (set (pc)
        (label_ref 0)) test.c:1 -1
     (nil))

(barrier 21 20 0)


What's strange in here are insn 12/13, insn 13 is redundant. Marked this as minor since it seems to me that GCC notices this and the assembly generation is ok.