aboutsummaryrefslogtreecommitdiff
path: root/gcc/combine.c
diff options
context:
space:
mode:
authorPaolo Bonzini <bonzini@gnu.org>2016-11-28 13:21:02 +0000
committerPaolo Bonzini <bonzini@gcc.gnu.org>2016-11-28 13:21:02 +0000
commit51a07549a93a00d5226635749a5eecf55f451984 (patch)
tree3e830f40caac9290970b1efe2a864f5cfa0b7e27 /gcc/combine.c
parent6383ff9f9e2b4fad5a0d7a76de5548b3255ea9a7 (diff)
downloadgcc-51a07549a93a00d5226635749a5eecf55f451984.zip
gcc-51a07549a93a00d5226635749a5eecf55f451984.tar.gz
gcc-51a07549a93a00d5226635749a5eecf55f451984.tar.bz2
combine.c (simplify_if_then_else): Simplify IF_THEN_ELSE that isolates a single bit...
gcc: * combine.c (simplify_if_then_else): Simplify IF_THEN_ELSE that isolates a single bit, even if the condition involves subregs. From-SVN: r242917
Diffstat (limited to 'gcc/combine.c')
-rw-r--r--gcc/combine.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/gcc/combine.c b/gcc/combine.c
index ecf6741..45d4048 100644
--- a/gcc/combine.c
+++ b/gcc/combine.c
@@ -6522,14 +6522,22 @@ simplify_if_then_else (rtx x)
simplify_shift_const (NULL_RTX, ASHIFT, mode,
gen_lowpart (mode, XEXP (cond, 0)), i);
- /* (IF_THEN_ELSE (NE REG 0) (0) (8)) is REG for nonzero_bits (REG) == 8. */
+ /* (IF_THEN_ELSE (NE A 0) C1 0) is A or a zero-extend of A if the only
+ non-zero bit in A is C1. */
if (true_code == NE && XEXP (cond, 1) == const0_rtx
&& false_rtx == const0_rtx && CONST_INT_P (true_rtx)
- && GET_MODE (XEXP (cond, 0)) == mode
+ && INTEGRAL_MODE_P (GET_MODE (XEXP (cond, 0)))
&& (UINTVAL (true_rtx) & GET_MODE_MASK (mode))
- == nonzero_bits (XEXP (cond, 0), mode)
+ == nonzero_bits (XEXP (cond, 0), GET_MODE (XEXP (cond, 0)))
&& (i = exact_log2 (UINTVAL (true_rtx) & GET_MODE_MASK (mode))) >= 0)
- return XEXP (cond, 0);
+ {
+ rtx val = XEXP (cond, 0);
+ enum machine_mode val_mode = GET_MODE (val);
+ if (val_mode == mode)
+ return val;
+ else if (GET_MODE_PRECISION (val_mode) < GET_MODE_PRECISION (mode))
+ return simplify_gen_unary (ZERO_EXTEND, mode, val, val_mode);
+ }
return x;
}