aboutsummaryrefslogtreecommitdiff
path: root/gcc/combine.cc
diff options
context:
space:
mode:
authorJivan Hakobyan <jivanhakobyan9@gmail.com>2023-05-29 07:55:29 -0600
committerJeff Law <jlaw@ventanamicro.com>2023-05-29 07:57:20 -0600
commit10680bc36aca7bfaee542a653a78813cf0d4fb1f (patch)
tree70a71a3e79623feea2007741b9c64006fdca0f0e /gcc/combine.cc
parent6b828454246c5aef7f984bb6a2888699f8dcfb2d (diff)
downloadgcc-10680bc36aca7bfaee542a653a78813cf0d4fb1f.zip
gcc-10680bc36aca7bfaee542a653a78813cf0d4fb1f.tar.gz
gcc-10680bc36aca7bfaee542a653a78813cf0d4fb1f.tar.bz2
RISC-V: Use extension instructions instead of bitwise "and"
In the case where the target supports extension instructions, it is preferable to use that instead of doing the same in other ways. For the following case void foo (unsigned long a, unsigned long* ptr) { ptr[0] = a & 0xffffffffUL; ptr[1] &= 0xffffffffUL; } GCC generates foo: li a5,-1 srli a5,a5,32 and a0,a0,a5 sd a0,0(a1) ld a4,8(a1) and a5,a4,a5 sd a5,8(a1) ret but it will be profitable to generate this one foo: zext.w a0,a0 sd a0,0(a1) lwu a5,8(a1) sd a5,8(a1) ret This patch fixes mentioned issue. It supports HI -> DI, HI->SI and SI -> DI extensions. gcc/ChangeLog: * config/riscv/riscv.md (and<mode>3): New expander. (*and<mode>3) New pattern. * config/riscv/predicates.md (arith_operand_or_mode_mask): New predicate. gcc/testsuite/ChangeLog: * gcc.target/riscv/and-extend-1.c: New test * gcc.target/riscv/and-extend-2.c: New test
Diffstat (limited to 'gcc/combine.cc')
0 files changed, 0 insertions, 0 deletions