Liu winter via llvm-dev
2017-Mar-22 03:03 UTC
[llvm-dev] Code selection problem in LLVM backend
Hi, I'm currently writing a backend for a specific platform. On the target platform, "add/sub" always write a flag result. I used SDNode pattern "add/sub" for these two instructions, however this leading to a wrongly code as follows, cmp ... add ... ... beq "add" changes the flag. Desired code is: add... cmp ... ;No add/sub beq Then I tried to use SDNode pattern "addc/subc" instead, but it doesn't matter and cause some other errors. What should I do to generate code that no "add/sub" between "cmp" and "branch"? -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170322/ccb1553b/attachment.html>
Krzysztof Parzyszek via llvm-dev
2017-Mar-22 20:13 UTC
[llvm-dev] Code selection problem in LLVM backend
You could model the flag as a register that is modified by cmp/add/sub and read by conditional branches. This should introduce data dependencies that would prevent incorrect scheduling. -Krzysztof On 3/21/2017 10:03 PM, Liu winter via llvm-dev wrote:> Hi, > > > I'm currently writing a backend for a specific platform. On the target > platform, "add/sub" always write a flag result. I used SDNode pattern > "add/sub" for these two instructions, however this leading to a wrongly > code as follows, > > > cmp > > ... > > add ... > > ... > > beq > > > "add" changes the flag. Desired code is: > > > add... > > cmp > > ... ;No add/sub > > beq > > > Then I tried to use SDNode pattern "addc/subc" instead, but it doesn't > matter and cause some other errors. What should I do to generate code > that no "add/sub" between "cmp" and "branch"? > > > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation