diff mbox

[i386] : Extend TARGET_READ_MODIFY{,_WRITE} peepholes to all integer modes

Message ID CAFULd4b0i_avn529OnqRicK48NTwMczkKcSsOTT7Pnypm+Cz_Q@mail.gmail.com
State New
Headers show

Commit Message

Uros Bizjak April 29, 2016, 11:52 a.m. UTC
On Fri, Apr 29, 2016 at 1:23 PM, Eric Botcazou <ebotcazou@adacore.com> wrote:
>> Attached patch was actually tested on a couple of cases. It generates
>> the same assembly as before.
>
> Note that you could just remove the second ":W" in the define_insn pattern.

Eh, then the build yawns about the missing mode of the input operand.

> That's better, but not quite it because this segfaults at -O2:

This is getting a bit frustrating, but attached patch should solve
this failure. Again lightly tested, regtest in progress.

Uros.

Comments

Eric Botcazou April 29, 2016, 2:30 p.m. UTC | #1
> Eh, then the build yawns about the missing mode of the input operand.

Every good back-end has at least an example of this. ;-)

> This is getting a bit frustrating, but attached patch should solve
> this failure. Again lightly tested, regtest in progress.

Everything is back to normal with this one, thanks!
Uros Bizjak April 29, 2016, 2:44 p.m. UTC | #2
On Fri, Apr 29, 2016 at 4:30 PM, Eric Botcazou <ebotcazou@adacore.com> wrote:
>> Eh, then the build yawns about the missing mode of the input operand.
>
> Every good back-end has at least an example of this. ;-)
>
>> This is getting a bit frustrating, but attached patch should solve
>> this failure. Again lightly tested, regtest in progress.
>
> Everything is back to normal with this one, thanks!

Thanks for testing, committed to mainline with following ChangeLog:

2016-04-29  Uros Bizjak  <ubizjak@gmail.com>

    * config/i386/i386.md (unspec): Add UNSPEC_PROBE_STACK.
    (probe_stack): New expander.
    (probe_stack_<mode>): New insn pattern.

Uros.
diff mbox

Patch

Index: i386.md
===================================================================
--- i386.md	(revision 235620)
+++ i386.md	(working copy)
@@ -88,6 +88,7 @@ 
   UNSPEC_SET_GOT_OFFSET
   UNSPEC_MEMORY_BLOCKAGE
   UNSPEC_STACK_CHECK
+  UNSPEC_PROBE_STACK
 
   ;; TLS support
   UNSPEC_TP
@@ -17552,6 +17553,30 @@ 
   DONE;
 })
 
+(define_expand "probe_stack"
+  [(match_operand 0 "memory_operand")]
+  ""
+{
+  rtx (*insn) (rtx, rtx)
+    = (GET_MODE (operands[0]) == DImode
+       ? gen_probe_stack_di : gen_probe_stack_si);
+
+  emit_insn (insn (operands[0], const0_rtx));
+  DONE;
+})
+
+;; Use OR for stack probes, this is shorter.
+(define_insn "probe_stack_<mode>"
+  [(set (match_operand:W 0 "memory_operand" "=m")
+	(unspec:W [(match_operand:W 1 "const0_operand")]
+		  UNSPEC_PROBE_STACK))
+   (clobber (reg:CC FLAGS_REG))]
+  ""
+  "or{<imodesuffix>}\t{%1, %0|%0, %1}"
+  [(set_attr "type" "alu1")
+   (set_attr "mode" "<MODE>")
+   (set_attr "length_immediate" "1")])
+  
 (define_insn "adjust_stack_and_probe<mode>"
   [(set (match_operand:P 0 "register_operand" "=r")
 	(unspec_volatile:P [(match_operand:P 1 "register_operand" "0")]