diff mbox series

[PR82096,gcc-7] Backport: Fix ICE in int_mode_for_mode, at stor-layout.c:403 with arm-linux-gnueabi

Message ID 8329ffa4-2b7a-43d3-ed0a-10565eae2904@arm.com
State New
Headers show
Series [PR82096,gcc-7] Backport: Fix ICE in int_mode_for_mode, at stor-layout.c:403 with arm-linux-gnueabi | expand

Commit Message

Sudakshina Das Jan. 22, 2018, 3:10 p.m. UTC
Hi

This is a patch to backport r256526 and r256941 (Fix case fix) of trunk 
to fix emit_store_flag_force () function to fix the ICE. The original 
discussion is at 
https://gcc.gnu.org/ml/gcc-patches/2018-01/msg00219.html and 
https://gcc.gnu.org/ml/gcc-patches/2018-01/msg01058.html

Is this ok for gcc-7-branch?
Testing : Ran regression testing with bootstrapped arm-none-linux-gnueabihf.

Thanks
Sudi

ChangeLog entries:

*** gcc/ChangeLog ***

2018-01-22  Sudakshina Das  <sudi.das@arm.com>

	Backport from mainline:
	2018-01-10  Sudakshina Das  <sudi.das@arm.com>

	PR target/82096
	* expmed.c (emit_store_flag_force): Swap if const op0
	and change VOIDmode to mode of op0.

*** gcc/testsuite/ChangeLog ***

2018-01-22  Sudakshina Das  <sudi.das@arm.com>

	Backport from mainline:
	2018-01-10  Sudakshina Das  <sudi.das@arm.com>

	PR target/82096
	* gcc.c-torture/compile/pr82096.c: New test.

Comments

Richard Biener Jan. 22, 2018, 3:23 p.m. UTC | #1
On Mon, Jan 22, 2018 at 4:10 PM, Sudakshina Das <sudi.das@arm.com> wrote:
> Hi
>
> This is a patch to backport r256526 and r256941 (Fix case fix) of trunk to
> fix emit_store_flag_force () function to fix the ICE. The original
> discussion is at https://gcc.gnu.org/ml/gcc-patches/2018-01/msg00219.html
> and https://gcc.gnu.org/ml/gcc-patches/2018-01/msg01058.html
>
> Is this ok for gcc-7-branch?
> Testing : Ran regression testing with bootstrapped arm-none-linux-gnueabihf.

The branch is currently frozen so please wait until after the GCC 7.3 release.

Thanks,
Richard.

> Thanks
> Sudi
>
> ChangeLog entries:
>
> *** gcc/ChangeLog ***
>
> 2018-01-22  Sudakshina Das  <sudi.das@arm.com>
>
>         Backport from mainline:
>         2018-01-10  Sudakshina Das  <sudi.das@arm.com>
>
>         PR target/82096
>         * expmed.c (emit_store_flag_force): Swap if const op0
>         and change VOIDmode to mode of op0.
>
> *** gcc/testsuite/ChangeLog ***
>
> 2018-01-22  Sudakshina Das  <sudi.das@arm.com>
>
>         Backport from mainline:
>         2018-01-10  Sudakshina Das  <sudi.das@arm.com>
>
>         PR target/82096
>         * gcc.c-torture/compile/pr82096.c: New test.
Sudakshina Das Feb. 16, 2018, 3:40 p.m. UTC | #2
On 22/01/18 15:23, Richard Biener wrote:
> On Mon, Jan 22, 2018 at 4:10 PM, Sudakshina Das <sudi.das@arm.com> wrote:
>> Hi
>>
>> This is a patch to backport r256526 and r256941 (Fix case fix) of trunk to
>> fix emit_store_flag_force () function to fix the ICE. The original
>> discussion is at https://gcc.gnu.org/ml/gcc-patches/2018-01/msg00219.html
>> and https://gcc.gnu.org/ml/gcc-patches/2018-01/msg01058.html
>>
>> Is this ok for gcc-7-branch?
>> Testing : Ran regression testing with bootstrapped arm-none-linux-gnueabihf.
> 
> The branch is currently frozen so please wait until after the GCC 7.3 release.

Committed as r257741

Thanks
Sudi

> 
> Thanks,
> Richard.
> 
>> Thanks
>> Sudi
>>
>> ChangeLog entries:
>>
>> *** gcc/ChangeLog ***
>>
>> 2018-01-22  Sudakshina Das  <sudi.das@arm.com>
>>
>>          Backport from mainline:
>>          2018-01-10  Sudakshina Das  <sudi.das@arm.com>
>>
>>          PR target/82096
>>          * expmed.c (emit_store_flag_force): Swap if const op0
>>          and change VOIDmode to mode of op0.
>>
>> *** gcc/testsuite/ChangeLog ***
>>
>> 2018-01-22  Sudakshina Das  <sudi.das@arm.com>
>>
>>          Backport from mainline:
>>          2018-01-10  Sudakshina Das  <sudi.das@arm.com>
>>
>>          PR target/82096
>>          * gcc.c-torture/compile/pr82096.c: New test.
Sudakshina Das Feb. 21, 2018, 12:55 p.m. UTC | #3
On 16/02/18 15:40, Sudakshina Das wrote:
> On 22/01/18 15:23, Richard Biener wrote:
>> On Mon, Jan 22, 2018 at 4:10 PM, Sudakshina Das <sudi.das@arm.com> wrote:
>>> Hi
>>>
>>> This is a patch to backport r256526 and r256941 (Fix case fix) of 
>>> trunk to
>>> fix emit_store_flag_force () function to fix the ICE. The original
>>> discussion is at 
>>> https://gcc.gnu.org/ml/gcc-patches/2018-01/msg00219.html
>>> and https://gcc.gnu.org/ml/gcc-patches/2018-01/msg01058.html
>>>
>>> Is this ok for gcc-7-branch?
>>> Testing : Ran regression testing with bootstrapped 
>>> arm-none-linux-gnueabihf.
>>
>> The branch is currently frozen so please wait until after the GCC 7.3 
>> release.
> 
> Committed as r257741

Backported to gcc-6 as r257871

Thanks
Sudi

> 
> Thanks
> Sudi
> 
>>
>> Thanks,
>> Richard.
>>
>>> Thanks
>>> Sudi
>>>
>>> ChangeLog entries:
>>>
>>> *** gcc/ChangeLog ***
>>>
>>> 2018-01-22  Sudakshina Das  <sudi.das@arm.com>
>>>
>>>          Backport from mainline:
>>>          2018-01-10  Sudakshina Das  <sudi.das@arm.com>
>>>
>>>          PR target/82096
>>>          * expmed.c (emit_store_flag_force): Swap if const op0
>>>          and change VOIDmode to mode of op0.
>>>
>>> *** gcc/testsuite/ChangeLog ***
>>>
>>> 2018-01-22  Sudakshina Das  <sudi.das@arm.com>
>>>
>>>          Backport from mainline:
>>>          2018-01-10  Sudakshina Das  <sudi.das@arm.com>
>>>
>>>          PR target/82096
>>>          * gcc.c-torture/compile/pr82096.c: New test.
>
diff mbox series

Patch

diff --git a/gcc/expmed.c b/gcc/expmed.c
index e9f634a..30001ac 100644
--- a/gcc/expmed.c
+++ b/gcc/expmed.c
@@ -5886,6 +5886,18 @@  emit_store_flag_force (rtx target, enum rtx_code code, rtx op0, rtx op1,
   if (tem != 0)
     return tem;
 
+  /* If one operand is constant, make it the second one.  Only do this
+     if the other operand is not constant as well.  */
+
+  if (swap_commutative_operands_p (op0, op1))
+    {
+      std::swap (op0, op1);
+      code = swap_condition (code);
+    }
+
+  if (mode == VOIDmode)
+    mode = GET_MODE (op0);
+
   if (!target)
     target = gen_reg_rtx (word_mode);
 
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr82096.c b/gcc/testsuite/gcc.c-torture/compile/pr82096.c
new file mode 100644
index 0000000..d144b70
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/pr82096.c
@@ -0,0 +1,11 @@ 
+/* { dg-require-effective-target arm_arch_v5t_ok { target arm*-*-* } } */
+/* { dg-skip-if "Do not combine float-abi values" { arm*-*-* } { "-mfloat-abi=*" } { "-mfloat-abi=soft" } } */
+/* { dg-additional-options "-march=armv5t -mthumb -mfloat-abi=soft" { target arm*-*-* } } */
+
+static long long AL[24];
+
+int
+check_ok (void)
+{
+  return (__sync_bool_compare_and_swap (AL+1, 0x200000003ll, 0x1234567890ll));
+}