diff mbox

PR63442 ICE with ubsan/overflow-int128.c test on AArch64

Message ID 544105DF.9070504@arm.com
State New
Headers show

Commit Message

Jiong Wang Oct. 17, 2014, 12:04 p.m. UTC
the cause should be one minor bug in prepare_cmp_insn.

the last mode parameter "pmode" of "prepare_cmp_insn" should match the
mode of the first parameter "x", while during the recursive call of "prepare_cmp_insn",
x is with mode of targetm.libgcc_cmp_return_mode () while pmode is assign to word_mode.

generally this is OK, because default libgcc_cmp_return_mode hook always return word_mode,
but AArch64 has a target private implementation which always return SImode, so there is a
mismatch which cause a ICE later.

this minor issue is hidding because nearly all other targets use default hook, and the
compare is rarely invoked.

Thanks

gcc/
   PR target/63442
   * optabs.c (prepare_cmp_insn): Use target hook "libgcc_cmp_return_mode" instead of word_mode.

Comments

Jiong Wang Oct. 24, 2014, 2:09 p.m. UTC | #1
ping~

thanks.

Regards,
Jiong

On 17/10/14 13:04, Jiong Wang wrote:
> the cause should be one minor bug in prepare_cmp_insn.
>
> the last mode parameter "pmode" of "prepare_cmp_insn" should match the
> mode of the first parameter "x", while during the recursive call of "prepare_cmp_insn",
> x is with mode of targetm.libgcc_cmp_return_mode () and pmode is assign to word_mode.
>
> generally this is OK, because default libgcc_cmp_return_mode hook always return word_mode,
> but AArch64 has a target private implementation which always return SImode, so there is a
> mismatch which cause a ICE later.
>
> this minor issue is hidding because nearly all other targets use default hook, and the
> compare is rarely invoked.
>
> Thanks
>
> gcc/
>     PR target/63442
>     * optabs.c (prepare_cmp_insn): Use target hook "libgcc_cmp_return_mode" instead of word_mode.
Jeff Law Oct. 24, 2014, 6:41 p.m. UTC | #2
On 10/24/14 08:09, Jiong Wang wrote:
> ping~
>
> thanks.
>
> Regards,
> Jiong
>
> On 17/10/14 13:04, Jiong Wang wrote:
>> the cause should be one minor bug in prepare_cmp_insn.
>>
>> the last mode parameter "pmode" of "prepare_cmp_insn" should match the
>> mode of the first parameter "x", while during the recursive call of
>> "prepare_cmp_insn",
>> x is with mode of targetm.libgcc_cmp_return_mode () and pmode is
>> assign to word_mode.
>>
>> generally this is OK, because default libgcc_cmp_return_mode hook
>> always return word_mode,
>> but AArch64 has a target private implementation which always return
>> SImode, so there is a
>> mismatch which cause a ICE later.
>>
>> this minor issue is hidding because nearly all other targets use
>> default hook, and the
>> compare is rarely invoked.
>>
>> Thanks
>>
>> gcc/
>>     PR target/63442
>>     * optabs.c (prepare_cmp_insn): Use target hook
>> "libgcc_cmp_return_mode" instead of word_mode.
This is fine once you have run it through a bootstrap and regression test.

Any reason not to use RET_MODE since that's already set up with the 
result of the target hook?

Jeff
diff mbox

Patch

diff --git a/gcc/optabs.c b/gcc/optabs.c
index d55a6bb..3073816 100644
--- a/gcc/optabs.c
+++ b/gcc/optabs.c
@@ -4264,7 +4264,7 @@  prepare_cmp_insn (rtx x, rtx y, enum rtx_code comparison, rtx size,
 	    y = const0_rtx;
 	}

-      *pmode = word_mode;
+      *pmode = targetm.libgcc_cmp_return_mode ();
       prepare_cmp_insn (x, y, comparison, NULL_RTX, unsignedp, methods,
 			ptest, pmode);
     }