SimplifySetCC invokes getNodeIfExists without passing Flags argument and getNodeIfExists uses a default SDNodeFlags to intersect the original flags, as a consequence, flags like nsw is dropped. Added a new helper function doesNodeExist to check if a node exists without modifying its flags.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Unit Tests
Time | Test | |
---|---|---|
400 ms | linux > HWAddressSanitizer-x86_64.TestCases::sizes.cpp |
Event Timeline
This patch can fix the issue reflected by your case. However, if you call getNodeIfExists somewhere else with argument Flags, I guess you will still meet the problem that flags of the unrelated existing node are modified.
The optional argument Flags looks confusing sometimes: does it mean (1) 'I want the node with the same opcodes, operands, and flags' or (2) 'I want the node with the same opcodes and operands, apply flags to it if found'?
If (1), the node id doesn't put flags into consideration (also to getNode). If (2), why use intersectFlags and modifying the original node still looks not reasonable.
I think getNodeIfExists() should have the same semantics with respect to flags as getNode().
Maybe we can add a new helper "doesNodeExist()" which just returns a boolean, and doesn't mess with the flags?