This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH COMMITTED: Use conditional moves in groups of assignments


On Wed, 18 Jan 2006, Richard Earnshaw wrote:
> Note we have two conditional forms in RTL: cond_exec and if_then_else.
>
> COND_EXEC is uses when all side effects are suppressed when the insn
> fails its condition.  IF_THEN_ELSE is used for situations where the
> side-effects are performed even if the value is not used.  So
>
> (cond_exec (ne: (pred) (const_int 0))
> 	(set (r0) (mem (post_inc(addr)))))
>
> is very different from
>
> (set (r0) (if_then_else (ne (pred) (const_int 0))
> 	(mem (post_inc (addr)))
> 	(r0))
>
> Though the value stored in r0 is the same in both cases, the former will
> not execute the memory access or increment addr if the condition fails,
> the latter will do both of these.

That looks wrong: the false if_then_else arm isn't supposed to
be executed *at all* i.e. not for side-effects like
post-increment.  It's not logical; the false if_then_else arm of
a conditional branch using if_then_else evaluated (usually just
a label; but the address isn't evaluated for validity).
Neither is it in similar common language constructs, like the C
"cond ? x : y". construct.

brgds, H-P


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]