aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2018-12-11 15:50:22 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2018-12-11 15:50:22 +0100
commit61d1d9a664851d5004d8238c996d0f42768c0562 (patch)
tree54e1c3a89bc812c407f3741dae48313f08185e13 /gcc
parent6d9391732bc8816627ff40103a6261d233c722bf (diff)
downloadgcc-61d1d9a664851d5004d8238c996d0f42768c0562.zip
gcc-61d1d9a664851d5004d8238c996d0f42768c0562.tar.gz
gcc-61d1d9a664851d5004d8238c996d0f42768c0562.tar.bz2
re PR target/88425 (suboptimal code for a<imm?-1:0)
PR target/88425 * config/i386/i386.md (*x86_mov<SWI48:mode>cc_0_m1_neg_leu<SWI:mode>): New define_insn_and_split. * gcc.target/i386/pr88425.c: New test. From-SVN: r267023
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/config/i386/i386.md18
-rw-r--r--gcc/testsuite/ChangeLog3
-rw-r--r--gcc/testsuite/gcc.target/i386/pr88425.c53
4 files changed, 80 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index a40b365..31cafdca 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2018-12-11 Jakub Jelinek <jakub@redhat.com>
+
+ PR target/88425
+ * config/i386/i386.md (*x86_mov<SWI48:mode>cc_0_m1_neg_leu<SWI:mode>):
+ New define_insn_and_split.
+
2018-12-11 Richard Biener <rguenther@suse.de>
PR middle-end/88448
diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
index 37a92f5..800b649 100644
--- a/gcc/config/i386/i386.md
+++ b/gcc/config/i386/i386.md
@@ -17195,6 +17195,24 @@
(set_attr "mode" "<MODE>")
(set_attr "length_immediate" "0")])
+(define_insn_and_split "*x86_mov<SWI48:mode>cc_0_m1_neg_leu<SWI:mode>"
+ [(set (match_operand:SWI48 0 "register_operand" "=r")
+ (neg:SWI48
+ (leu:SWI48
+ (match_operand:SWI 1 "nonimmediate_operand" "<SWI:r>m")
+ (match_operand:SWI 2 "<SWI:immediate_operand>" "<SWI:i>"))))
+ (clobber (reg:CC FLAGS_REG))]
+ "CONST_INT_P (operands[2])
+ && INTVAL (operands[2]) != -1
+ && INTVAL (operands[2]) != 2147483647"
+ "#"
+ ""
+ [(set (reg:CC FLAGS_REG) (compare:CC (match_dup 1) (match_dup 2)))
+ (parallel [(set (match_dup 0)
+ (neg:SWI48 (ltu:SWI48 (reg:CC FLAGS_REG) (const_int 0))))
+ (clobber (reg:CC FLAGS_REG))])]
+ "operands[2] = GEN_INT (INTVAL (operands[2]) + 1);")
+
(define_insn "*mov<mode>cc_noc"
[(set (match_operand:SWI248 0 "register_operand" "=r,r")
(if_then_else:SWI248 (match_operator 1 "ix86_comparison_operator"
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 52804b4..12acfe3 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,8 @@
2018-12-11 Jakub Jelinek <jakub@redhat.com>
+ PR target/88425
+ * gcc.target/i386/pr88425.c: New test.
+
PR sanitizer/88426
* c-c++-common/ubsan/float-cast-overflow-11.c: New test.
diff --git a/gcc/testsuite/gcc.target/i386/pr88425.c b/gcc/testsuite/gcc.target/i386/pr88425.c
new file mode 100644
index 0000000..e0df560
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr88425.c
@@ -0,0 +1,53 @@
+/* PR target/88425 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -masm=att" } */
+/* { dg-final { scan-assembler-times "sbb\[lq]\[ \t]" 8 } } */
+/* { dg-final { scan-assembler-not "setbe\[ \t]" } } */
+
+unsigned long
+f1 (unsigned long x)
+{
+ return x < 123UL ? -1UL : 0;
+}
+
+unsigned long
+f2 (unsigned int x)
+{
+ return x < 12345U ? -1UL : 0;
+}
+
+unsigned long
+f3 (unsigned short *x)
+{
+ return x[0] < 1234U ? -1UL : 0;
+}
+
+unsigned long
+f4 (unsigned char *x)
+{
+ return x[0] < 123U ? -1UL : 0;
+}
+
+unsigned int
+f5 (unsigned long x)
+{
+ return x < 123UL ? -1U : 0;
+}
+
+unsigned int
+f6 (unsigned int x)
+{
+ return x < 12345U ? -1U : 0;
+}
+
+unsigned int
+f7 (unsigned short *x)
+{
+ return x[0] < 1234U ? -1U : 0;
+}
+
+unsigned int
+f8 (unsigned char *x)
+{
+ return x[0] < 123U ? -1U : 0;
+}