[PATCH, i386]: Fix PR78310, insn does not satisfy its constraints: {*bmi2_rorxdi3_1} with -mbmi2
Uros Bizjak
ubizjak@gmail.com
Fri Nov 11 16:24:00 GMT 2016
2016-11-11 Uros Bizjak <ubizjak@gmail.com>
PR target/78310
* config/i386/i386.md (rotate to rotatex splitter): Avoid overflow
when calculating operand 2.
(rotate to rotatex zext splitter): Ditto.
testsuite/ChangeLog:
2016-11-11 Uros Bizjak <ubizjak@gmail.com>
PR target/78310
* gcc.target/i386/pr78310.c: New test.
Bootstrapped and regression tested on x86_64-linux-gnu {,-m32}.
Committed to SVN, will be backported to release branches.
Uros.
-------------- next part --------------
Index: config/i386/i386.md
===================================================================
--- config/i386/i386.md (revision 242073)
+++ config/i386/i386.md (working copy)
@@ -10908,8 +10908,9 @@
[(set (match_dup 0)
(rotatert:SWI48 (match_dup 1) (match_dup 2)))]
{
- operands[2]
- = GEN_INT (GET_MODE_BITSIZE (<MODE>mode) - INTVAL (operands[2]));
+ int bitsize = GET_MODE_BITSIZE (<MODE>mode);
+
+ operands[2] = GEN_INT ((bitsize - INTVAL (operands[2])) % bitsize);
})
(define_split
@@ -10975,8 +10976,9 @@
[(set (match_dup 0)
(zero_extend:DI (rotatert:SI (match_dup 1) (match_dup 2))))]
{
- operands[2]
- = GEN_INT (GET_MODE_BITSIZE (SImode) - INTVAL (operands[2]));
+ int bitsize = GET_MODE_BITSIZE (SImode);
+
+ operands[2] = GEN_INT ((bitsize - INTVAL (operands[2])) % bitsize);
})
(define_split
Index: testsuite/gcc.target/i386/pr78310.c
===================================================================
--- testsuite/gcc.target/i386/pr78310.c (nonexistent)
+++ testsuite/gcc.target/i386/pr78310.c (working copy)
@@ -0,0 +1,15 @@
+/* { dg-do compile { target { ! ia32 } } } */
+/* { dg-options "-O -mbmi2" } */
+
+unsigned long long a;
+int b;
+
+int
+fn1(int p1)
+{
+ p1 &= 1;
+ p1 &= (short)~p1;
+ b = a;
+ a = a << p1 | a >> (64 - p1);
+ return p1 + 1 + a;
+}
More information about the Gcc-patches
mailing list