diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index 27cd6c117b4..8575fbf40fe 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -19124,11 +19124,11 @@ (define_insn "*bt" [(set (reg:CCC FLAGS_REG) (compare:CCC + (const_int 0) (zero_extract:SWI48 (match_operand:SWI48 0 "nonimmediate_operand" "r,m") (const_int 1) - (match_operand:QI 1 "nonmemory_operand" "q,")) - (const_int 0)))] + (match_operand:QI 1 "nonmemory_operand" "q,"))))] "" { switch (get_attr_mode (insn)) @@ -19155,14 +19155,14 @@ (define_insn_and_split "*bt_mask" [(set (reg:CCC FLAGS_REG) (compare:CCC + (const_int 0) (zero_extract:SWI48 (match_operand:SWI48 0 "nonimmediate_operand" "r,m") (const_int 1) (subreg:QI (and:SWI248 (match_operand:SWI248 1 "register_operand") - (match_operand 2 "const_int_operand")) 0)) - (const_int 0)))] + (match_operand 2 "const_int_operand")) 0))))] "TARGET_USE_BT && (INTVAL (operands[2]) & (GET_MODE_BITSIZE (mode)-1)) == GET_MODE_BITSIZE (mode)-1 @@ -19171,8 +19171,8 @@ "&& 1" [(set (reg:CCC FLAGS_REG) (compare:CCC - (zero_extract:SWI48 (match_dup 0) (const_int 1) (match_dup 1)) - (const_int 0)))] + (const_int 0) + (zero_extract:SWI48 (match_dup 0) (const_int 1) (match_dup 1))))] "operands[1] = gen_lowpart (QImode, operands[1]);") (define_insn_and_split "*jcc_bt" @@ -19197,18 +19197,18 @@ "&& 1" [(set (reg:CCC FLAGS_REG) (compare:CCC + (const_int 0) (zero_extract:SWI48 (match_dup 1) (const_int 1) - (match_dup 2)) - (const_int 0))) + (match_dup 2)))) (set (pc) (if_then_else (match_op_dup 0 [(reg:CCC FLAGS_REG) (const_int 0)]) (label_ref (match_dup 3)) (pc)))] { operands[0] = shallow_copy_rtx (operands[0]); - PUT_CODE (operands[0], reverse_condition (GET_CODE (operands[0]))); + PUT_CODE (operands[0], GET_CODE (operands[0]) == NE ? LTU : GEU); }) ;; Avoid useless masking of bit offset operand. @@ -19233,18 +19233,18 @@ "&& 1" [(set (reg:CCC FLAGS_REG) (compare:CCC + (const_int 0) (zero_extract:SWI48 (match_dup 1) (const_int 1) - (match_dup 2)) - (const_int 0))) + (match_dup 2)))) (set (pc) (if_then_else (match_op_dup 0 [(reg:CCC FLAGS_REG) (const_int 0)]) (label_ref (match_dup 4)) (pc)))] { operands[0] = shallow_copy_rtx (operands[0]); - PUT_CODE (operands[0], reverse_condition (GET_CODE (operands[0]))); + PUT_CODE (operands[0], GET_CODE (operands[0]) == NE ? LTU : GEU); }) ;; Avoid useless masking of bit offset operand. @@ -19270,18 +19270,18 @@ "&& 1" [(set (reg:CCC FLAGS_REG) (compare:CCC + (const_int 0) (zero_extract:SWI48 (match_dup 1) (const_int 1) - (match_dup 2)) - (const_int 0))) + (match_dup 2)))) (set (pc) (if_then_else (match_op_dup 0 [(reg:CCC FLAGS_REG) (const_int 0)]) (label_ref (match_dup 4)) (pc)))] { operands[0] = shallow_copy_rtx (operands[0]); - PUT_CODE (operands[0], reverse_condition (GET_CODE (operands[0]))); + PUT_CODE (operands[0], GET_CODE (operands[0]) == NE ? LTU : GEU); operands[2] = gen_lowpart (QImode, operands[2]); }) @@ -19302,10 +19302,10 @@ && ix86_pre_reload_split ()" [(set (reg:CCC FLAGS_REG) (compare:CCC - (zero_extract:SWI48 (match_dup 1) (const_int 1) (match_dup 2)) - (const_int 0))) + (const_int 0) + (zero_extract:SWI48 (match_dup 1) (const_int 1) (match_dup 2)))) (set (match_dup 0) - (if_then_else:SWI248 (eq (reg:CCC FLAGS_REG) (const_int 0)) + (if_then_else:SWI248 (ltu (reg:CCC FLAGS_REG) (const_int 0)) (match_dup 3) (match_dup 4)))] { @@ -19326,10 +19326,10 @@ "&& 1" [(set (reg:CCC FLAGS_REG) (compare:CCC - (zero_extract:SWI48 (match_dup 1) (const_int 1) (match_dup 2)) - (const_int 0))) + (const_int 0) + (zero_extract:SWI48 (match_dup 1) (const_int 1) (match_dup 2)))) (set (match_dup 0) - (eq:QI (reg:CCC FLAGS_REG) (const_int 0)))]) + (ltu:QI (reg:CCC FLAGS_REG) (const_int 0)))]) ;; Help combine recognize bt followed by setnc (define_insn_and_split "*bt_setncqi" @@ -19346,10 +19346,10 @@ "&& 1" [(set (reg:CCC FLAGS_REG) (compare:CCC - (zero_extract:SWI48 (match_dup 1) (const_int 1) (match_dup 2)) - (const_int 0))) + (const_int 0) + (zero_extract:SWI48 (match_dup 1) (const_int 1) (match_dup 2)))) (set (match_dup 0) - (ne:QI (reg:CCC FLAGS_REG) (const_int 0)))]) + (geu:QI (reg:CCC FLAGS_REG) (const_int 0)))]) (define_insn_and_split "*bt_setnc" [(set (match_operand:SWI48 0 "register_operand") @@ -19364,10 +19364,10 @@ "&& 1" [(set (reg:CCC FLAGS_REG) (compare:CCC - (zero_extract:SWI48 (match_dup 1) (const_int 1) (match_dup 2)) - (const_int 0))) + (const_int 0) + (zero_extract:SWI48 (match_dup 1) (const_int 1) (match_dup 2)))) (set (match_dup 3) - (ne:QI (reg:CCC FLAGS_REG) (const_int 0))) + (geu:QI (reg:CCC FLAGS_REG) (const_int 0))) (set (match_dup 0) (zero_extend:SWI48 (match_dup 3)))] "operands[3] = gen_reg_rtx (QImode);") @@ -19386,10 +19386,10 @@ "&& 1" [(set (reg:CCC FLAGS_REG) (compare:CCC - (zero_extract:SWI48 (match_dup 1) (const_int 1) (match_dup 2)) - (const_int 0))) + (const_int 0) + (zero_extract:SWI48 (match_dup 1) (const_int 1) (match_dup 2)))) (set (match_dup 0) - (ne:QI (reg:CCC FLAGS_REG) (const_int 0)))]) + (geu:QI (reg:CCC FLAGS_REG) (const_int 0)))]) ;; Help combine recognize bt followed by setc (define_insn_and_split "*bt_setc_mask" @@ -19410,10 +19410,10 @@ "&& 1" [(set (reg:CCC FLAGS_REG) (compare:CCC - (zero_extract:SWI48 (match_dup 1) (const_int 1) (match_dup 2)) - (const_int 0))) + (const_int 0) + (zero_extract:SWI48 (match_dup 1) (const_int 1) (match_dup 2)))) (set (match_dup 3) - (eq:QI (reg:CCC FLAGS_REG) (const_int 0))) + (ltu:QI (reg:CCC FLAGS_REG) (const_int 0))) (set (match_dup 0) (zero_extend:SWI48 (match_dup 3)))] { operands[2] = gen_lowpart (QImode, operands[2]); diff --git a/gcc/testsuite/gcc.c-torture/execute/pr118623.c b/gcc/testsuite/gcc.c-torture/execute/pr118623.c new file mode 100644 index 00000000000..bd14e1ce322 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr118623.c @@ -0,0 +1,23 @@ +/* PR target/118623 */ + +static int +foo (int x, int y) +{ + int a = 1 << x; + if (y & a) + return 0; + return 5; +} + +__attribute__((noipa)) void +bar (int x) +{ + if (((foo (x - 50, x) + x + x) & 1) == 0) + __builtin_abort (); +} + +int +main () +{ + bar (63); +}