• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc < %s -march=x86-64 | FileCheck %s
2; CHECK: addl
3
4; The two additions are the same , but have different flags.
5; In theory this code should never be generated by the frontend, but this
6; tries to test that two identical instructions with two different flags
7; actually generate two different nodes.
8;
9; Normally the combiner would see this condition without the flags
10; and optimize the result of the sub into a register clear
11; (the final result would be 0). With the different flags though the combiner
12; needs to keep the add + sub nodes, because the two nodes result as different
13; nodes and so cannot assume that the subtraction of the two nodes
14; generates 0 as result
15define i32 @foo(i32 %a, i32 %b) {
16  %1 = add i32 %a, %b
17  %2 = add nsw i32 %a, %b
18  %3 = sub i32 %1, %2
19  ret i32 %3
20}
21