Eric Christopher <echristo@apple.com>

Uros Bizjak ubizjak@gmail.com
Mon Nov 6 07:48:00 GMT 2006


Eric Christopher wrote:

> Anyhow, this fixes up all of the failures that were noticed (and I was able to test on
> x86_64-darwin as well).

> Probably obvious, but OK?


> 2006-11-04 Eric Christopher <echristo@apple.com>

>        * gcc.target/i386/builtin-bswap-1.c: Use nocona instead of 486
>        for arch.

> /* { dg-do compile } */
> /* { dg-options "-march=nocona" } */
> /* { dg-final { scan-assembler "bswap" } } */

This will pick "bswap" word from __builtin_bswap. You should probably
use scan-assembler-not "builtin_bswap".

int foo (int a)
{
  int b;

  b = __builtin_bswap (a);

There is no __builtin_bswap() builtin function,  only
__builtin_bswap32() and __builtin_bswap64(). The test "passes" only
due to above problem.

+(define_insn "bswapsi2"
+  [(set (match_operand:SI 0 "register_operand" "=r")
+	(bswap:SI (match_operand:SI 1 "register_operand" "0")))
+   (clobber (reg:CC FLAGS_REG))]
+  "!TARGET_64BIT && TARGET_BSWAP"
+  "bswap\t%1"

bswap\t%0

+  [(set_attr "prefix_0f" "1")])

Does this patern need to be disabled on 64 bits? IMO it can still be
used with 32bit argument.

BTW: I wonder, why there is no bswaphi2 pattern. Intel recommends xchg
instruction to swap bytes in HImode argument. The relevant pattern
could be defined like:

(define_insn "bswaphi2"
  [(set (match_operand:HI 0 "register_operand" "=G")
	(bswap:HI (match_operand:HI 1 "register_operand" "0")))]
  ""
  "xchg\t%b0, %h0")

I'm sure that linux's __be16 and __le16 data could find some use for
this pattern.

Uros.



More information about the Gcc-patches mailing list