mirrored from git://gcc.gnu.org/git/gcc.git
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PATCH] RISC-V: optimization on checking certain bits set ((x & mask)…
… == val) The patch optimizes code generation for comparisons of the form X & C1 == C2 by converting them to (X | ~C1) == (C2 | ~C1). C1 is a constant that requires li and addi to be loaded, while ~C1 requires a single lui instruction. As the values of C1 and C2 are not visible within the equality expression, a plus pattern is matched instead. PR target/114087 gcc/ChangeLog: * config/riscv/riscv.md (*lui_constraint<ANYI:mode>_and_to_or): New pattern gcc/testsuite/ChangeLog: * gcc.target/riscv/pr114087-1.c: New test.
- Loading branch information
1 parent
d24a5e2
commit d17b09c
Showing
2 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* { dg-do compile } */ | ||
/* { dg-require-effective-target rv64 } */ | ||
/* { dg-skip-if "" { *-*-* } { "-O0" "-O1" "-Og" } } */ | ||
/* { dg-options "-march=rv64gc -mabi=lp64d" } */ | ||
|
||
#include <stdbool.h> | ||
#include <stdint.h> | ||
|
||
static uint32_t mask1 = 0x55555FFF; | ||
static uint32_t val1 = 0x14501DEF; | ||
|
||
bool pred1a(uint32_t x) { | ||
return ((x & mask1) == val1); | ||
} | ||
|
||
/* { dg-final { scan-assembler {or\s*[a-x0-9]+,\s*[a-x0-9]+,\s*[a-x0-9]+} } } */ |