This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Suboptimal code generation if if - conversion
- From: "Hartmut Penner" <HPENNER at de dot ibm dot com>
- To: Richard Henderson <rth at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Thu, 10 Oct 2002 09:00:18 +0200
- Subject: Re: Suboptimal code generation if if - conversion
Richard Henderson wrote:
>No it isn't. While the IF-THEN-ELSE block is found in ifcvt.c,
>no changes are made. At all.
>And, actually, all the badness in this example is fixed by
>correctly declaring F to have a void return type. When you
>do that, the (clobber (reg/i:SI 2 %r2)) is no longer in the
>instruction stream, and the cfg cleanup routines take care
>of fixing things up as you'd like.
Yes, with the good example you mentioned, cfg will find the opportunity and
does the cleanup. Sorry for that bad example, but I think there
will be more of that kind of code...
But a short remark to ifcvt, if the cfg cleanup routines does not
convert the jump, ifcvt will do it, if and only if the test is
done against a register, that the problem I saw.
But since with a right way of writing code, cfg will do the
optimization, I guess it is not worth thinking about a fix.
Example shows the result of ifcvt on a 64 bit s390x plattform
compiling my 'bad' example. On 31bit this conversion is not done.
--- ti.c.18.combine Thu Oct 10 08:39:11 2002
+++ ti.c.19.ce Thu Oct 10 08:39:11 2002
@@ -1,6 +1,17 @@
;; Function f
+
+IF-THEN-ELSE block found, pass 1, start block 0 [insn 29], then 1 [30], else 2 [17], join 3 [24]
+
+IF-CASE-1 found, start 0, then 1
+Conversion succeeded on pass 1.
+
+2 possible IF blocks searched.
+1 IF blocks converted.
+1 basic blocks deleted.
+
+
(note 2 0 3 NOTE_INSN_DELETED)
(note 3 2 29 NOTE_INSN_FUNCTION_BEG)
@@ -13,48 +24,48 @@
(expr_list:REG_EQUAL (symbol_ref:DI ("p"))
(nil)))
-(insn 9 8 10 0 (nil) (set (reg:DI 42)
+(insn 9 8 13 0 (nil) (set (reg:DI 42)
(mem/f:DI (reg/f:DI 41) [3 p+0 S8 A64])) 48 {*movdi_64} (insn_list 8 (nil))
(expr_list:REG_DEAD (reg/f:DI 41)
(expr_list:REG_EQUAL (mem/f:DI (reg/f:DI 41) [3 p+0 S8 A64])
(nil))))
-(insn 10 9 11 0 (nil) (set (reg:CCZ 33 %cc)
+(insn 13 9 14 0 (nil) (clobber (reg/i:DI 2 %r2)) -1 (nil)
+ (expr_list:REG_UNUSED (reg/i:DI 2 %r2)
+ (nil)))
+
+(insn 14 13 10 0 (nil) (clobber (reg:DI 40)) -1 (nil)
+ (nil))
+
+(insn 10 14 11 0 (nil) (set (reg:CCZ 33 %cc)
(compare:CCZ (reg:DI 42)
(const_int 0 [0x0]))) 13 {*tstdi_cconly} (insn_list 9 (nil))
(nil))
-(jump_insn 11 10 30 0 (nil) (set (pc)
- (if_then_else (ne (reg:CCZ 33 %cc)
+(jump_insn 11 10 49 0 (nil) (set (pc)
+ (if_then_else (eq (reg:CCZ 33 %cc)
(const_int 0 [0x0]))
- (label_ref 17)
+ (label_ref 24)
(pc))) 267 {cjump} (insn_list 10 (nil))
(expr_list:REG_DEAD (reg:CCZ 33 %cc)
(expr_list:REG_BR_PROB (const_int 5000 [0x1388])
(nil))))
;; End of basic block 0, registers live:
- 11 [%r11] 15 [%r15] 32 [%ap] 34 [%fp] 42
+ 11 [%r11] 15 [%r15] 32 [%ap] 34 [%fp] 40 42
-;; Start of basic block 1, registers live: 11 [%r11] 15 [%r15] 32 [%ap] 34 [%fp]
-(note 30 11 13 1 [bb 1] NOTE_INSN_BASIC_BLOCK)
+;; Start of basic block 1, registers live: 11 [%r11] 15 [%r15] 32 [%ap] 34 [%fp] 42
+(note 49 11 50 1 [bb 1] NOTE_INSN_BASIC_BLOCK)
-(insn 13 30 14 1 (nil) (clobber (reg/i:DI 2 %r2)) -1 (nil)
- (expr_list:REG_UNUSED (reg/i:DI 2 %r2)
- (nil)))
-
-(insn 14 13 15 1 (nil) (clobber (reg:DI 40)) -1 (nil)
- (nil))
-
-(jump_insn 15 14 16 1 (nil) (set (pc)
- (label_ref 24)) -1 (nil)
+(jump_insn 50 49 51 1 (nil) (set (pc)
+ (label_ref 17)) -1 (nil)
(nil))
;; End of basic block 1, registers live:
- 11 [%r11] 15 [%r15] 32 [%ap] 34 [%fp] 40
+ 11 [%r11] 15 [%r15] 32 [%ap] 34 [%fp] 42
-(barrier 16 15 17)
+(barrier 51 50 17)
;; Start of basic block 2, registers live: 11 [%r11] 15 [%r15] 32 [%ap] 34 [%fp] 42
-(code_label 17 16 31 2 2 "" [1 uses])
+(code_label 17 51 31 2 2 "" [1 uses])
(note 31 17 21 2 [bb 2] NOTE_INSN_BASIC_BLOCK)
@@ -89,6 +100,3 @@
;; End of basic block 3, registers live:
2 [%r2] 11 [%r11] 15 [%r15] 32 [%ap] 34 [%fp]
-
-;; Combiner totals: 5 attempts, 5 substitutions (3 requiring new space),
-;; 0 successes.
Mit freundlichem Gruß / Best regards,
Hartmut Penner
GCC for S/390 Development
Internet Mail Address : hpenner@de.ibm.com