diff options
author | Jim Wilson <wilson@gcc.gnu.org> | 1995-04-02 14:34:42 -0700 |
---|---|---|
committer | Jim Wilson <wilson@gcc.gnu.org> | 1995-04-02 14:34:42 -0700 |
commit | c27b5c621add2e8fb6b902db970f1567f98702e5 (patch) | |
tree | 0b0d136390a8eedbd3118eb72d8370c894773cbe /gcc/cse.c | |
parent | e3124505ece242bb964c02b325395e5831c3975e (diff) | |
download | gcc-c27b5c621add2e8fb6b902db970f1567f98702e5.zip gcc-c27b5c621add2e8fb6b902db970f1567f98702e5.tar.gz gcc-c27b5c621add2e8fb6b902db970f1567f98702e5.tar.bz2 |
(simplify_relational_operation): Don't simplify A-B for
compare of A and B when the compare is unsigned.
From-SVN: r9296
Diffstat (limited to 'gcc/cse.c')
-rw-r--r-- | gcc/cse.c | 14 |
1 files changed, 5 insertions, 9 deletions
@@ -4378,20 +4378,16 @@ simplify_relational_operation (code, mode, op0, op1) a register or a CONST_INT, this can't help; testing for these cases will prevent infinite recursion here and speed things up. - If CODE is an unsigned comparison, we can only do this if A - B is a - constant integer, and then we have to compare that integer with zero as a - signed comparison. Note that this will give the incorrect result from - comparisons that overflow. Since these are undefined, this is probably - OK. If it causes a problem, we can check for A or B being an address - (fp + const or SYMBOL_REF) and only do it in that case. */ + If CODE is an unsigned comparison, then we can never do this optimization, + because it gives an incorrect result if the subtraction wraps around zero. + ANSI C defines unsigned operations such that they never overflow, and + thus such cases can not be ignored. */ if (INTEGRAL_MODE_P (mode) && op1 != const0_rtx && ! ((GET_CODE (op0) == REG || GET_CODE (op0) == CONST_INT) && (GET_CODE (op1) == REG || GET_CODE (op1) == CONST_INT)) && 0 != (tem = simplify_binary_operation (MINUS, mode, op0, op1)) - && (GET_CODE (tem) == CONST_INT - || (code != GTU && code != GEU && - code != LTU && code != LEU))) + && code != GTU && code != GEU && code != LTU && code != LEU) return simplify_relational_operation (signed_condition (code), mode, tem, const0_rtx); |